]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-130] В случае отсутствия себестоимости записываем summ от продукта
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 4 Sep 2024 13:20:42 +0000 (16:20 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 4 Sep 2024 13:20:42 +0000 (16:20 +0300)
erp24/services/MotivationService.php

index 5186306a9f39a4d4158191be7810e18a268163a7..9abba21656327d33a693142695d5d60583141f1b 100644 (file)
@@ -459,7 +459,7 @@ class MotivationService
             }
 
             if ($exportImportTable) {
-                $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity'])
+                $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.summ'])
                     ->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
                     ->where(['between', 'wo.date', $weekStart, $weekEnd])
                     ->andWhere(['wo.store_id' => $exportImportTable->export_val])
@@ -481,7 +481,8 @@ class MotivationService
                         if (($data['type'] ?? '') != $key) {
                             continue;
                         }
-                        $sum += ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0) * ($data['quantity'] ?? 0);
+                        $value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0) * ($data['quantity'] ?? 0);
+                        $sum += $value > 0 ? $value : ($data['summ'] ?? 0);
                     }
 
                     $motivationItemType = MotivationCostsItem::writeOffsToMotivationItemMap($key);