]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Возвращаем константу и исправление ошибок
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Jun 2025 14:08:08 +0000 (17:08 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Jun 2025 14:08:08 +0000 (17:08 +0300)
erp24/controllers/AutoPlannogrammaController.php
erp24/services/AutoPlannogrammaService.php

index a56c5301a772591c06c6c950faeacb052da5912c..2bfec0d8e8cb85d71c99145c0cc0ef3201317235 100644 (file)
@@ -1444,7 +1444,7 @@ class AutoPlannogrammaController extends BaseController
                 [$monthSpeciesGoal['species']] = $monthSpeciesGoal['goal'] ;
             }
 
-            $weeksShareResult = $service->getHistoricalWeeklySpeciesShare($filters['plan_date'], $filters, null, 'writeOffs');
+            $weeksShareResult = $service->getHistoricalWeeklySpeciesShare($model->month, $filters, null, 'writeOffs');
             $weeksData = $service->calculateWeeklySpeciesGoals($weeksShareResult['weeksData'], $monthSpeciesGoals) ;
 
             $datePlan = $filters['plan_date'];
@@ -1646,7 +1646,7 @@ class AutoPlannogrammaController extends BaseController
             }
 
 
-            $weeksShareResult = $service->getHistoricalWeeklySpeciesShare($filters['plan_date'], $filters, null, 'writeOffs');
+            $weeksShareResult = $service->getHistoricalWeeklySpeciesShare($model->month, $filters, null, 'writeOffs');
             $weeksData = $service->calculateWeeklySpeciesGoals($weeksShareResult, $monthSpeciesGoals) ;
 
             $datePlan = $filters['plan_date'];
index 95abe7c97a38c3d101c8807c4ffefdccffdb6d93..829b2b3ea977c5f9b0df2787e54cf6b6be1d97b8 100644 (file)
@@ -29,7 +29,7 @@ class AutoPlannogrammaService
     public const TYPE_WRITE_OFFS = 'writeOffs'; // Тип операции: списания
     private const CATEGORY_LOOKBACK_MONTHS = 3; // Период для анализа категорий (месяцы)
     private const LOOKBACK_MONTHS = 2; // Отступаемый шаг от плановой даты перед расчетами
-    private const HELIUM_GUID = '2b72702a-792f-11e8-9edd-1c6f659fb563';
+    public const HELIUM_GUID = '2b72702a-792f-11e8-9edd-1c6f659fb563';
 
     /**
      * Получение списка видимых магазинов
@@ -1302,7 +1302,7 @@ class AutoPlannogrammaService
         ?array $productFilter = null,
         string $type = 'sales'
     ): array {
-        [$yearStr, $monthStr, $day] = explode('-', $monthYear);
+        [$monthStr, $yearStr] = explode('-', $monthYear);
         $month = (int)$monthStr;
         $year  = (int)$yearStr;
         $yearData = [];
@@ -2110,6 +2110,8 @@ class AutoPlannogrammaService
         $priceDynamics = PricesDynamic::find()
             ->andWhere(['region_id' => $region])
             ->andWhere(['product_id' => array_values(ArrayHelper::getColumn($nomenclatures, 'id'))])
+            ->andWhere(['<=', 'date_from', $monthEnd])
+            ->andWhere(['>=', 'date_to',   $monthStart])
             ->orderBy(['date_from' => SORT_DESC])
             ->all();
 
@@ -2750,7 +2752,7 @@ class AutoPlannogrammaService
             if (isset($heliumGuid) && $productId === $heliumGuid) {
                 if ($multiRegion) {
                     if (!isset($pricesMap[$productId][$regionId])) {
-                        $pricesMap[$productId][$regionId] = [$price];
+                        $pricesMap[$productId][$regionId] = $price;
                     } else {
                         $pricesMap[$productId][$regionId] = min(
                             $pricesMap[$productId][$regionId],
@@ -2759,7 +2761,7 @@ class AutoPlannogrammaService
                     }
                 } else {
                     if (!isset($pricesMap[$productId])) {
-                        $pricesMap[$productId] = [$price];
+                        $pricesMap[$productId] = $price;
                     } else {
                         $pricesMap[$productId] = min(
                             $pricesMap[$productId],