From: Alexander Smirnov Date: Wed, 4 Sep 2024 13:20:42 +0000 (+0300) Subject: [ERP-130] В случае отсутствия себестоимости записываем summ от продукта X-Git-Tag: 1.4~6^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=33ea489e4bc734b799e326baa087ccdbc3848cbc;p=erp24_rep%2Fyii-erp24%2F.git [ERP-130] В случае отсутствия себестоимости записываем summ от продукта --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 5186306a..9abba216 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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);