From: fomichev Date: Wed, 9 Apr 2025 08:58:29 +0000 (+0300) Subject: Подсчет цены X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f62c2b9bb8099e6c0793405c3159a7aefd2cfa36;p=erp24_rep%2Fyii-erp24%2F.git Подсчет цены --- diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 75b7fd2f..c8b7f5ca 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -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;