From: Alexander Smirnov Date: Wed, 4 Sep 2024 12:48:46 +0000 (+0300) Subject: [ERP-140] после 174ой X-Git-Tag: 1.4~5^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=fbd5ae244c3f300a39b1fc1bd49551dd43490a09;p=erp24_rep%2Fyii-erp24%2F.git [ERP-140] после 174ой --- 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;