]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Правки расчета
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 22 Jul 2025 12:34:26 +0000 (15:34 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 22 Jul 2025 12:34:26 +0000 (15:34 +0300)
erp24/commands/CronController.php
erp24/services/AutoPlannogrammaService.php

index fe68d7f7bccdee463166c1e180023610a03d1f61..0b8365435525369d057d2cee34a6cf409ea795d7 100644 (file)
@@ -1648,6 +1648,8 @@ class CronController extends Controller
                         $writeOffs = $writeOffsForecast[$productId][$week]['writeOffs'];
                         $details['writeOffs']['quantity'] = $writeOffs;
                         $total += is_array($writeOffs) ? array_sum($writeOffs) : (float)$writeOffs;
+                    } else {
+                        $details['writeOffs']['quantity'] = 0;
                     }
 
                     foreach (['offline', 'online', 'marketplace'] as $type) {
index 6d60b52420685277b82de16edd8f133e41d9ffb5..052b814b45e5ea4c3c47a6c6bb41e828142ae76d 100644 (file)
@@ -1467,8 +1467,8 @@ class AutoPlannogrammaService
                 'category' => $cat,
                 'subcategory' => $sub,
                 'species' => $spec,
-                'percent' => $percent,
-                'monthly_goal' => $monthlyGoal,
+                'percent' => $percent ?? 0,
+                'monthly_goal' => $monthlyGoal ?? 0,
                 'weekly_goal' => $weeklyGoal,
             ];
         }
@@ -2143,7 +2143,7 @@ class AutoPlannogrammaService
             $guid = $componentDataRecord['component_guid'];
             $nomenclatureData = $nomenclatures[$guid] ?? null;
             $productId = $nomenclatureData?->id;
-            $price = 0;
+            $price = null;
             $dailyPrices = [];
             foreach ($pricesByProduct[$productId] ?? [] as $priceRecordForProduct) {
                 if (defined($heliumConstant) && $productId == constant($heliumConstant)) {
@@ -2162,7 +2162,8 @@ class AutoPlannogrammaService
             }
             if (!empty($dailyPrices)) {
                 $price = min($dailyPrices);
-            } else {
+            }
+            if ($price === null) {
                 $price = 0.0;
             }
             $cost = $componentDataRecord['quantity'] * $price * $componentDataRecord['quantity_product'];
@@ -3017,16 +3018,19 @@ class AutoPlannogrammaService
                 $salesShares[$storeId]['marketplace'] = round($market / $total, 4);
             }
         }
+
         foreach ($weeklyForecasts as $item) {
+            $groupsArr = explode('_', (string)$item['matrix_group']);
+            $baseGroup = $groupsArr[0];
             $storeItem = (int)$item['store_id'];
             $guid = (string)$item['product_guid'];
-            $group = (string)$item['matrix_group'];
+            $group = $baseGroup;
             $type = (string)$item['type'];
             $forecastValue = (float)$item['week_forecast'];
             if (isset($salesShares[$storeItem]) && isset($salesShares[$storeItem][$type])) {
                 $grouped[$storeItem][$type]['share'] = $salesShares[$storeItem][$type];
             }
-            $grouped[$storeItem][$guid][$type][$group] = $forecastValue;
+            $grouped[$storeItem][$guid][$type][$group] = ($grouped[$storeItem][$guid][$type][$group] ?? 0) + $forecastValue;
         }
 
         return $grouped;