我有这段代码可以与. 一起使用shipment has one invoice
,但现在我不得不将其更改为shipment has many invoices
. 如何修改以下代码以反映新的关联?
@totals = {
:overall => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_total },
:paid => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_amount_paid },
:balance => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_open_balance }
}