Deal with nil values in sum

Rails was doing that for us but Rails 7.1 won't.
This commit is contained in:
Maikel Linke
2025-03-28 16:58:32 +11:00
parent 007154ef28
commit 4962304a48
2 changed files with 3 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)