From 4e6bd0fb1bf4f8c1c8fd2dd86ebc53eed9739076 Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 21 Apr 2025 16:03:42 +0300 Subject: [PATCH] =?utf8?q?ERP-359=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D1=82?= =?utf8?q?=D1=8C=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20=D1=80=D0=B0?= =?utf8?q?=D1=81=D1=87=D0=B5=D1=82=D0=B0=20=D0=BD=D0=B0=20=D0=BC=D0=B5?= =?utf8?q?=D1=81=D1=8F=D1=86=20-=20=D1=81=D1=83=D0=BC=D0=BC=D0=B0=20=D0=BF?= =?utf8?q?=D1=80=D0=BE=D0=B4=D0=B0=D0=B6=20=D0=B2=D0=B8=D0=B4=D0=B0=20?= =?utf8?q?=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/AutoPlannogrammaService.php | 13 ++++++++----- erp24/views/auto-plannogramma/calculating.php | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index d40263d8..87b29e6c 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -258,7 +258,7 @@ class AutoPlannogrammaService $query = (new Query()) ->select([ 'store_id' => 'ex.entity_id', - 'species' => 'p1c.species', + 'species' => 'p1c.name', 'category' => 'p1c.category', 'subcategory' => 'p1c.subcategory', 'total_sum' => new Expression( @@ -273,8 +273,8 @@ class AutoPlannogrammaService ->leftJoin('products_1c_nomenclature p1c', 'p1c.id = item ->> \'product_id\'') ->where(['>=', 'w.date', $dateFrom]) ->andWhere(['ex.entity_id' => $storeIds]) - ->andWhere(['<>', 'p1c.species', '']) - ->groupBy(['ex.entity_id', 'p1c.species', 'p1c.category', 'p1c.subcategory']); + ->andWhere(['<>', 'p1c.name', '']) + ->groupBy(['ex.entity_id', 'p1c.name', 'p1c.category', 'p1c.subcategory']); if ($productFilter !== null) { $query->andWhere(['item ->> \'product_id\'' => $productFilter]); @@ -286,8 +286,8 @@ class AutoPlannogrammaService ->leftJoin('export_import_table ex', 'ex.export_val = s.store_id_1c') ->where(['>=', 's.date', $dateFrom]) ->andWhere(['ex.entity_id' => $storeIds]) - ->andWhere(['<>', 'p1c.species', '']) - ->groupBy(['ex.entity_id', 'p1c.species', 'p1c.category', 'p1c.subcategory']); + ->andWhere(['<>', 'p1c.name', '']) + ->groupBy(['ex.entity_id', 'p1c.name', 'p1c.category', 'p1c.subcategory']); if ($productFilter !== null) { $query->andWhere(['sp.product_id' => $productFilter]); @@ -315,6 +315,8 @@ class AutoPlannogrammaService public function getMonthSpeciesGoalDirty(array $speciesShare, array $subcategoryGoals): array { + $storeNamesMap = ArrayHelper::map($this->getVisibleStores(), 'id', 'name'); + $indexedGoals = []; foreach ($subcategoryGoals as $goal) { $indexedGoals[$goal['store_id']][$goal['category']][$goal['subcategory']] = $goal['goal']; @@ -329,6 +331,7 @@ class AutoPlannogrammaService 'subcategory' => $species['subcategory'], 'product_name' => $species['species'], 'store_id' => $species['store_id'], + 'store_name' => $storeNamesMap[$species['store_id']] ?? 'Неизвестный магазин', // Добавляем название магазина 'goal' => round($species['percent_of_month'] * $goal, 2), ]; } diff --git a/erp24/views/auto-plannogramma/calculating.php b/erp24/views/auto-plannogramma/calculating.php index 4139963b..d267d77b 100644 --- a/erp24/views/auto-plannogramma/calculating.php +++ b/erp24/views/auto-plannogramma/calculating.php @@ -100,6 +100,7 @@ use yii_app\records\Products1cNomenclature; 'subcategory', 'product_name', 'store_id', + 'store_name', [ 'attribute' => 'goal', 'label' => 'План закупок (RUB)', -- 2.39.5