summaryrefslogtreecommitdiff
path: root/lib/super_good
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-20 16:10:35 -0800
committerJared Norman <jared@super.gd>2019-01-20 16:10:35 -0800
commit3a1aea93e236ec0a52fae0ef4ab949acccd2088f (patch)
tree9bcf1596ea1f0cb8d69358b7f64b129e46f3ca35 /lib/super_good
parent4ddde7d3b241cd57f935bb74750d1ed574dd90c4 (diff)
Use correctly value for shipping tax
Oops, was grabbing the total shipping tax for the order and using that as the tax, instead of grabbing the collectable tax from the breakdown. That makes more sense.
Diffstat (limited to 'lib/super_good')
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
index 4efa367..445087a 100644
--- a/lib/super_good/solidus_taxjar/tax_calculator.rb
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -12,6 +12,7 @@ module SuperGood
def calculate
return no_tax if order.tax_address.empty?
+ return no_tax unless taxjar_breakdown
Spree::Tax::OrderTax.new(
order_id: order.id,
@@ -26,24 +27,22 @@ module SuperGood
def line_item_taxes
@line_item_taxes ||=
- if taxjar_breakdown
- taxjar_breakdown.line_items.map do |line_item|
- Spree::Tax::ItemTax.new(
- item_id: line_item.id.to_i,
- label: "Sales Tax",
- tax_rate: tax_rate,
- amount: line_item.tax_collectable,
- included_in_price: false
- )
- end
- else
- []
+ taxjar_breakdown.line_items.map do |line_item|
+ Spree::Tax::ItemTax.new(
+ item_id: line_item.id.to_i,
+ label: "Sales Tax",
+ tax_rate: tax_rate,
+ amount: line_item.tax_collectable,
+ included_in_price: false
+ )
end
end
def shipment_taxes
@shipment_taxes ||=
- if (total_shipping_tax = taxjar_tax.shipping) != 0
+ if taxjar_breakdown.shipping? &&
+ (total_shipping_tax = taxjar_breakdown.shipping.tax_collectable) != 0
+
# Distribute shipping tax across shipments:
# TaxJar does not provide a breakdown of shipping taxes, so we have
# to proportionally distribute the tax across the shipments,