Fix error on summarising total_units

This commit is contained in:
Maikel Linke
2023-05-16 14:11:19 +10:00
parent 71e4d2c6ed
commit 6803e0a8f9
2 changed files with 8 additions and 2 deletions

View File

@@ -25,9 +25,15 @@ module Reporting
group_by: :producer,
header: true,
summary_row: proc do |_key, _items, rows|
total_units = rows.map(&:total_units)
summary_total_units = if total_units.all?(&:present?)
rows.sum(&:total_units)
else
" "
end
{
quantity: rows.sum(&:quantity),
total_units: rows.sum(&:total_units),
total_units: summary_total_units,
total_cost: rows.sum(&:total_cost)
}
end

View File

@@ -82,7 +82,7 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleSupplierTotals do
expect(report_table[2][4]).to eq 0.601 # summary
end
pending "is blank in summary when one line item misses a unit and another not" do
it "is blank in summary when one line item misses a unit and another not" do
expect(report).to receive(:display_summary_row?).and_return(true)
# This is not possible with the current code but was possible years ago.