]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
правки для расчета расходных материалов consumable_fixes origin/consumable_fixes
authormarina <m.zozirova@gmail.com>
Wed, 9 Oct 2024 08:04:53 +0000 (11:04 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 9 Oct 2024 08:04:53 +0000 (11:04 +0300)
erp24/services/MotivationService.php

index a3058570965d79458eba34aded29faf20e360b2e..f60a36ca7371ffe97a44a23ec1d54b2d92eed2a9 100644 (file)
@@ -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) {