Allow enterprise fee with no tax category

This commit is contained in:
Rohan Mitchell
2015-03-06 12:12:33 +11:00
parent 1e18f773f5
commit 381bfd383b
2 changed files with 4 additions and 3 deletions

View File

@@ -32,7 +32,9 @@ module OpenFoodNetwork
end
def adjustment_tax(order, adjustment)
enterprise_fee.tax_category.tax_rates.match(order).sum do |rate|
tax_rates = enterprise_fee.tax_category ? enterprise_fee.tax_category.tax_rates.match(order) : []
tax_rates.sum do |rate|
compute_tax rate, adjustment.amount
end
end

View File

@@ -84,7 +84,6 @@ module Spree
let!(:zone_member) { ZoneMember.create!(zone: zone, zoneable: Country.find_by_name('Australia')) }
let(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: Calculator::DefaultTax.new, zone: zone, amount: 0.1) }
let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) }
let(:tax_category_untaxed) { create(:tax_category) }
let(:coordinator) { create(:distributor_enterprise) }
let(:variant) { create(:variant) }
@@ -120,7 +119,7 @@ module Spree
describe "when enterprise fees have no tax" do
before do
enterprise_fee.tax_category = tax_category_untaxed
enterprise_fee.tax_category = nil
enterprise_fee.save!
order.update_distribution_charge!
end