From ae6faae0f704e6b9d703028584fee2610bb8dfb1 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Wed, 20 Aug 2025 17:50:58 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5?= =?utf8?q?=D0=BC=20=D0=B0=D0=BA=D1=82=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= =?utf8?q?=D1=81=D1=82=D1=8C=20=D0=B2=20=D1=80=D0=B0=D1=81=D1=87=D0=B5?= =?utf8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/AutoPlannogrammaService.php | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index 1b59010a..8bf20434 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -1328,10 +1328,22 @@ private function buildCategoryGoals(array $rawGoals, bool $subtractMatrix, int $ public function calculateWeeklyProductForecastPieces( array $productForecastSpecies, - array $weeklySales + array $weeklySales, + array $filters ): array { - + $date = $filters['year'] . '-' . str_pad($filters['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(); $forecastMap = []; foreach ($productForecastSpecies as $item) { $sid = $item['store_id']; @@ -1369,7 +1381,9 @@ private function buildCategoryGoals(array $rawGoals, bool $subtractMatrix, int $ foreach ($productsInSpec as $pid => $piecesMon) { $forecastWeekPieces = round($piecesMon * $wShare, 2); - + if (!in_array($pid, $actualProducts)) { + continue; + } $result[] = [ 'week' => $week, 'store_id' => $sid, @@ -2509,7 +2523,7 @@ private function buildCategoryGoals(array $rawGoals, bool $subtractMatrix, int $ $weeklySales = $this->getHistoricalSpeciesShareByWeek($filters['plan_date'], $filters); - $weeklySalesForecast = $this->calculateWeeklyProductForecastPieces($productForecastSpecies, $weeklySales); + $weeklySalesForecast = $this->calculateWeeklyProductForecastPieces($productForecastSpecies, $weeklySales, $filters); return $weeklySalesForecast; } @@ -3253,11 +3267,10 @@ private function buildCategoryGoals(array $rawGoals, bool $subtractMatrix, int $ $baseGroup = $groupsArr[0]; $storeItem = (int)$item['store_id']; $guid = (string)$item['product_guid']; - $group = $baseGroup; if (!in_array($guid, $actualProducts)) { - continue; + continue; } - $group = (string)$item['matrix_group']; + $group = $baseGroup; $type = (string)$item['type']; $forecastValue = (float)$item['week_forecast']; if (isset($salesShares[$storeItem]) && isset($salesShares[$storeItem][$type])) { -- 2.39.5