From: fomichev Date: Thu, 10 Apr 2025 06:37:45 +0000 (+0300) Subject: Добавление года в метод для расчета истории X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ff7c7296571340839e399711056d68d58c36f90f;p=erp24_rep%2Fyii-erp24%2F.git Добавление года в метод для расчета истории --- diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 3d35ec86..5e9cad1f 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -351,14 +351,14 @@ class CategoryPlanController extends Controller { $subcategory, $species ); - //var_dump($result); die(); + $weightedResults = StorePlanService::calculateWeightedSalesForProductsWithoutHistory( $storeId, $selectedMonth, + $selectedYear, $result['without_history'] ); - $productSalesShare = StorePlanService::calculateProductSalesShare( $storeId, $selectedMonth, diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 76c6f5c3..10bdd8e2 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -445,6 +445,7 @@ class StorePlanService * * @param int $storeId Идентификатор магазина. * @param string $selectedMonth Выбранный месяц в формате "mm" (целевой месяц). + * @param string $selectedYear Год в формате "YYYY". * @param array $productsWithoutHistory Массив товаров без истории, где каждый элемент имеет вид: * [ * 'guid' => , @@ -453,9 +454,9 @@ class StorePlanService * * @return array Возвращает массив, где ключ – GUID товара, а значение – рассчитанное взвешенное значение продаж. */ - public static function calculateWeightedSalesForProductsWithoutHistory($storeId, $selectedMonth, $productsWithoutHistory) + public static function calculateWeightedSalesForProductsWithoutHistory($storeId, $selectedMonth, $selectedYear, $productsWithoutHistory) { - $targetDate = strtotime(date('Y') . "-$selectedMonth-01"); + $targetDate = strtotime("{$selectedYear}-{$selectedMonth}-01"); $periods = self::getPeriods($targetDate, 3); $weightedResults = []; @@ -680,7 +681,7 @@ class StorePlanService { $targetDate = strtotime(date('Y') . "-$selectedMonth-01"); - $weightedPeriods = self::getPeriods($targetDate, 3, false,true); + $weightedPeriods = self::getPeriods($targetDate, 3, false, true); $productsData = []; $globalTotal = 0;