From ff15ab7b73cea25755fb4c7b11f5f42530fbca5d Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Fri, 23 Aug 2024 17:51:46 +0300 Subject: [PATCH] =?utf8?q?[ERP-130]=20=D0=9F=D1=80=D0=B8=D0=BD=D1=83=D0=B4?= =?utf8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=BE=D0=B1?= =?utf8?q?=D0=BD=D1=83=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=8F=D1=87=D0=B5?= =?utf8?q?=D0=B5=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=82=D0=BE?= =?utf8?q?=D1=80=D1=8B=D1=85=20=D0=BD=D0=B5=D1=82=20=D0=B4=D0=B0=D0=BD?= =?utf8?q?=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/records/MotivationCostsItem.php | 9 +++++++++ erp24/services/MotivationService.php | 8 +++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/erp24/records/MotivationCostsItem.php b/erp24/records/MotivationCostsItem.php index 1f9de0be..e678dbcd 100644 --- a/erp24/records/MotivationCostsItem.php +++ b/erp24/records/MotivationCostsItem.php @@ -39,6 +39,15 @@ class MotivationCostsItem extends ActiveRecord } } + public static function getWriteOffsItems() { + return [ + WriteOffsErp::WRITE_OFFS_TYPE_BRAK, + WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK, + WriteOffsErp::WRITE_OFFS_TYPE_DUE_TO_EQUIPMENT_FAILURE_BRAK, + WriteOffsErp::WRITE_OFFS_TYPE_RESORTING_DOES_NOT_COUNT_TOWARDS_COST, + ]; + } + /** * {@inheritdoc} */ diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 0ada3d5e..a9854aea 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -363,11 +363,9 @@ class MotivationService ->indexBy('type') ->asArray()->all(); - foreach ($writeOffs as $key => $data) { + foreach (MotivationCostsItem::getWriteOffsItems() as $key) { + $data = $writeOffs[$key] ?? []; $motivationItemType = MotivationCostsItem::writeOffsToMotivationItemMap($key); - if (empty($motivationItemType)) { - continue; - } $motivationCostsItem = MotivationCostsItem::find()->where(['name' => $motivationItemType])->one(); /** @var $motivationCostsItem MotivationCostsItem */ if ($motivation) { @@ -380,7 +378,7 @@ class MotivationService $motivationValue->value_id = $motivationCostsItem->code; $motivationValue->value_type = $motivationCostsItem->data_type; } - $motivationValue->value_float = $data['total']; + $motivationValue->value_float = $data['total'] ?? 0; $motivationValue->save(); if ($motivationValue->getErrors()) { throw new \Exception(Json::encode($motivationValue->getErrors())); -- 2.39.5