From 260b773fa090c8952a407230e800f82731178236 Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 10 Dec 2024 13:01:58 +0300 Subject: [PATCH] =?utf8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=B5=D0=BC=20?= =?utf8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20?= =?utf8?q?=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../m241210_090957_waybill_write_offs.php | 73 ++++++++++++++ ...210_091021_waybill_write_offs_products.php | 67 +++++++++++++ erp24/records/WaybillWriteOffs.php | 94 +++++++++++++++++++ erp24/records/WaybillWriteOffsProducts.php | 80 ++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 erp24/migrations/m241210_090957_waybill_write_offs.php create mode 100644 erp24/migrations/m241210_091021_waybill_write_offs_products.php create mode 100644 erp24/records/WaybillWriteOffs.php create mode 100644 erp24/records/WaybillWriteOffsProducts.php diff --git a/erp24/migrations/m241210_090957_waybill_write_offs.php b/erp24/migrations/m241210_090957_waybill_write_offs.php new file mode 100644 index 00000000..378a9b9a --- /dev/null +++ b/erp24/migrations/m241210_090957_waybill_write_offs.php @@ -0,0 +1,73 @@ +db->getTableSchema(self::TABLE_NAME); + + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'id' => $this->primaryKey()->comment('ID'), + 'guid' => $this->string(100)->notNull()->unique()->comment('GUID документа для 1c'), + 'status' => $this->integer()->notNull()->defaultValue(1)->comment('Статус документа'), + 'created_admin_id' => $this->integer()->notNull()->comment('Создан пользователем'), + 'updated_admin_id' => $this->integer()->null()->comment('Изменён пользователем'), + 'confirm_admin_id' => $this->integer()->null()->comment('Подтвержден пользователем'), + 'store_id' => $this->integer()->notNull()->comment('id магазина в ERP'), + 'store_guid' => $this->string(100)->notNull()->comment('GUID магазина из 1с'), + 'number' => $this->string(100)->notNull()->comment('Название документа'), + 'number_1c' => $this->string(100)->null()->comment('Название документа в 1с'), + 'based_on' => $this->string(100)->null()->comment('Документ основания'), + 'write_offs_type' => $this->string(100)->notNull()->comment('ТИП документа'), + 'date' => $this->dateTime()->notNull()->comment('Дата документа'), + 'comment' => $this->text()->null()->comment('Комментарий'), + 'quantity' => $this->float()->notNull()->comment('Количество'), + 'summ' => $this->float()->null()->comment('Сумма списания в закупочных ценах рублях'), + 'summ_retail' => $this->float()->null()->comment('Сумма в розничных ценах'), + 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'), + 'updated_at' => $this->dateTime()->null()->comment('Дата обновления'), + 'deleted_at' => $this->dateTime()->null()->comment('Дата удаление'), + 'confirm_at' => $this->string(100)->null()->comment('Дата подтверждения'), + 'send_at' => $this->dateTime()->null()->comment('Дата отправления в 1с'), + 'active' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность'), + 'deleted_admin_id' => $this->integer()->null()->comment('Удален пользователем'), + ]); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + if (isset($tableSchema)) { + $this->dropTable(self::TABLE_NAME); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m241210_090957_waybill_write_offs cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/migrations/m241210_091021_waybill_write_offs_products.php b/erp24/migrations/m241210_091021_waybill_write_offs_products.php new file mode 100644 index 00000000..0fd94ec3 --- /dev/null +++ b/erp24/migrations/m241210_091021_waybill_write_offs_products.php @@ -0,0 +1,67 @@ +db->getTableSchema(self::TABLE_NAME); + + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'id' => $this->primaryKey()->comment('ID'), + 'waybill_write_offs_id' => $this->integer()->notNull()->comment('GUID документа из таблицы waybill_write_offs'), + 'name' => $this->string(100)->notNull()->comment('Название товара'), + 'product_id' => $this->string(100)->notNull()->comment('GUID товара из таблицы products_1c'), + 'quantity' => $this->float()->notNull()->comment('Количество'), + 'price' => $this->float()->notNull()->comment('Цена'), + 'price_retail' => $this->float()->null()->comment('Розничная цена'), + 'price_self_cost' => $this->float()->null()->comment('Себестоимость'), + 'summ' => $this->float()->notNull()->comment('Сумма'), + 'summ_retail' => $this->float()->null()->comment('Сумма в розничных ценах'), + 'summ_self_cost' => $this->float()->null()->comment('Сумма себестоимости'), + 'active_product' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность'), + 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'), + 'updated_at' => $this->dateTime()->null()->comment('Дата обновления'), + 'deleted_at' => $this->dateTime()->null()->comment('Дата удаление'), + 'created_admin_id' => $this->integer()->notNull()->comment('Создан пользователем'), + 'updated_admin_id' => $this->integer()->null()->comment('Изменён пользователем'), + 'deleted_admin_id' => $this->integer()->null()->comment('Удален пользователем'), + ]); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + if (isset($tableSchema)) { + $this->dropTable(self::TABLE_NAME); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m241210_091021_waybill_write_offs_products cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/records/WaybillWriteOffs.php b/erp24/records/WaybillWriteOffs.php new file mode 100644 index 00000000..55fe64f8 --- /dev/null +++ b/erp24/records/WaybillWriteOffs.php @@ -0,0 +1,94 @@ + null], + [['status', 'created_admin_id', 'updated_admin_id', 'confirm_admin_id', 'store_id', 'active', 'deleted_admin_id'], 'integer'], + [['date', 'created_at', 'updated_at', 'deleted_at', 'send_at'], 'safe'], + [['comment'], 'string'], + [['quantity', 'summ', 'summ_retail'], 'number'], + [['guid', 'store_guid', 'number', 'number_1c', 'based_on', 'write_offs_type', 'confirm_at'], 'string', 'max' => 100], + [['guid'], 'unique'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'guid' => 'GUID документа для 1c', + 'status' => 'Статус документа', + 'created_admin_id' => 'Создан пользователем', + 'updated_admin_id' => 'Изменён пользователем', + 'confirm_admin_id' => 'Подтвержден пользователем', + 'store_id' => 'id магазина в ERP', + 'store_guid' => 'GUID магазина из 1с', + 'number' => 'Название документа', + 'number_1c' => 'Название документа в 1с', + 'based_on' => 'Документ основания', + 'write_offs_type' => 'ТИП документа', + 'date' => 'Дата документа', + 'comment' => 'Комментарий', + 'quantity' => 'Количество', + 'summ' => 'Сумма списания в закупочных ценах рублях', + 'summ_retail' => 'Сумма в розничных ценах', + 'created_at' => 'Дата создания', + 'updated_at' => 'Дата обновления', + 'deleted_at' => 'Дата удаление', + 'confirm_at' => 'Дата подтверждения', + 'send_at' => 'Дата отправления в 1с', + 'active' => 'Активность', + 'deleted_admin_id' => 'Удален пользователем', + ]; + } +} diff --git a/erp24/records/WaybillWriteOffsProducts.php b/erp24/records/WaybillWriteOffsProducts.php new file mode 100644 index 00000000..a17a9f48 --- /dev/null +++ b/erp24/records/WaybillWriteOffsProducts.php @@ -0,0 +1,80 @@ + null], + [['waybill_write_offs_id', 'active_product', 'created_admin_id', 'updated_admin_id', 'deleted_admin_id'], 'integer'], + [['quantity', 'price', 'price_retail', 'price_self_cost', 'summ', 'summ_retail', 'summ_self_cost'], 'number'], + [['created_at', 'updated_at', 'deleted_at'], 'safe'], + [['name', 'product_id'], 'string', 'max' => 100], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'waybill_write_offs_id' => 'GUID документа из таблицы replacement_invoice', + 'name' => 'Название товара', + 'product_id' => 'GUID товара из таблицы products_1c', + 'quantity' => 'Количество', + 'price' => 'Цена', + 'price_retail' => 'Розничная цена', + 'price_self_cost' => 'Себестоимость', + 'summ' => 'Сумма', + 'summ_retail' => 'Сумма в розничных ценах', + 'summ_self_cost' => 'Сумма себестоимости', + 'active_product' => 'Активность', + 'created_at' => 'Дата создания', + 'updated_at' => 'Дата обновления', + 'deleted_at' => 'Дата удаление', + 'created_admin_id' => 'Создан пользователем', + 'updated_admin_id' => 'Изменён пользователем', + 'deleted_admin_id' => 'Удален пользователем', + ]; + } +} -- 2.39.5