From: Vladimir Fomichev Date: Thu, 28 Aug 2025 08:12:43 +0000 (+0300) Subject: Добавил свойства type_id и type_guid X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=1d69bd4dcd3d82d44a40f97d3cfa4b6ccdf9d266;p=erp24_rep%2Fyii-erp24%2F.git Добавил свойства type_id и type_guid --- 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 index 00000000..37b98beb --- /dev/null +++ b/erp24/migrations/m250828_065539_add_type_and_type_id_fields_to_write_offs_tables.php @@ -0,0 +1,62 @@ +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 index 00000000..48aad2e8 --- /dev/null +++ b/erp24/migrations/m250828_080450_add_type_and_type_id_fields_to_write_offs_erp_tables.php @@ -0,0 +1,62 @@ +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; + } + */ +} diff --git a/erp24/records/WriteOffs.php b/erp24/records/WriteOffs.php index b214f211..bce6bf17 100755 --- a/erp24/records/WriteOffs.php +++ b/erp24/records/WriteOffs.php @@ -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 типа списания', ]; } diff --git a/erp24/records/WriteOffsErp.php b/erp24/records/WriteOffsErp.php index fc2d2dd0..60b07e96 100644 --- a/erp24/records/WriteOffsErp.php +++ b/erp24/records/WriteOffsErp.php @@ -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',