mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
When the order does not have a hub, all tax rates apply
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
Spree::TaxRate.class_eval do
|
||||
class << self
|
||||
def match_with_sales_tax_registration(order)
|
||||
return [] unless order.distributor.charges_sales_tax
|
||||
return [] if order.distributor && !order.distributor.charges_sales_tax
|
||||
match_without_sales_tax_registration(order)
|
||||
end
|
||||
alias_method_chain :match, :sales_tax_registration
|
||||
|
||||
@@ -9,7 +9,7 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
include UIComponentHelper
|
||||
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) }
|
||||
let(:supplier) { create(:supplier_enterprise) }
|
||||
let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.master]) }
|
||||
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23, tax_category: product.tax_category) }
|
||||
|
||||
@@ -5,7 +5,7 @@ module Spree
|
||||
let!(:order) { create(:order, distributor: hub, bill_address: create(:address)) }
|
||||
let!(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: Calculator::FlatRate.new(preferred_amount: 0.1), zone: zone) }
|
||||
|
||||
context "when the order's hub charges sales tax" do
|
||||
describe "when the order's hub charges sales tax" do
|
||||
let(:hub) { create(:distributor_enterprise, charges_sales_tax: true) }
|
||||
|
||||
it "selects all tax rates" do
|
||||
@@ -13,13 +13,21 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
context "when the order's hub does not charge sales tax" do
|
||||
describe "when the order's hub does not charge sales tax" do
|
||||
let(:hub) { create(:distributor_enterprise, charges_sales_tax: false) }
|
||||
|
||||
it "selects no tax rates" do
|
||||
TaxRate.match(order).should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "when the order does not have a hub" do
|
||||
let!(:order) { create(:order, distributor: nil, bill_address: create(:address)) }
|
||||
|
||||
it "selects all tax rates" do
|
||||
TaxRate.match(order).should == [tax_rate]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user