mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
fix tax rates listing in invoices
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user