]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавил свойства type_id и type_guid origin/feature_fomichoff_erp-460_add_type_fields_to_writeoffs
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 28 Aug 2025 08:12:43 +0000 (11:12 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 28 Aug 2025 08:12:43 +0000 (11:12 +0300)
erp24/migrations/m250828_065539_add_type_and_type_id_fields_to_write_offs_tables.php [new file with mode: 0644]
erp24/migrations/m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables.php [new file with mode: 0644]
erp24/records/WriteOffs.php
erp24/records/WriteOffsErp.php

diff --git a/erp24/migrations/m250828_065539_add_type_and_type_id_fields_to_write_offs_tables.php b/erp24/migrations/m250828_065539_add_type_and_type_id_fields_to_write_offs_tables.php
new file mode 100644 (file)
index 0000000..37b98be
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+use yii\db\Migration;
+
+class m250828_065539_add_type_and_type_id_fields_to_write_offs_tables extends Migration
+{
+    const TABLE_NAME = 'erp24.write_offs';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
+        if ($table === null) {
+            return;
+        }
+
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_id')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'type_id',
+                $this->integer()->null()->comment('id типа списания')
+            );
+        }
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_guid')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'type_guid',
+                $this->string()->null()->comment('guid типа списания')
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_id')) {
+            $this->dropColumn(self::TABLE_NAME, 'type_id');
+        }
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_guid')) {
+            $this->dropColumn(self::TABLE_NAME, 'type_guid');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m250828_065539_add_type_and_type_id_fields_to_write_offs_tables cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
diff --git a/erp24/migrations/m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables.php b/erp24/migrations/m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables.php
new file mode 100644 (file)
index 0000000..48aad2e
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+use yii\db\Migration;
+
+class m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables extends Migration
+{
+    const TABLE_NAME = 'erp24.write_offs_erp';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
+        if ($table === null) {
+            return;
+        }
+
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_id')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'type_id',
+                $this->integer()->null()->comment('id типа списания')
+            );
+        }
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_guid')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'type_guid',
+                $this->string()->null()->comment('guid типа списания')
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_id')) {
+            $this->dropColumn(self::TABLE_NAME, 'type_id');
+        }
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('type_guid')) {
+            $this->dropColumn(self::TABLE_NAME, 'type_guid');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index b214f211e4c5d023b4f0fe59a9ae19303542d712..bce6bf176637a34b7420b826229c2545cd82e5aa 100755 (executable)
@@ -25,6 +25,8 @@ use yii_app\services\WriteOffsService;
  * @property string $items
  * @property float $summ
  * @property float $summ_retail
+ * @property integer|null $type_id id типа списания
+ * @property string|null $type_guid guid типа списания
  */
 class WriteOffs extends \yii\db\ActiveRecord
 {
@@ -45,9 +47,9 @@ class WriteOffs extends \yii\db\ActiveRecord
             [['id', 'store_id', 'number', 'date', 'type', /*'comment',*/ 'items', 'summ'], 'required'],
             [['date', 'summ_retail', 'based_on', 'cause'], 'safe'],
             [['based_on', 'cause', 'comment', 'items', 'write_downs'], 'string'],
-            [['summ', 'summ_retail', 'status_id'], 'number'],
+            [['summ', 'summ_retail', 'status_id', 'type_id'], 'number'],
             [['id', 'store_id'], 'string', 'max' => 36],
-            [['number', 'type'], 'string', 'max' => 255],
+            [['number', 'type', 'type_guid'], 'string', 'max' => 255],
             [['id'], 'unique'],
         ];
     }
@@ -71,6 +73,8 @@ class WriteOffs extends \yii\db\ActiveRecord
             'summ_retail' => 'summ_retail',
             'status_id' => 'status_id',
             'write_downs' => 'write_downs',
+            'type_id' => 'id типа списания',
+            'type_guid' => 'guid типа списания',
         ];
     }
 
index fc2d2dd09ff17698ff6aba08ecbd25cb1807594d..60b07e96fa4832c944a8742a22ace5b28085e226 100644 (file)
@@ -39,7 +39,8 @@ use yii\helpers\Html;
  * @property string|null $send_at Дата создания
  * @property array|null $modelsProducts Дата изменения
  * @property float $quantity количество
- *
+ * @property integer|null $type_id id типа списания
+ * @property string|null $type_guid guid типа списания
  * @property WriteOffsProductsErp[] $writeOffsProductsErps
  */
 class WriteOffsErp extends \yii\db\ActiveRecord
@@ -70,8 +71,8 @@ class WriteOffsErp extends \yii\db\ActiveRecord
             [['status', 'created_admin_id', 'updated_admin_id', 'cause_id', 'confirm_admin_id', 'cause_group_id', 'store_id', 'active', 'deleted_admin_id'], 'integer'],
             [['date', 'created_at', 'send_at', 'updated_at', 'confirm_at', 'deleted_at', 'modelsProducts'], 'safe'],
             [['based_on', 'comment', 'error_text', 'write_offs_type'], 'string'],
-            [['summ', 'summ_retail', 'quantity'], 'number'],
-            [['guid', 'store_guid', 'number', 'number_1c', 'date', 'based_on', 'write_offs_type', 'created_at', 'updated_at', 'deleted_at', 'confirm_at', 'send_at'], 'string', 'max' => 100],
+            [['summ', 'summ_retail', 'quantity', 'type_id'], 'number'],
+            [['guid', 'store_guid', 'type_guid', 'number', 'number_1c', 'date', 'based_on', 'write_offs_type', 'created_at', 'updated_at', 'deleted_at', 'confirm_at', 'send_at'], 'string', 'max' => 100],
             [['guid'], 'unique'],
         ];
     }
@@ -104,6 +105,8 @@ class WriteOffsErp extends \yii\db\ActiveRecord
             'active' => 'Активность',
             'quantity' => 'Количество',
             'summ_retail' => 'Summ Retail',
+            'type_id' => 'id типа списания',
+            'type_guid' => 'guid типа списания',
             'send_at' => 'Дата отправки в 1с',
             'created_at' => 'Created At',
             'updated_at' => 'Updated At',