]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-130] Принудительное обнуление ячеек для которых нет данных
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 23 Aug 2024 14:51:46 +0000 (17:51 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 23 Aug 2024 14:51:46 +0000 (17:51 +0300)
erp24/records/MotivationCostsItem.php
erp24/services/MotivationService.php

index 1f9de0bee65e93b06f5d8d14dfbb8cdfe54c111d..e678dbcd3e26fcc9804d861346c55b4d3145d189 100644 (file)
@@ -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}
      */
index 0ada3d5e52587793fd22291d954eac4179dee154..a9854aeae995b20acd7fdde6a0f422b7c3b8c8a2 100644 (file)
@@ -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()));