From: fomichev Date: Wed, 9 Apr 2025 07:11:27 +0000 (+0300) Subject: Вычисление средней цены X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3e18da01d80dac2411e5fb5befb62b256f8f84e3;p=erp24_rep%2Fyii-erp24%2F.git Вычисление средней цены --- diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 1bf6d988..71512d1b 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -477,9 +477,10 @@ class StorePlanService if (!empty($priceRecords)) { $totalPrice = 0; - $count = count($priceRecords); + $records = ArrayHelper::getColumn((array)$priceRecords, 'price'); + $count = count((array)$priceRecords); foreach ($priceRecords as $record) { - $totalPrice += $record->price; // предполагаем, что поле с ценой называется "price" + $totalPrice += $record->price; } $averagePrice = $totalPrice / $count; } else {