]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавляем актуальность в расчет
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 20 Aug 2025 13:34:49 +0000 (16:34 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 20 Aug 2025 13:34:49 +0000 (16:34 +0300)
erp24/services/AutoPlannogrammaService.php

index 39751ab9de856b62dfef51cd3f45fdea656f61d4..e5a6c946adc68b4459d934b3da2a75bcb9ec70c9 100644 (file)
@@ -17,6 +17,7 @@ use yii_app\records\CityStoreParams;
 use yii_app\records\ExportImportTable;
 use yii_app\records\MatrixBouquetForecast;
 use yii_app\records\Products1c;
+use yii_app\records\Products1cNomenclatureActuality;
 use yii_app\records\Sales;
 use yii_app\records\SalesProducts;
 use yii_app\records\SalesWriteOffsPlan;
@@ -3050,6 +3051,17 @@ class AutoPlannogrammaService
         );
 
         $date = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01';
+        $df = (new \DateTime($date))
+            ->setTime(0, 0, 0)->format('Y-m-d H:i:s');
+        $dt = (new \DateTime($date))
+            ->modify('last day of this month')->setTime(23, 59, 59)
+            ->format('Y-m-d H:i:s');
+        $actualProducts = Products1cNomenclatureActuality::find()
+            ->select(['guid'])
+            ->where(['<=', 'date_from', $df])
+            ->andWhere(['>=', 'date_to', $dt])
+            ->asArray()
+            ->column();
 
         $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrixGroups);
         $weekShares = $this->getHistoricalSpeciesShareByWeek($date);
@@ -3124,6 +3136,9 @@ class AutoPlannogrammaService
         foreach ($weeklyForecasts as $item) {
             $storeItem = (int)$item['store_id'];
             $guid = (string)$item['product_guid'];
+            if (!in_array($guid, $actualProducts)) {
+               continue;
+            }
             $group = (string)$item['matrix_group'];
             $type = (string)$item['type'];
             $forecastValue = (float)$item['week_forecast'];