]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-140] подсчёт Расходные материалы (обеспечение продаж) факт мотивации
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 3 Sep 2024 08:05:51 +0000 (11:05 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 3 Sep 2024 08:05:51 +0000 (11:05 +0300)
erp24/actions/motivation/TestFactAction.php
erp24/scripts/tasks/task_32_motivation_fact.php
erp24/services/MotivationService.php

index 3148ebc5b7bda861635df528399967cebbfed54f..da921ee678bd8513aaeb748202350b59ea3fbd0b 100644 (file)
@@ -74,6 +74,8 @@ class TestFactAction extends Action
 
             MotivationService::calculateMonthCostMotivation($model->year, $model->month);
 
+            MotivationService::calculateMonthMaterials($model->year, $model->month);
+
             MotivationService::initMonth1cFields($model->year, $model->month);
         }
 
index 06d21f26698a4b50e7d41ef805dde80ff181a6be..f5de4bbbc5b4e48d8039722f4e7292811a33e6ed 100644 (file)
@@ -77,6 +77,8 @@ try {
 
         MotivationService::calculateMonthCostMotivation($year, $month);
 
+        MotivationService::calculateMonthMaterials($year, $month);
+
         MotivationService::initMonth1cFields($year, $month);
         //////////////////////////////////////////////
 
index 8fdf2b87b6217ce5a9e2b055b910b2c3e133b214..b13d9cb3a691b6c0f391b4cd7b3a0c9604981486 100644 (file)
@@ -1509,6 +1509,18 @@ class MotivationService
         }
     }
 
+    public static function calculateMonthMaterials($year, $month) {
+        $motivations = Motivation::find()
+            ->where(['year' => $year, 'month' => $month])
+            ->all();
+
+        foreach ($motivations as $motivation) {
+            $materials = self::getMotivationValue($motivation->id, 10, self::CODE_CONSUMABLES_SALES_SUPPORT);
+            self::saveOrUpdateMotivationValue($motivation->id,
+                "fact", self::CODE_CONSUMABLES_SALES_SUPPORT, "float", $materials);
+        }
+    }
+
     public static function initMonth1cFields($year, $month) {
         $motivations = Motivation::find()
             ->where(['year' => $year, 'month' => $month])