From: marina Date: Tue, 17 Jun 2025 13:42:42 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c5ad5f5744e5a6504d2b251fd7d352edeb3c394a;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- 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 = [];