mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix shipping tax display in regular invoice template
This commit is contained in:
@@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base
|
||||
helper 'spree/orders'
|
||||
helper 'spree/payment_methods'
|
||||
helper 'shared'
|
||||
helper 'adjustments'
|
||||
helper 'tax'
|
||||
helper 'enterprises'
|
||||
helper 'order_cycles'
|
||||
helper 'order'
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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
|
||||
|
||||
def display_adjustment_total_with_tax(adjustment)
|
||||
total = adjustment.amount + adjustment.additional_tax_total
|
||||
Spree::Money.new(total, currency: adjustment.currency)
|
||||
end
|
||||
end
|
||||
19
app/helpers/tax_helper.rb
Normal file
19
app/helpers/tax_helper.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module TaxHelper
|
||||
def display_taxes(taxable, display_zero: true)
|
||||
if !taxable.included_tax_total.zero?
|
||||
amount = Spree::Money.new(taxable.included_tax_total, currency: taxable.currency)
|
||||
I18n.t(:tax_amount_included, amount: amount)
|
||||
elsif !taxable.additional_tax_total.zero?
|
||||
Spree::Money.new(taxable.additional_tax_total, currency: taxable.currency)
|
||||
else
|
||||
Spree::Money.new(0.00, currency: taxable.currency) if display_zero
|
||||
end
|
||||
end
|
||||
|
||||
def display_total_with_tax(taxable)
|
||||
total = taxable.amount + taxable.additional_tax_total
|
||||
Spree::Money.new(total, currency: taxable.currency)
|
||||
end
|
||||
end
|
||||
@@ -25,9 +25,9 @@
|
||||
%td.align-center.tax-category
|
||||
= taxable.tax_category&.name || "-"
|
||||
%td.align-center.tax
|
||||
= display_adjustment_taxes(taxable)
|
||||
= display_taxes(taxable)
|
||||
%td.align-center.total
|
||||
= display_adjustment_total_with_tax(taxable)
|
||||
= display_total_with_tax(taxable)
|
||||
- unless @order.canceled?
|
||||
%td.actions
|
||||
- if adjustment.originator_type.nil?
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- taxable = adjustment.adjustable_type == "Spree::Shipment" ? adjustment.adjustable : adjustment
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
%td{:align => "right"}
|
||||
1
|
||||
%td{:align => "right"}
|
||||
= display_adjustment_taxes(adjustment)
|
||||
= display_taxes(taxable, display_zero: false)
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_amount
|
||||
%tfoot
|
||||
|
||||
Reference in New Issue
Block a user