Update display of associated tax amounts

This commit is contained in:
Matt-Yorkley
2021-06-16 18:13:56 +01:00
parent ad1b9f3f2f
commit c60554a14a
6 changed files with 35 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
helper 'spree/orders'
helper 'spree/payment_methods'
helper 'shared'
helper 'adjustments'
helper 'enterprises'
helper 'order_cycles'
helper 'order'

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
module AdjustmentsHelper
def display_adjustment_taxes(adjustment)
if adjustment.included_tax_total > 0
amount = Spree::Money.new(adjustment.included_tax_total, currency: adjustment.currency)
I18n.t(:tax_amount_included, amount: amount)
elsif adjustment.additional_tax_total > 0
Spree::Money.new(adjustment.additional_tax_total, currency: adjustment.currency)
else
Spree::Money.new(0.00, currency: adjustment.currency)
end
end
end

View File

@@ -137,6 +137,14 @@ module Spree
tax_total.positive?
end
def included_tax_total
adjustments.tax.inclusive.sum(:amount)
end
def additional_tax_total
adjustments.tax.additional.sum(:amount)
end
private
def tax_total

View File

@@ -4,7 +4,7 @@
%th= "#{t('spree.date')}/#{t('spree.time')}"
%th= t(:description)
%th= t(:amount)
%th= t(:included_tax)
%th= t(:tax)
%th.actions
%tbody
- @collection.each do |adjustment|
@@ -13,10 +13,14 @@
- tr_class = cycle('odd', 'even')
- tr_id = spree_dom_id(adjustment)
%tr{:class => tr_class, "data-hook" => "adjustment_row", :id => tr_id}
%td.align-center.created_at= pretty_time(adjustment.created_at)
%td.align-center.label= adjustment.label
%td.align-center.amount= adjustment.display_amount.to_html
%td.align-center.included-tax= adjustment.display_included_tax.to_html
%td.align-center.created_at
= pretty_time(adjustment.created_at)
%td.align-center.label
= adjustment.label
%td.align-center.amount
= adjustment.display_amount.to_html
%td.align-center.tax
= display_adjustment_taxes(adjustment)
- unless @order.canceled?
%td.actions
- if adjustment.originator_type.nil?

View File

@@ -30,7 +30,7 @@
%td{:align => "right"}
1
%td{:align => "right"}
= adjustment.included_tax > 0 ? adjustment.display_included_tax : ""
= display_adjustment_taxes(adjustment)
%td{:align => "right"}
= adjustment.display_amount
%tfoot

View File

@@ -2162,6 +2162,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using
fundraising_fee: "Fundraising fee"
price_graph: "Price graph"
included_tax: "Included tax"
tax: "Tax"
tax_amount_included: "%{amount} (included)"
remove_tax: "Remove tax"
balance: "Balance"
transaction: "Transaction"