48 $storeTotals = parent::getStoreTotals();
49 if (empty($storeTotals))
54 $priceAmounts = $this->getPriceAmounts();
56 $formattedTotalsByPrices = $storeTotals;
57 foreach ($storeTotals as $storeId => $storeTotal)
61 'TOTAL_COST_PRICE' => 0
63 $storeTotal[
'TOTALS'] ??= [];
64 foreach ($storeTotal[
'TOTALS'] as $measureId => $fields)
66 foreach ($fields as $fieldId => $value)
68 $total[$fieldId][$measureId] = $value;
72 $priceAmounts[$storeId] ??= [];
73 foreach ($priceAmounts[$storeId] as $currency => $fields)
76 $total[
'TOTAL_SOLD'] ??= 0;
77 $total[
'TOTAL_SOLD'] += $fields[
'TOTAL_SOLD'];
78 $total[
'TOTAL_COST_PRICE'] ??= 0;
79 $total[
'TOTAL_COST_PRICE'] += $fields[
'COST_PRICE'];
82 $total[
'PROFIT'] = $total[
'TOTAL_SOLD'] - $total[
'TOTAL_COST_PRICE'];
83 $total[
'PROFITABILITY'] = $this->
calculateProfitability((
float)$total[
'TOTAL_COST_PRICE'], (
float)$total[
'PROFIT']);
84 $formattedTotalsByPrices[$storeId][
'TOTALS'] = $total;
87 return $formattedTotalsByPrices;
93 'STARTING_QUANTITY' => [],
94 'RECEIVED_QUANTITY' => [],
96 'QUANTITY_RESERVED_SUM' => [],
100 'TOTAL_COST_PRICE' => 0,
102 'PROFITABILITY' => 0,
105 foreach ($storeTotals as $storeTotalEntry)
107 foreach ($storeTotalEntry[
'TOTALS'] as $fieldName => $value)
109 if ($value && is_array($value))
111 $overallTotals[$fieldName] ??= [];
112 foreach ($value as $measureId => $measureItemValue)
114 $overallTotals[$fieldName][$measureId] ??= 0.0;
115 $overallTotals[$fieldName][$measureId] += $measureItemValue;
120 $overallTotals[$fieldName] ??= 0.0;
121 $overallTotals[$fieldName] += (float)$value;
126 $overallTotals[
'PROFITABILITY'] = $this->
calculateProfitability($overallTotals[
'TOTAL_COST_PRICE'], $overallTotals[
'PROFIT']);
128 return $overallTotals;