From: marina Date: Mon, 21 Apr 2025 13:03:42 +0000 (+0300) Subject: ERP-359 Создать логику расчета на месяц - сумма продаж вида для автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=4e6bd0fb1bf4f8c1c8fd2dd86ebc53eed9739076;p=erp24_rep%2Fyii-erp24%2F.git ERP-359 Создать логику расчета на месяц - сумма продаж вида для автопм --- 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)',