mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Extract private method
This was initially intended to cache the result of the `#map` and `#uniq` calls but we're not confident enough and don't want to scopecreep this. It's still worth to point out that this is what we need, line items' `unique orders`. Hopefully, next time we find a way to optimize it.
This commit is contained in:
@@ -159,15 +159,19 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def customer_payments_total_cost(line_items)
|
||||
line_items.map(&:order).uniq.sum(&:total)
|
||||
unique_orders(line_items).sum(&:total)
|
||||
end
|
||||
|
||||
def customer_payments_amount_owed(line_items)
|
||||
line_items.map(&:order).uniq.sum(&:outstanding_balance)
|
||||
unique_orders(line_items).sum(&:outstanding_balance)
|
||||
end
|
||||
|
||||
def customer_payments_amount_paid(line_items)
|
||||
line_items.map(&:order).uniq.sum(&:payment_total)
|
||||
unique_orders(line_items).sum(&:payment_total)
|
||||
end
|
||||
|
||||
def unique_orders(line_items)
|
||||
line_items.map(&:order).uniq
|
||||
end
|
||||
|
||||
def empty_cell(_line_items)
|
||||
|
||||
Reference in New Issue
Block a user