diff options
author | Jared Norman <jared@super.gd> | 2019-04-24 16:42:55 -0700 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-04-24 16:42:55 -0700 |
commit | 0203766a9291ae2eca5a73c067530564e09f481d (patch) | |
tree | 3941b71ab1c93620d5630eab6e4a3ae6a55cbd32 | |
parent | 656181bb7e234da0872239c8572965c8aaad58cd (diff) |
Report no tax collected when order zeroed out
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/api_params.rb | 8 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/api_params_spec.rb | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb0a0d..b83f7af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +- Report no tax collected on order when order total zeroed out. + ## v0.11.1 - Avoid sending negative amounts for order totals. diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index 3d898c3..ca346ff 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -30,7 +30,7 @@ module SuperGood transaction_date: order.completed_at.to_formatted_s(:iso8601), amount: [order.total - order.additional_tax_total, 0].max, shipping: shipping(order), - sales_tax: order.additional_tax_total + sales_tax: sales_tax(order) ) end @@ -106,6 +106,12 @@ module SuperGood def shipping(order) SuperGood::SolidusTaxJar.shipping_calculator.(order) end + + def sales_tax(order) + return 0 if order.total.zero? + + order.additional_tax_total + end end end end diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index 2e9e289..e16edb9 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -218,6 +218,10 @@ RSpec.describe SuperGood::SolidusTaxJar::APIParams do it "sends the order total as zero" do expect(subject[:amount]).to be_zero end + + it "sends the sales tax total as zero" do + expect(subject[:sales_tax]).to be_zero + end end context "when the line item has 0 quantity" do |