From: Alexander Smirnov Date: Tue, 3 Sep 2024 08:05:51 +0000 (+0300) Subject: [ERP-140] подсчёт Расходные материалы (обеспечение продаж) факт мотивации X-Git-Tag: 1.4~5^2~12 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=068500ce936f02c99b01bac3ccfb7e7ce5ea8d20;p=erp24_rep%2Fyii-erp24%2F.git [ERP-140] подсчёт Расходные материалы (обеспечение продаж) факт мотивации --- diff --git a/erp24/actions/motivation/TestFactAction.php b/erp24/actions/motivation/TestFactAction.php index 3148ebc5..da921ee6 100644 --- a/erp24/actions/motivation/TestFactAction.php +++ b/erp24/actions/motivation/TestFactAction.php @@ -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); } diff --git a/erp24/scripts/tasks/task_32_motivation_fact.php b/erp24/scripts/tasks/task_32_motivation_fact.php index 06d21f26..f5de4bbb 100644 --- a/erp24/scripts/tasks/task_32_motivation_fact.php +++ b/erp24/scripts/tasks/task_32_motivation_fact.php @@ -77,6 +77,8 @@ try { MotivationService::calculateMonthCostMotivation($year, $month); + MotivationService::calculateMonthMaterials($year, $month); + MotivationService::initMonth1cFields($year, $month); ////////////////////////////////////////////// diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 8fdf2b87..b13d9cb3 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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])