mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Deal with nil values in sum
Rails was doing that for us but Rails 7.1 won't.
This commit is contained in:
@@ -58,7 +58,6 @@ Openfoodnetwork::Application.configure do
|
||||
ActiveSupport::Deprecation.behavior = ->(message, callstack, deprecation_horizon, gem_name) do
|
||||
allowed_warnings = [
|
||||
# List strings here to allow matching deprecations.
|
||||
"Enumerable.sum", # spec/lib/reports/bulk_coop_report_spec.rb:188
|
||||
]
|
||||
unless allowed_warnings.any? { |pattern| message.match(pattern) }
|
||||
ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:raise].call(message, callstack, deprecation_horizon, gem_name)
|
||||
|
||||
@@ -21,15 +21,15 @@ module Reporting
|
||||
private
|
||||
|
||||
def customer_payments_total_cost(line_items)
|
||||
unique_orders(line_items).sum(&:total)
|
||||
unique_orders(line_items).map(&:total).sum(&:to_f)
|
||||
end
|
||||
|
||||
def customer_payments_amount_owed(line_items)
|
||||
unique_orders(line_items).sum(&:new_outstanding_balance)
|
||||
unique_orders(line_items).map(&:new_outstanding_balance).sum(&:to_f)
|
||||
end
|
||||
|
||||
def customer_payments_amount_paid(line_items)
|
||||
unique_orders(line_items).sum(&:payment_total)
|
||||
unique_orders(line_items).map(&:payment_total).sum(&:to_f)
|
||||
end
|
||||
|
||||
def unique_orders(line_items)
|
||||
|
||||
Reference in New Issue
Block a user