From 2af0afafe9e027ea31ea46a31d3bc38830a0978f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 19 Feb 2021 18:30:01 +0000 Subject: [PATCH] Update Order#shipping_tax --- app/models/spree/order.rb | 2 +- spec/models/spree/order_spec.rb | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index faac4a7089..df08a4dd47 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -646,7 +646,7 @@ module Spree end def shipping_tax - shipment_adjustments.reload.shipping.sum(:included_tax) + shipment_adjustments.reload.tax.sum(:amount) end def enterprise_fee_tax diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 58895613e9..51adbd5480 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -636,16 +636,19 @@ describe Spree::Order do describe "getting the shipping tax" do let(:order) { create(:order) } - let(:shipping_method) { create(:shipping_method_with, :flat_rate) } + let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, included_in_price: true, zone: create(:zone_with_member)) } + let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate]) } + let!(:shipping_method) { create(:shipping_method_with, :flat_rate, tax_category: shipping_tax_category) } context "with a taxed shipment" do - before do - allow(Spree::Config).to receive(:shipment_inc_vat).and_return(true) - allow(Spree::Config).to receive(:shipping_tax_rate).and_return(0.25) - end - let!(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) } + before do + allow(order).to receive(:tax_zone) { shipping_tax_rate.zone } + order.reload + order.create_tax_charge! + end + it "returns the shipping tax" do expect(order.shipping_tax).to eq(10) end