]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Подсчет цены
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 9 Apr 2025 08:58:29 +0000 (11:58 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 9 Apr 2025 08:58:29 +0000 (11:58 +0300)
erp24/services/StorePlanService.php

index 75b7fd2f9f8ce997b172ec7464680356454c814f..c8b7f5ca376e450fdf19dd1e60b559bae16eaac8 100755 (executable)
@@ -464,7 +464,7 @@ class StorePlanService
                 'or',
                 ['>=', 'date_to', $monthStart],
                 ['date_to' => '2100-01-01 03:00:00+03']
-            ]);
+            ])->all();
         if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) {
             $region = 52;
         } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) {
@@ -472,18 +472,18 @@ class StorePlanService
         } else {
             $region = null;
         }
-        $priceRecords
-            //->andWhere(['or',['region_id' => $region],['region_id' => null]])
-            ->all();
+
+            //$priceRecords->andWhere(['or',['region_id' => $region],['region_id' => null]])
+            //->all();
 
 
         if (!empty($priceRecords)) {
             $totalPrice = 0;
-            $records = ArrayHelper::toArray($priceRecords);
-            $count = count($records);
+            $count = 0;
             foreach ($priceRecords as $record) {
                 if (isset($record->price)) {
                     $totalPrice += $record->price;
+                    $count += 1;
                 }
             }
             $averagePrice = $totalPrice / $count;