summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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