fix tax rates listing in invoices

This commit is contained in:
Mohamed ABDELLANI
2024-02-19 12:22:57 +01:00
parent 91ecdb0eb9
commit 56fe7f5e21
3 changed files with 10 additions and 6 deletions

View File

@@ -91,6 +91,14 @@ class Invoice
Spree::Money.new(shipment.amount + shipment.additional_tax_total, currency:)
end
def display_line_item_tax_rate(item)
all_tax_adjustments.select { |a|
a.adjustable.type == 'Spree::LineItem' && a.adjustable.id == item.id
}.map(&:originator).map { |tr|
number_to_percentage(tr.amount * 100, precision: 1)
}.join(", ")
end
def display_shipment_tax_rates
all_eligible_adjustments.select { |a|
a.originator.type == 'Spree::TaxRate' && a.adjustable_type == 'Spree::Shipment'

View File

@@ -3,7 +3,7 @@
class Invoice
class DataPresenter
class LineItem < Invoice::DataPresenter::Base
attributes :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
attributes :id, :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
:variant_id, :unit_price_price_and_unit, :unit_presentation,
:enterprise_fee_additional_tax, :enterprise_fee_included_tax
attributes_with_presenter :variant
@@ -35,10 +35,6 @@ class Invoice
fee_tax = enterprise_fee_included_tax || 0.0
Spree::Money.new(price_with_adjustments - ((included_tax + fee_tax) / quantity), currency:)
end
def display_line_item_tax_rates
tax_rates.map { |tr| number_to_percentage(tr.amount * 100, precision: 1) }.join(", ")
end
end
end
end

View File

@@ -32,7 +32,7 @@
%td{:align => "right"}
= item.display_amount_with_adjustments_without_taxes
%td{:align => "right"}
= item.display_line_item_tax_rates
= @order.display_line_item_tax_rate(item)
%td{:align => "right"}
= item.display_amount_with_adjustments_and_with_taxes
%tr