From: marina Date: Wed, 9 Oct 2024 08:04:53 +0000 (+0300) Subject: правки для расчета расходных материалов X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=refs%2Fremotes%2Forigin%2Fconsumable_fixes;p=erp24_rep%2Fyii-erp24%2F.git правки для расчета расходных материалов --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index a3058570..f60a36ca 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -240,6 +240,7 @@ class MotivationService // Подстановка значений расходных материалов //190 - порядок для расходных материалов $consumable = self::getConsumable($motivation->id); + $result[190]['week1'] = $consumable['week1']; $result[190]['week2'] = $consumable['week2']; $result[190]['week3'] = $consumable['week3']; $result[190]['week4'] = $consumable['week4']; @@ -2085,10 +2086,18 @@ class MotivationService } } + + $subQuery = (new \yii\db\Query()) + ->select('MAX(id)') + ->from('motivation_value') + ->where(['motivation_id' => $motivationId, 'value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT]) + ->groupBy('motivation_group_id'); + $motivationValues = MotivationValue::find() - ->andWhere(['motivation_id' => $motivationId]) - ->andWhere(['value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT]) - ->select('motivation_group_id, value_float') + ->select(['motivation_group_id', 'value_float']) + ->where(['motivation_id' => $motivationId, 'value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT]) + ->andWhere(['id' => $subQuery]) + ->orderBy(['motivation_group_id' => SORT_DESC]) ->all(); foreach ($motivationValues as $value) {