fix order_cycle summary row.

the summary row has to only include the line items coming from the supplier used in the grouping key
This commit is contained in:
Mohamed ABDELLANI
2023-06-09 08:44:14 +01:00
committed by Konrad
parent 7b0a99c652
commit 7a875723ca

View File

@@ -219,8 +219,12 @@ module Reporting
def order_cycle_totals_row
proc do |_key, items, _rows|
supplier_id = items.first.first[2] # supplier id used in the grouped line items
order_ids = items.flat_map(&:second).map(&:id).uniq
line_items = items.flat_map(&:second).uniq.map(&:line_items).flatten
.filter do |line_item|
line_item.supplier_id == supplier_id
end
total_excl_tax = total_fees_excl_tax(order_ids) + line_items_excl_tax(line_items)
tax = tax_for_order_ids(order_ids) + tax_for_line_items(line_items)