From fbd5ae244c3f300a39b1fc1bd49551dd43490a09 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Wed, 4 Sep 2024 15:48:46 +0300 Subject: [PATCH] =?utf8?q?[ERP-140]=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20174?= =?utf8?q?=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index d7a92f17..beeba4af 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1446,11 +1446,11 @@ class MotivationService foreach ($motivations as $motivation) { /** @var $motivation Motivation */ - // Рассчитываем сумму себестоимости за эту неделю + $correction = self::getMotivationValue($motivation->id, 8, self::CODE_COSTS_OF_GOODS); $costSum = self::getSelfCostSumByStore($monthStart, $monthEnd, $motivation->store_id); self::saveOrUpdateMotivationValue($motivation->id, - "fact", self::CODE_COSTS_OF_GOODS, "float", $costSum); + "fact", self::CODE_COSTS_OF_GOODS, "float", $costSum + $correction); } } @@ -1863,7 +1863,7 @@ class MotivationService $exportImportTable = ExportImportTable::find()->select(['export_val'])->where(['entity' => 'city_store', 'entity_id' => $storeId, 'export_id' => 1])->one(); 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', $startDate, $endDate]) ->andWhere(['wo.store_id' => $exportImportTable->export_val]) @@ -1882,8 +1882,9 @@ class MotivationService $sum = 0; foreach($writeOffs as $data) { - $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']; } return $sum; -- 2.39.5