From 038f392070aab53512871a1208081b1122968536 Mon Sep 17 00:00:00 2001 From: Noah Silvera Date: Fri, 30 Apr 2021 10:51:32 -0700 Subject: Use spree address2 if it is present The taxjar validation API has the option to take a freeform street input consisting of the full address. This means that if both address1 and address2 exist, we should concatenate them and pass them to the street parameter. This can help with situations that involve a suite number that has a unique ZIP+4 code that can be determined from the suite. The suite number is usually kept in address2, so without it, there's no way to distinguish the full address if only the 5 digit zip code is passed. Co-authored-by: Nick Van Doorn --- lib/super_good/solidus_taxjar/api_params.rb | 2 +- spec/super_good/solidus_taxjar/api_params_spec.rb | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index ef189e9..2e0e92c 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -72,7 +72,7 @@ module SuperGood state: spree_address.state&.abbr || spree_address.state_name, zip: spree_address.zipcode, city: spree_address.city, - street: spree_address.address1 + street: [spree_address.address1, spree_address.address2].compact.join(' ') } end diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index 1e879e7..df374d5 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -400,5 +400,35 @@ RSpec.describe SuperGood::SolidusTaxjar::ApiParams do }) end end + + context "an address with address2" do + let(:ship_address) do + Spree::Address.create!( + address1: "1 World Trade CTR", + address2: "STE 45A", + city: "New York", + country: country_us, + first_name: "Chuck", + last_name: "Schuldiner", + phone: "1-250-555-4444", + state: Spree::State.create!( + abbr: "NY", + country: country_us, + name: "New York" + ), + zipcode: "10007" + ) + end + + it "concatenates address1 and address2 into the street parameter" do + expect(subject).to eq({ + country: "US", + state: "NY", + zip: "10007", + city: "New York", + street: "1 World Trade CTR STE 45A" + }) + end + end end end -- cgit v1.2.3 From add456479abddfd665fecb21ae56cdd845083c3f Mon Sep 17 00:00:00 2001 From: Noah Silvera Date: Wed, 19 May 2021 12:00:37 -0700 Subject: Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 644b2ff..3b0a93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#59](https://github.com/SuperGoodSoft/solidus_taxjar/pull/59) Add pry debugging tools - [#69](https://github.com/SuperGoodSoft/solidus_taxjar/pull/69) Lock ExecJS version - [#37](https://github.com/SuperGoodSoft/solidus_taxjar/pull/37) Added a basic Taxjar settings admin interface which displays placeholder text. +- [#64](https://github.com/SuperGoodSoft/solidus_taxjar/pull/64) Provide Spree::Address.address2 to TaxJar address validation if it is present. ## v0.18.1 -- cgit v1.2.3