From 94b568d91b69572ad1be8d1afd3908159c045077 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 3 Sep 2024 10:50:21 +0300 Subject: [PATCH] =?utf8?q?[ERP-140]=20=D0=BF=D0=BE=D0=B4=D1=81=D1=87=D1=91?= =?utf8?q?=D1=82=20=D0=A1=D1=82=D0=BE=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D1=8C?= =?utf8?q?=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=B0=20=D1=84=D0=B0=D0=BA?= =?utf8?q?=D1=82=20=D0=BC=D0=BE=D1=82=D0=B8=D0=B2=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/motivation/TestFactAction.php | 2 ++ .../scripts/tasks/task_32_motivation_fact.php | 2 ++ erp24/services/MotivationService.php | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/erp24/actions/motivation/TestFactAction.php b/erp24/actions/motivation/TestFactAction.php index 4a784f20..3148ebc5 100644 --- a/erp24/actions/motivation/TestFactAction.php +++ b/erp24/actions/motivation/TestFactAction.php @@ -72,6 +72,8 @@ class TestFactAction extends Action MotivationService::calculateMonthCeoAndSaleOfWebsiteGoods($model->year, $model->month); + MotivationService::calculateMonthCostMotivation($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 3d641799..06d21f26 100644 --- a/erp24/scripts/tasks/task_32_motivation_fact.php +++ b/erp24/scripts/tasks/task_32_motivation_fact.php @@ -75,6 +75,8 @@ try { MotivationService::calculateMonthCeoAndSaleOfWebsiteGoods($year, $month); + MotivationService::calculateMonthCostMotivation($year, $month); + MotivationService::initMonth1cFields($year, $month); ////////////////////////////////////////////// diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index f9795b7d..8fdf2b87 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1490,6 +1490,25 @@ class MotivationService } } + public static function calculateMonthCostMotivation($year, $month) { + $monthStart = date("Y-m-d 00:00:00", strtotime("$year-$month-01")); + $monthEnd = date("Y-m-t 23:59:59", strtotime("$year-$month-01")); + + $motivations = Motivation::find() + ->where(['year' => $year, 'month' => $month]) + ->all(); + + foreach ($motivations as $motivation) { + /** @var $motivation Motivation */ + + // Рассчитываем сумму себестоимости за эту неделю + $costSum = self::getSelfCostSumByStore($monthStart, $monthEnd, $motivation->store_id); + + self::saveOrUpdateMotivationValue($motivation->id, + "fact", self::CODE_COSTS_OF_GOODS, "float", $costSum); + } + } + public static function initMonth1cFields($year, $month) { $motivations = Motivation::find() ->where(['year' => $year, 'month' => $month]) -- 2.39.5