From a548e1741619cf24f27d277039b9e5db41e7f273 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Wed, 4 Sep 2024 16:18:35 +0300 Subject: [PATCH] =?utf8?q?[ERP-140]=20=D0=92=20=D1=81=D0=BB=D1=83=D1=87?= =?utf8?q?=D0=B0=D0=B5=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2?= =?utf8?q?=D0=B8=D1=8F=20=D1=81=D0=B5=D0=B1=D0=B5=D1=81=D1=82=D0=BE=D0=B8?= =?utf8?q?=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?utf8?q?=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20summ=20=D0=BE=D1=82=20=D0=BF?= =?utf8?q?=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index beeba4af..848a7a5c 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1279,7 +1279,7 @@ class MotivationService foreach ($exportImportTables as $store_id => $store_guid) { if (isset($motivations[$store_id])) { - $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', $monthStart, $monthEnd]) ->andWhere(['wo.store_id' => $store_guid]) @@ -1299,8 +1299,9 @@ class MotivationService $sum = 0; foreach($writeOffs as $data) { if (($data['type'] ?? '') == $key) { - $sum += ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0) + $value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0) * ($data['quantity'] ?? 0); + $sum += $value > 0 ? $value : ($data['summ'] ?? 0); } } @@ -1884,7 +1885,7 @@ class MotivationService foreach($writeOffs as $data) { $value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0) * ($data['quantity'] ?? 0); - $sum = $value > 0 ? $value : $data['summ']; + $sum += $value > 0 ? $value : ($data['summ'] ?? 0); } return $sum; -- 2.39.5