From: Vladimir Fomichev Date: Wed, 20 Aug 2025 13:34:49 +0000 (+0300) Subject: Добавляем актуальность в расчет X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3d0f7cf150fcaecf9fe421a76569a790323eea79;p=erp24_rep%2Fyii-erp24%2F.git Добавляем актуальность в расчет --- diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index 39751ab9..e5a6c946 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -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'];