From: Alexander Smirnov Date: Fri, 23 Aug 2024 14:51:46 +0000 (+0300) Subject: [ERP-130] Принудительное обнуление ячеек для которых нет данных X-Git-Tag: 1.4~11^2~32 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ff15ab7b73cea25755fb4c7b11f5f42530fbca5d;p=erp24_rep%2Fyii-erp24%2F.git [ERP-130] Принудительное обнуление ячеек для которых нет данных --- 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()));