summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb12
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb12
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
index 5052814..327e248 100644
--- a/lib/super_good/solidus_taxjar/tax_calculator.rb
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -12,7 +12,7 @@ module SuperGood
def calculate
return no_tax if SuperGood::SolidusTaxJar.test_mode
- return no_tax if order.tax_address.empty? || order.line_items.none?
+ return no_tax if incomplete_address?(order.tax_address) || order.line_items.none?
return no_tax unless taxable_address? order.tax_address
cache do
@@ -150,6 +150,16 @@ module SuperGood
def line_item_tax_label(taxjar_line_item, spree_line_item)
SuperGood::SolidusTaxJar.line_item_tax_label_maker.(taxjar_line_item, spree_line_item)
end
+
+ def incomplete_address?(tax_address)
+ [
+ tax_address.address1,
+ tax_address.city,
+ tax_address&.state&.abbr || tax_address.state_name,
+ tax_address.zipcode,
+ tax_address.country.iso
+ ].any?(&:blank?)
+ end
end
end
end
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index a13f564..0d390ec 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -78,6 +78,10 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
let(:address) do
::Spree::Address.new(
first_name: "Ronnie James",
+ zipcode: "90210",
+ address1: "9900 Wilshire Blvd",
+ city: "Beverly Hills",
+ state_name: "California",
country: ::Spree::Country.new(iso: "US")
)
end
@@ -95,6 +99,10 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
let(:address) do
::Spree::Address.new(
first_name: "Ronnie James",
+ zipcode: "90210",
+ address1: "9900 Wilshire Blvd",
+ city: "Beverly Hills",
+ state_name: "California",
country: ::Spree::Country.new(iso: "US")
)
end
@@ -123,6 +131,10 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
let(:address) do
::Spree::Address.new(
first_name: "Ronnie James",
+ zipcode: "90210",
+ address1: "9900 Wilshire Blvd",
+ city: "Beverly Hills",
+ state_name: "California",
country: ::Spree::Country.new(iso: "US")
)
end