mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Do not charge tax on shipments when distributor does not charge sales tax
This commit is contained in:
@@ -3,7 +3,11 @@ module Spree
|
||||
def ensure_correct_adjustment_with_included_tax
|
||||
ensure_correct_adjustment_without_included_tax
|
||||
|
||||
adjustment.set_included_tax! Config.shipping_tax_rate if Config.shipment_inc_vat
|
||||
if Config.shipment_inc_vat && (order.distributor.nil? || order.distributor.charges_sales_tax)
|
||||
adjustment.set_included_tax! Config.shipping_tax_rate
|
||||
else
|
||||
adjustment.set_included_tax! 0
|
||||
end
|
||||
end
|
||||
|
||||
alias_method_chain :ensure_correct_adjustment, :included_tax
|
||||
|
||||
@@ -30,7 +30,8 @@ module Spree
|
||||
end
|
||||
|
||||
describe "Shipment adjustments" do
|
||||
let!(:order) { create(:order, shipping_method: shipping_method) }
|
||||
let!(:order) { create(:order, distributor: hub, shipping_method: shipping_method) }
|
||||
let(:hub) { create(:distributor_enterprise, charges_sales_tax: true) }
|
||||
let!(:line_item) { create(:line_item, order: order) }
|
||||
let(:shipping_method) { create(:shipping_method, calculator: Calculator::FlatRate.new(preferred_amount: 50.0)) }
|
||||
let(:adjustment) { order.adjustments(:reload).shipping.first }
|
||||
@@ -80,6 +81,13 @@ module Spree
|
||||
|
||||
adjustment.included_tax.should == 0
|
||||
end
|
||||
|
||||
it "records 0% tax on shipments when the distributor does not charge sales tax" do
|
||||
order.distributor.update_attributes! charges_sales_tax: false
|
||||
order.reload.create_shipment!
|
||||
|
||||
adjustment.included_tax.should == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user