summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-04-24 16:53:03 -0700
committerJared Norman <jared@super.gd>2019-04-24 16:55:12 -0700
commitd98c103f6bc485d8398f5231bfe7917b772ec829 (patch)
tree0b95fc781ee20c3f400da27d8ffc805aff92920f
parent0203766a9291ae2eca5a73c067530564e09f481d (diff)
More hacks to handle zero dollar orders
I have a plan for how to handle these better in v1.0 though!
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/super_good/solidus_taxjar/api_params.rb8
-rw-r--r--spec/super_good/solidus_taxjar/api_params_spec.rb12
3 files changed, 20 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b83f7af..5a6699c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
## master
-- Report no tax collected on order when order total zeroed out.
+- Report no tax collected on order and line items when order total zeroed out.
## v0.11.1
diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb
index ca346ff..53b2c81 100644
--- a/lib/super_good/solidus_taxjar/api_params.rb
+++ b/lib/super_good/solidus_taxjar/api_params.rb
@@ -85,7 +85,7 @@ module SuperGood
product_tax_code: line_item.tax_category&.tax_code,
unit_price: line_item.price,
discount: discount(line_item),
- sales_tax: line_item.additional_tax_total
+ sales_tax: line_item_sales_tax(line_item)
}
end
}
@@ -112,6 +112,12 @@ module SuperGood
order.additional_tax_total
end
+
+ def line_item_sales_tax(line_item)
+ return 0 if line_item.order.total.zero?
+
+ line_item.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 e16edb9..daa5b63 100644
--- a/spec/super_good/solidus_taxjar/api_params_spec.rb
+++ b/spec/super_good/solidus_taxjar/api_params_spec.rb
@@ -222,6 +222,18 @@ RSpec.describe SuperGood::SolidusTaxJar::APIParams do
it "sends the sales tax total as zero" do
expect(subject[:sales_tax]).to be_zero
end
+
+ it "sends the sales tax on the line items as zero" do
+ expect(subject[:line_items]).to contain_exactly({
+ discount: 2,
+ id: line_item.id,
+ product_identifier: "G00D-PR0DUCT",
+ product_tax_code: "A_GEN_TAX",
+ quantity: 3,
+ sales_tax: 0,
+ unit_price: 10
+ })
+ end
end
context "when the line item has 0 quantity" do