Do not charge tax on shipments when distributor does not charge sales tax

This commit is contained in:
Rohan Mitchell
2015-04-09 11:04:54 +10:00
parent 0b8a619274
commit 81324f3cc4
2 changed files with 14 additions and 2 deletions

View File

@@ -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

View File

@@ -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