diff options
author | Juan Carlos Ruiz <JuanCrg90@gmail.com> | 2019-03-12 14:11:49 -0600 |
---|---|---|
committer | Juan Carlos Ruiz <JuanCrg90@gmail.com> | 2019-03-12 16:20:46 -0600 |
commit | 9f48531b513be0f233eddbdfce8be2e071f3539a (patch) | |
tree | ad50e6c3c6150dbfa80601fc9449250b8d19478e /lib | |
parent | 9a83ec4cda37760aad82373dc422cadbb33eddfe (diff) |
Add incomplete_address? check method
Solidus has deprecated the `empty?` method on
https://github.com/solidusio/solidus/pull/1686 . This adds a private
`incomplete_address?` method for avoid future problems and remove the
deprecation warning in projects that uses this gem.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/super_good/solidus_taxjar/tax_calculator.rb | 12 |
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 |