From d489e06009ff576a34d4ebeb3b965d7256d7da99 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 24 Mar 2015 10:40:54 +1100 Subject: [PATCH] Retrieve line item sales tax from included_tax rather than tax amount --- lib/open_food_network/sales_tax_report.rb | 2 +- spec/features/admin/reports_spec.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/open_food_network/sales_tax_report.rb b/lib/open_food_network/sales_tax_report.rb index db3660c84b..a296f13f74 100644 --- a/lib/open_food_network/sales_tax_report.rb +++ b/lib/open_food_network/sales_tax_report.rb @@ -55,7 +55,7 @@ module OpenFoodNetwork end def tax_included_in(line_item) - line_item.adjustments.included_tax.sum &:amount + line_item.adjustments.sum &:included_tax end def shipment_inc_vat diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 89fe97357a..724a50fd71 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -110,6 +110,8 @@ feature %q{ describe "Sales tax report" do let!(:payment_method) { create(:payment_method, distributors: [user1.enterprises.first]) } + let!(:zone) { create(:zone, default_tax: true) } + let!(:zone_member) { Spree::ZoneMember.create!(zone: zone, zoneable: Spree::Country.find_by_name('Australia')) } let(:user1) do create_enterprise_user(enterprises: [create(:distributor_enterprise)]) @@ -119,8 +121,8 @@ feature %q{ end let(:tax_category1) { create(:tax_category) } let(:tax_category2) { create(:tax_category) } - let!(:tax_rate1) { create(:tax_rate, amount: 0.0, calculator: Spree::Calculator::DefaultTax.new, tax_category: tax_category1) } - let!(:tax_rate2) { create(:tax_rate, amount: 0.2, calculator: Spree::Calculator::DefaultTax.new, tax_category: tax_category2) } + let!(:tax_rate1) { create(:tax_rate, amount: 0.0, calculator: Spree::Calculator::DefaultTax.new, tax_category: tax_category1, zone: zone) } + let!(:tax_rate2) { create(:tax_rate, amount: 0.2, calculator: Spree::Calculator::DefaultTax.new, tax_category: tax_category2, zone: zone) } let(:product1) { create(:product, price: 12.54, tax_category: tax_category1) } let(:product2) { create(:product, price: 500.15, tax_category: tax_category2) } @@ -137,7 +139,7 @@ feature %q{ Spree::Config.shipment_inc_vat = true Spree::Config.shipping_tax_rate = 0.2 - order1.create_shipment! + 3.times { order1.next } order1.finalize! login_to_admin_as user1