From c5ad5f5744e5a6504d2b251fd7d352edeb3c394a Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 16:42:42 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/AutoPlannogrammaService.php | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index c71df1bb..101ce93e 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -2857,18 +2857,41 @@ class AutoPlannogrammaService } $grouped = []; + $grouped = []; + $salesShares = []; + + $plans = SalesWriteOffsPlan::find() + ->where(['month' => $month, 'year' => $year]) + ->indexBy('store_id') + ->asArray() + ->all(); + if ($plans) { + foreach ($plans as $storeId => $plan) { + $total = $plan['total_sales_plan']; + $offline = $plan['offline_sales_plan']; + $online = $plan['online_sales_shop_plan']; + $market = $plan['online_sales_marketplace_plan']; + $salesShares[$storeId]['offline'] = round($offline / $total, 4); + $salesShares[$storeId]['online'] = round($online / $total, 4); + $salesShares[$storeId]['marketplace'] = round($market / $total, 4); + } + } + foreach ($weeklyForecasts as $item) { $storeItem = (int)$item['store_id']; $guid = (string)$item['product_guid']; $group = (string)$item['matrix_group']; $type = (string)$item['type']; $forecastValue = (float)$item['week_forecast']; - + if (isset($salesShares[$storeItem]) && isset($salesShares[$storeItem][$type])) { + $grouped[$storeItem][$type]['share'] = $salesShares[$storeItem][$type]; + } $grouped[$storeItem][$guid][$type][$group] = $forecastValue; } return $grouped; } + public function getWeeklyProductsWriteoffsForecast($month, $year, $storeId = null, $weekNumber = null) { $weeksProductForecast = []; -- 2.39.5