]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление года в метод для расчета истории
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 10 Apr 2025 06:37:45 +0000 (09:37 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 10 Apr 2025 06:37:45 +0000 (09:37 +0300)
erp24/controllers/CategoryPlanController.php
erp24/services/StorePlanService.php

index 3d35ec862e194db3b49bfaff8958c08b0285706d..5e9cad1f1f814b4a5cc3cb0f94886bcd89105585 100644 (file)
@@ -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,
index 76c6f5c3a8b0da74b8bf3ba1ca169d76b3e12112..10bdd8e29af713992822b0e6900b6064ff0192a0 100755 (executable)
@@ -445,6 +445,7 @@ class StorePlanService
      *
      * @param int    $storeId                Идентификатор магазина.
      * @param string $selectedMonth          Выбранный месяц в формате "mm" (целевой месяц).
+     * @param string $selectedYear Год в формате "YYYY".
      * @param array  $productsWithoutHistory Массив товаров без истории, где каждый элемент имеет вид:
      *           [
      *              'guid' => <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;