--- /dev/null
+<?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|null $shift_transfer_id ID записи передачи смены
+ * @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 $date Дата документа
+ * @property string|null $comment Комментарий
+ * @property float $quantity Количество
+ * @property float $summ Сумма розничная
+ * @property float|null $summ_self_cost Сумма себестоимости
+ * @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 Удален пользователем
+ *
+ * @property ShiftTransfer $shiftTransfer
+ * @property WaybillWriteOffsProducts[] $waybillWriteOffsProducts
+ */
+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', 'date', 'quantity', 'summ', 'created_at'], 'required'],
+ [['shift_transfer_id', 'status', 'created_admin_id', 'updated_admin_id', 'confirm_admin_id', 'store_id', 'active', 'deleted_admin_id'], 'default', 'value' => null],
+ [['shift_transfer_id', '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_self_cost'], 'number'],
+ [['guid', 'store_guid', 'number', 'number_1c', 'confirm_at'], 'string', 'max' => 100],
+ [['guid'], 'unique'],
+ [['shift_transfer_id'], 'exist', 'skipOnError' => true, 'targetClass' => ShiftTransfer::class, 'targetAttribute' => ['shift_transfer_id' => 'id']],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'guid' => 'GUID документа для 1c',
+ 'shift_transfer_id' => 'ID записи передачи смены',
+ 'status' => 'Статус документа',
+ 'created_admin_id' => 'Создан пользователем',
+ 'updated_admin_id' => 'Изменён пользователем',
+ 'confirm_admin_id' => 'Подтвержден пользователем',
+ 'store_id' => 'id магазина в ERP',
+ 'store_guid' => 'GUID магазина из 1с',
+ 'number' => 'Название документа',
+ 'number_1c' => 'Название документа в 1с',
+ 'date' => 'Дата документа',
+ 'comment' => 'Комментарий',
+ 'quantity' => 'Количество',
+ 'summ' => 'Сумма розничная',
+ 'summ_self_cost' => 'Сумма себестоимости',
+ 'created_at' => 'Дата создания',
+ 'updated_at' => 'Дата обновления',
+ 'deleted_at' => 'Дата удаление',
+ 'confirm_at' => 'Дата подтверждения',
+ 'send_at' => 'Дата отправления в 1с',
+ 'active' => 'Активность',
+ 'deleted_admin_id' => 'Удален пользователем',
+ ];
+ }
+
+ /**
+ * Gets query for [[ShiftTransfer]].
+ *
+ * @return \yii\db\ActiveQuery
+ */
+ public function getShiftTransfer()
+ {
+ return $this->hasOne(ShiftTransfer::class, ['id' => 'shift_transfer_id']);
+ }
+
+ /**
+ * Gets query for [[WaybillWriteOffsProducts]].
+ *
+ * @return \yii\db\ActiveQuery
+ */
+ public function getWaybillWriteOffsProducts()
+ {
+ return $this->hasMany(WaybillWriteOffsProducts::class, ['waybill_write_offs_id' => 'id']);
+ }
+}
--- /dev/null
+<?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|null $product_id ID товара с недостатком
+ * @property float|null $product_count Количество товара с недостатком
+ * @property float|null $product_price Цена товара розничная
+ * @property float|null $product_self_cost Себестоимость товара
+ * @property float $summ Сумма розничная
+ * @property float|null $summ_self_cost Сумма себестоимости
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ *
+ * @property WaybillWriteOffs $waybillWriteOffs
+ */
+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', 'summ', 'created_at'], 'required'],
+ [['waybill_write_offs_id'], 'default', 'value' => null],
+ [['waybill_write_offs_id'], 'integer'],
+ [['product_count', 'product_price', 'product_self_cost', 'summ', 'summ_self_cost'], 'number'],
+ [['created_at', 'updated_at'], 'safe'],
+ [['name'], 'string', 'max' => 100],
+ [['product_id'], 'string', 'max' => 255],
+ [['waybill_write_offs_id'], 'exist', 'skipOnError' => true, 'targetClass' => WaybillWriteOffs::class, 'targetAttribute' => ['waybill_write_offs_id' => 'id']],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'waybill_write_offs_id' => 'GUID документа из таблицы waybill_write_offs',
+ 'name' => 'Название товара',
+ 'product_id' => 'ID товара с недостатком',
+ 'product_count' => 'Количество товара с недостатком',
+ 'product_price' => 'Цена товара розничная',
+ 'product_self_cost' => 'Себестоимость товара',
+ 'summ' => 'Сумма розничная',
+ 'summ_self_cost' => 'Сумма себестоимости',
+ 'created_at' => 'Дата создания',
+ 'updated_at' => 'Дата обновления',
+ ];
+ }
+
+ /**
+ * Gets query for [[WaybillWriteOffs]].
+ *
+ * @return \yii\db\ActiveQuery
+ */
+ public function getWaybillWriteOffs()
+ {
+ return $this->hasOne(WaybillWriteOffs::class, ['id' => 'waybill_write_offs_id']);
+ }
+}