mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Fix error on summarising total_units
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user