mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
always render shipment on the invoice
This commit is contained in:
@@ -61,6 +61,12 @@ class Invoice
|
||||
}
|
||||
end
|
||||
|
||||
if exclude.include? :shipment
|
||||
adjustments.reject! { |a|
|
||||
a.adjustable_type == 'Spree::Shipment'
|
||||
}
|
||||
end
|
||||
|
||||
if reject_zero_amount
|
||||
adjustments.reject! { |a| a.amount == 0 }
|
||||
end
|
||||
@@ -68,6 +74,30 @@ class Invoice
|
||||
adjustments
|
||||
end
|
||||
|
||||
def shipment_adjustment
|
||||
all_eligible_adjustments.find { |a| a.originator.type == 'Spree::ShippingMethod' }
|
||||
end
|
||||
|
||||
# contains limited information about the shipment
|
||||
def shipment
|
||||
shipment_adjustment.adjustable
|
||||
end
|
||||
|
||||
def display_shipment_amount_without_taxes
|
||||
Spree::Money.new(shipment.amount - shipment.included_tax_total, currency:)
|
||||
end
|
||||
|
||||
def display_shipment_amount_with_taxes
|
||||
Spree::Money.new(shipment.amount + shipment.additional_tax_total, currency:)
|
||||
end
|
||||
|
||||
def display_shipment_tax_rates
|
||||
all_eligible_adjustments.select { |a|
|
||||
a.originator.type == 'Spree::TaxRate' && a.adjustable_type == 'Spree::Shipment'
|
||||
}.map(&:originator)
|
||||
.map { |tr| number_to_percentage(tr.amount * 100, precision: 1) }.join(", ")
|
||||
end
|
||||
|
||||
def display_checkout_taxes_hash
|
||||
tax_adjustment_totals.map do |tax_rate_id, tax_amount|
|
||||
tax_rate = tax_rate_by_id[tax_rate_id]
|
||||
|
||||
@@ -35,8 +35,20 @@
|
||||
= item.display_line_item_tax_rates
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments_and_with_taxes
|
||||
|
||||
- @order.checkout_adjustments(exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{t(:shipping)} "
|
||||
= "( #{t(:invoice_shipping_type)} #{raw(@order.shipping_method.name)} )"
|
||||
%td{:align => "right"}
|
||||
%td{:align => "right"}
|
||||
%td{:align => "right"}
|
||||
%td{:align => "right"}
|
||||
= @order.display_shipment_amount_without_taxes
|
||||
%td{:align => "right"}
|
||||
= @order.display_shipment_tax_rates
|
||||
%td{:align => "right"}
|
||||
= @order.display_shipment_amount_with_taxes
|
||||
- @order.checkout_adjustments(exclude: [:line_item, :shipment]).reverse_each do |adjustment|
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
|
||||
@@ -1885,6 +1885,7 @@ en:
|
||||
invoice_tax_total: "GST Total:"
|
||||
tax_invoice: "TAX INVOICE"
|
||||
tax_total: "Total tax (%{rate}):"
|
||||
invoice_shipping_type: "Type:"
|
||||
total_excl_tax: "Total (Excl. tax):"
|
||||
total_incl_tax: "Total (Incl. tax):"
|
||||
abn: "ABN:"
|
||||
|
||||
Reference in New Issue
Block a user