]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Создаем миграции и модели
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 10 Dec 2024 10:01:58 +0000 (13:01 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 10 Dec 2024 10:01:58 +0000 (13:01 +0300)
erp24/migrations/m241210_090957_waybill_write_offs.php [new file with mode: 0644]
erp24/migrations/m241210_091021_waybill_write_offs_products.php [new file with mode: 0644]
erp24/records/WaybillWriteOffs.php [new file with mode: 0644]
erp24/records/WaybillWriteOffsProducts.php [new file with mode: 0644]

diff --git a/erp24/migrations/m241210_090957_waybill_write_offs.php b/erp24/migrations/m241210_090957_waybill_write_offs.php
new file mode 100644 (file)
index 0000000..378a9b9
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241210_090957_waybill_write_offs
+ */
+class m241210_090957_waybill_write_offs extends Migration
+{
+    const TABLE_NAME  = 'erp24.waybill_write_offs';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->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 (file)
index 0000000..0fd94ec
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241210_091021_waybill_write_offs_products
+ */
+class m241210_091021_waybill_write_offs_products extends Migration
+{
+    const TABLE_NAME  = 'erp24.waybill_write_offs_products';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->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 (file)
index 0000000..55fe64f
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "waybill_write_offs".
+ *
+ * @property int $id ID
+ * @property string $guid GUID документа для 1c
+ * @property int $status Статус документа
+ * @property int $created_admin_id Создан пользователем
+ * @property int|null $updated_admin_id Изменён пользователем
+ * @property int|null $confirm_admin_id Подтвержден пользователем
+ * @property int $store_id id магазина в ERP
+ * @property string $store_guid GUID магазина из 1с
+ * @property string $number Название документа
+ * @property string|null $number_1c Название документа в 1с
+ * @property string|null $based_on Документ основания
+ * @property string $write_offs_type ТИП документа
+ * @property string $date Дата документа
+ * @property string|null $comment Комментарий
+ * @property float $quantity Количество
+ * @property float|null $summ Сумма списания в закупочных ценах рублях
+ * @property float|null $summ_retail Сумма в розничных ценах
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property string|null $deleted_at Дата удаление
+ * @property string|null $confirm_at Дата подтверждения
+ * @property string|null $send_at Дата отправления в 1с
+ * @property int $active Активность
+ * @property int|null $deleted_admin_id Удален пользователем
+ */
+class WaybillWriteOffs extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'waybill_write_offs';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['guid', 'created_admin_id', 'store_id', 'store_guid', 'number', 'write_offs_type', 'date', 'quantity', 'created_at'], 'required'],
+            [['status', 'created_admin_id', 'updated_admin_id', 'confirm_admin_id', 'store_id', 'active', 'deleted_admin_id'], 'default', 'value' => 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 (file)
index 0000000..a17a9f4
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "waybill_write_offs_products".
+ *
+ * @property int $id ID
+ * @property int $waybill_write_offs_id GUID документа из таблицы waybill_write_offs
+ * @property string $name Название товара
+ * @property string $product_id GUID товара из таблицы products_1c
+ * @property float $quantity Количество
+ * @property float $price Цена
+ * @property float|null $price_retail Розничная цена
+ * @property float|null $price_self_cost Себестоимость
+ * @property float $summ Сумма
+ * @property float|null $summ_retail Сумма в розничных ценах
+ * @property float|null $summ_self_cost Сумма себестоимости
+ * @property int $active_product Активность
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property string|null $deleted_at Дата удаление
+ * @property int $created_admin_id Создан пользователем
+ * @property int|null $updated_admin_id Изменён пользователем
+ * @property int|null $deleted_admin_id Удален пользователем
+ */
+class WaybillWriteOffsProducts extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'waybill_write_offs_products';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['waybill_write_offs_id', 'name', 'product_id', 'quantity', 'price', 'summ', 'created_at', 'created_admin_id'], 'required'],
+            [['waybill_write_offs_id', 'active_product', 'created_admin_id', 'updated_admin_id', 'deleted_admin_id'], 'default', 'value' => 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' => 'Удален пользователем',
+        ];
+    }
+}