mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add nil safety in reports for zero priced orders with no payment method
This commit is contained in:
@@ -23,7 +23,7 @@ module Reporting
|
||||
|
||||
def total_by_payment_method(orders, pay_method)
|
||||
orders.map(&:payments).flatten.select { |payment|
|
||||
payment.completed? && payment.payment_method.name.to_s.include?(pay_method)
|
||||
payment.completed? && payment.payment_method&.name.to_s.include?(pay_method)
|
||||
}.sum(&:amount)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ module Reporting
|
||||
{
|
||||
payment_state: proc { |payments| payment_state(payments.first.order) },
|
||||
distributor: proc { |payments| payments.first.order.distributor.name },
|
||||
payment_type: proc { |payments| payments.first.payment_method.name },
|
||||
payment_type: proc { |payments| payments.first.payment_method&.name },
|
||||
total_price: proc { |payments| payments.sum(&:amount) }
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user