Calculate total tax from the tax included in all the adjustments on the order

This commit is contained in:
Rohan Mitchell
2015-03-25 16:07:03 +11:00
parent 333a4ecf2f
commit 84f3097217
3 changed files with 5 additions and 6 deletions

View File

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

View File

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

View File

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