mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make code work for relations and arrays
This commit is contained in:
@@ -60,11 +60,11 @@ class ProducerMailer < Spree::BaseMailer
|
||||
end
|
||||
|
||||
def total_from_line_items(line_items)
|
||||
Spree::Money.new line_items.sum(&:total)
|
||||
Spree::Money.new line_items.to_a.sum(&:total)
|
||||
end
|
||||
|
||||
def tax_total_from_line_items(line_items)
|
||||
Spree::Money.new line_items.sum(&:included_tax)
|
||||
Spree::Money.new line_items.to_a.sum(&:included_tax)
|
||||
end
|
||||
|
||||
# This hack makes ActiveRecord skip the default_scope (deleted_at IS NULL)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
%td.toggle-bought{ colspan: 2, ng: { click: 'showBought=!showBought' } }
|
||||
%h5.brick
|
||||
%i{ ng: { class: "{ 'ofn-i_007-caret-right': !showBought, 'ofn-i_005-caret-down': showBought}"} }
|
||||
= t(:orders_bought_items_notice, count: @order.finalised_line_items.sum(&:quantity))
|
||||
= t(:orders_bought_items_notice, count: @order.finalised_line_items.to_a.sum(&:quantity))
|
||||
%td.text-right{ colspan: 3 }
|
||||
%a.edit-finalised.button.radius.expand.small{ href: changeable_orders_link_path, ng: { class: "{secondary: !showBought, primary: showBought}" } }
|
||||
= t(:orders_bought_edit_button)
|
||||
|
||||
@@ -180,11 +180,11 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def total_untaxable_products(order)
|
||||
order.line_items.without_tax.sum(&:amount)
|
||||
order.line_items.without_tax.to_a.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_taxable_products(order)
|
||||
order.line_items.with_tax.sum(&:amount)
|
||||
order.line_items.with_tax.to_a.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_untaxable_fees(order)
|
||||
|
||||
Reference in New Issue
Block a user