summaryrefslogtreecommitdiff
path: root/lib/super_good/solidus_taxjar
diff options
context:
space:
mode:
Diffstat (limited to 'lib/super_good/solidus_taxjar')
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb12
1 files changed, 11 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