diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index 780c27c595..1ba2097d80 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -72,7 +72,9 @@ module CheckoutHelper totals.each_with_object({}) do |(tax_rate, tax_amount), hash| hash[number_to_percentage(tax_rate.amount * 100, precision: 1)] = - Spree::Money.new tax_amount, currency: order.currency + { + amount: Spree::Money.new(tax_amount, currency: order.currency), + } end end diff --git a/app/views/spree/admin/orders/_invoice_table2.html.haml b/app/views/spree/admin/orders/_invoice_table2.html.haml index eb83714747..ad2c97977d 100644 --- a/app/views/spree/admin/orders/_invoice_table2.html.haml +++ b/app/views/spree/admin/orders/_invoice_table2.html.haml @@ -47,12 +47,12 @@ %strong= @order.has_taxes_included ? t(:total_incl_tax) : t(:total_excl_tax) %td{:align => "right", :colspan => "2"} %strong= @order.has_taxes_included ? @order.display_total : display_checkout_total_less_tax(@order) - - display_checkout_taxes_hash(@order).each do |tax_rate, tax_value| + - display_checkout_taxes_hash(@order).each do |tax_rate, tax| %tr %td{:align => "right", :colspan => "3"} = t(:tax_total, rate: tax_rate) %td{:align => "right", :colspan => "2"} - = tax_value + = tax[:amount] %tr %td{:align => "right", :colspan => "3"} = @order.has_taxes_included ? t(:total_excl_tax) : t(:total_incl_tax) diff --git a/app/views/spree/admin/orders/ticket.html.haml b/app/views/spree/admin/orders/ticket.html.haml index 415fb97adb..07810ca7d4 100644 --- a/app/views/spree/admin/orders/ticket.html.haml +++ b/app/views/spree/admin/orders/ticket.html.haml @@ -58,10 +58,10 @@ j(@order.display_total.format(with_currency: false))]}", '\x1B' + '\x45' + '\x0A', // bold off '\x0A', - "#{display_checkout_taxes_hash(@order).map { |tax_rate, tax_value| + "#{display_checkout_taxes_hash(@order).map { |tax_rate, tax| '%31s%10s' % [j(t(:tax_total, rate: tax_rate)), - j(tax_value.format(with_currency: false))] + + j(tax[:amount].format(with_currency: false))] + '" + \'\x0A\' + "'}.join }", "#{'%31s%10s' % [j(t(:total_excl_tax)), diff --git a/spec/helpers/checkout_helper_spec.rb b/spec/helpers/checkout_helper_spec.rb index b09d7d01a9..6851383879 100644 --- a/spec/helpers/checkout_helper_spec.rb +++ b/spec/helpers/checkout_helper_spec.rb @@ -48,7 +48,9 @@ describe CheckoutHelper, type: :helper do order.save! expect(helper.display_checkout_taxes_hash(order)).to eq( - "10.0%" => Spree::Money.new(1, currency: order.currency) + "10.0%" => { + amount: Spree::Money.new(1, currency: order.currency), + } ) end @@ -58,8 +60,8 @@ describe CheckoutHelper, type: :helper do order.save! expect(helper.display_checkout_taxes_hash(order)).to eq( - "10.0%" => Spree::Money.new(1, currency: order.currency), - "20.0%" => Spree::Money.new(2, currency: order.currency), + "10.0%" => { amount: Spree::Money.new(1, currency: order.currency) }, + "20.0%" => { amount: Spree::Money.new(2, currency: order.currency) }, ) end @@ -71,8 +73,8 @@ describe CheckoutHelper, type: :helper do # This passes because we override the hash entry exactly # like the original code. expect(helper.display_checkout_taxes_hash(order)).to eq( - "20.0%" => Spree::Money.new(2, currency: order.currency), - "20.0%" => Spree::Money.new(2, currency: order.currency), + "20.0%" => { amount: Spree::Money.new(2, currency: order.currency) }, + "20.0%" => { amount: Spree::Money.new(2, currency: order.currency) }, ) pending "https://github.com/openfoodfoundation/openfoodnetwork/issues/9605"