diff --git a/lib/open_food_network/sales_tax_report.rb b/lib/open_food_network/sales_tax_report.rb index 668e5ee04e..be48b04a02 100644 --- a/lib/open_food_network/sales_tax_report.rb +++ b/lib/open_food_network/sales_tax_report.rb @@ -18,9 +18,10 @@ module OpenFoodNetwork shipping_cost = shipping_cost_for order shipping_tax = order.shipping_tax enterprise_fee_tax = order.enterprise_fee_tax + total_tax = (order.adjustments + order.price_adjustments).sum(&:included_tax) [order.number, order.created_at, totals[:items], totals[:items_total], - totals[:taxable_total], totals[:sales_tax], shipping_cost, shipping_tax, enterprise_fee_tax, totals[:sales_tax] + shipping_tax + enterprise_fee_tax, + totals[:taxable_total], totals[:sales_tax], shipping_cost, shipping_tax, enterprise_fee_tax, total_tax, order.bill_address.full_name, order.distributor.andand.name] end end diff --git a/spec/factories.rb b/spec/factories.rb index 3a1738de2c..28ea617bd2 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -200,7 +200,7 @@ FactoryGirl.define do tax_category { create(:tax_category) } after(:create) do |product, proxy| - create(:tax_rate, amount: proxy.tax_rate_amount, calculator: Spree::Calculator::DefaultTax.new, tax_category: product.tax_category, zone: proxy.zone) + create(:tax_rate, amount: proxy.tax_rate_amount, tax_category: product.tax_category, included_in_price: true, calculator: Spree::Calculator::DefaultTax.new, zone: proxy.zone) end end end diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index bb64c52d2c..f16b736c00 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -126,7 +126,6 @@ feature %q{ let!(:line_item2) { create(:line_item, variant: product2.master, price: 500.15, quantity: 3, order: order1) } let!(:adj_shipping) { create(:adjustment, adjustable: order1, label: "Shipping", amount: 100.55) } - let!(:adj_li2_tax) { create(:adjustment, adjustable: line_item2, source: line_item2, originator: product2.tax_category.tax_rates.first, label: "RandomTax", amount: 123.00) } before do Spree::Config.shipment_inc_vat = true @@ -157,8 +156,7 @@ feature %q{ # And the totals and sales tax should be correct page.should have_content "1512.99" # items total page.should have_content "1500.45" # taxable items total - page.should have_content "123.0" # sales tax (from adj_li2_tax, not calculated on the fly) - page.should_not have_content "250.08" # the number that would have been calculated on the fly + page.should have_content "250.08" # sales tax page.should have_content "20.0" # enterprise fee tax # And the shipping cost and tax should be correct @@ -166,7 +164,7 @@ feature %q{ page.should have_content "16.76" # shipping tax # And the total tax should be correct - page.should have_content "159.76" # total tax + page.should have_content "286.84" # total tax end end