);
}
}
- if (!empty($waybillWriteOffsErp)) {
+ if (!empty($waybillWriteOffsErp) && isset($arr["held"]) && $arr["held"]) {
/** @var WaybillWriteOffs $waybillWriteOffsErp */
$waybillWriteOffsErp->status = WriteOffsErp::STATUS_CREATED_1С;
- $waybillWriteOffsErp->number_1c = $arr["number"] ?? '';
+ $waybillWriteOffsErp->number_1c = $arr["name"] ?? '';
$waybillWriteOffsErp->save();
if ($waybillWriteOffsErp->getErrors()) {
LogService::apiErrorLog(
'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('Ð\9dазвание документа в 1с'),
+ 'number_1c' => $this->string(100)->null()->comment('Ð\9dомеÑ\80 документа в 1с'),
'date' => $this->dateTime()->notNull()->comment('Дата документа'),
'comment' => $this->text()->null()->comment('Комментарий'),
'quantity' => $this->float()->notNull()->comment('Количество'),
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241220_084001_add_name_1c_to_waybill_write_offs
+ */
+class m241220_084001_add_name_1c_to_waybill_write_offs extends Migration
+{
+ const TABLE_NAME = 'erp24.waybill_write_offs';
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+ if ($tableSchema !== null && !isset($tableSchema->columns['name_1c'])) {
+ $this->addColumn(
+ self::TABLE_NAME,
+ 'name_1c',
+ $this->string(255)
+ ->null()
+ ->comment('Название документа в 1с')
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+ if ($tableSchema !== null && isset($tableSchema->columns['name_1c'])) {
+ $this->dropColumn(self::TABLE_NAME, 'name_1c');
+ }
+ }
+
+ /*
+ // Use up()/down() to run migration code without a transaction.
+ public function up()
+ {
+
+ }
+
+ public function down()
+ {
+ echo "m241220_084001_add_name_1c_to_waybill_write_offs cannot be reverted.\n";
+
+ return false;
+ }
+ */
+}
* @property int $store_id id магазина в ERP
* @property string $store_guid GUID магазина из 1с
* @property string $number Название документа
- * @property string|null $number_1c Название документа в 1с
+ * @property string|null $number_1c Номер документа в 1с
+ * @property string|null $name_1c Название документа в 1с
* @property string $date Дата документа
* @property string|null $comment Комментарий
* @property float $quantity Количество
[['shift_transfer_id', 'status', 'created_admin_id', 'updated_admin_id', 'store_id'], 'default', 'value' => null],
[['shift_transfer_id', 'status', 'created_admin_id', 'updated_admin_id', 'store_id'], 'integer'],
[['date', 'created_at', 'updated_at', 'send_at'], 'safe'],
- [['comment', 'error_text'], 'string'],
+ [['comment', 'error_text', 'name_1c'], 'string'],
[['quantity', 'summ', 'summ_self_cost'], 'number'],
[['guid', 'store_guid', 'number', 'number_1c'], 'string', 'max' => 100],
[['guid'], 'unique'],
'store_id' => 'id магазина в ERP',
'store_guid' => 'GUID магазина из 1с',
'number' => 'Название документа',
- 'number_1c' => 'Название документа в 1с',
+ 'number_1c' => 'Номер документа в 1с',
+ 'name_1c' => 'Название документа в 1с',
'date' => 'Дата документа',
'comment' => 'Комментарий',
'quantity' => 'Количество',
WaybillWriteOffsProducts::setData($model, $shiftTransfer);
- if (!WaybillWriteOffsProducts::find()
+ if (
+ !WaybillWriteOffsProducts::find()
->andWhere(['waybill_write_offs_id' => $model->id])
- ->exists()) {
+ ->exists()
+ ) {
$model->delete();
return;
}
'summ_self_cost' => $summaries['total_summ_self_cost']
]);
}
-
} catch (\Exception $exception) {
throw new \Exception($exception);
}
'id',
'guid',
'number',
- 'date',
+ [
+ 'label' => 'Дата документа',
+ 'attribute' => 'date',
+ 'value' => function ($model) {
+ return date('d-m-Y H:i:s', strtotime($model->date));
+ }
+ ],
[
'label' => 'Магазин',
'attribute' => 'store_id',
'label' => 'Текст ошибки',
'attribute' => 'error_text',
'value' => function ($model) {
- return $model->status == 8 ? $model->error_text : '';
- }
+ return $model->status == \yii_app\records\WriteOffsErp::STATUS_ERROR_1С ? $model->error_text : '';
+ },
+ 'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_ERROR_1С,
+ ],
+ [
+ 'label' => 'Название документа в 1С',
+ 'attribute' => 'name_1c',
+ 'value' => function ($model) {
+ return
+ $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С ?
+ $model->name_1c : '';
+ },
+ 'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С,
],
[
'label' => 'Номер документа в 1С',
return
$model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С ?
$model->number_1c : '';
- }
+ },
+ 'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С && isset($model->number_1c),
],
[
'label' => 'Отправлено в 1С',
'attribute' => 'send_at',
+ 'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_SEND,
+ 'value' => function ($model) {
+ return date('d-m-Y H:i:s', strtotime($model->send_at));
+ }
],
[
'label' => 'Создан пользователем',
return Admin::findOne([$model->created_admin_id])->name;
}
],
-
- 'created_at',
- 'updated_at',
+ [
+ 'label' => 'Дата создания',
+ 'attribute' => 'created_at',
+ 'value' => function ($model) {
+ return date('d-m-Y H:i:s', strtotime($model->created_at));
+ }
+ ],
+ [
+ 'label' => 'Дата обновления',
+ 'attribute' => 'updated_at',
+ 'value' => function ($model) {
+ return $model->updated_at ? date('d-m-Y H:i:s', strtotime($model->updated_at)) : '';
+ }
+ ],
],
]) ?>