summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-03-19 12:58:37 -0700
committerGitHub <noreply@github.com>2019-03-19 12:58:37 -0700
commit132bf515857d04f79143650a529d956e3bfb44a1 (patch)
tree229ad98b7272d97c2020d25a306089791eb3cddc /lib
parentf5f234e82ab8f2cc5044c9299e8894ff9dcbbf8d (diff)
parent84d0cf6c10bef0818f20e37531996a4bed29b6b2 (diff)
Merge pull request #5 from SuperGoodSoft/feature/report-line-itemsv0.7.0
Send full line item list when creating/updating transactions
Diffstat (limited to 'lib')
-rw-r--r--lib/super_good/solidus_taxjar/api_params.rb17
-rw-r--r--lib/super_good/solidus_taxjar/version.rb2
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb
index b848eee..cb554a8 100644
--- a/lib/super_good/solidus_taxjar/api_params.rb
+++ b/lib/super_good/solidus_taxjar/api_params.rb
@@ -24,6 +24,7 @@ module SuperGood
def transaction_params(order)
{}
.merge(order_address_params(order.tax_address))
+ .merge(transaction_line_items_params(order.line_items))
.merge(
transaction_id: order.number,
transaction_date: order.completed_at.to_formatted_s(:iso8601),
@@ -74,6 +75,22 @@ module SuperGood
}
end
+ def transaction_line_items_params(line_items)
+ {
+ line_items: line_items.map do |line_item|
+ {
+ id: line_item.id,
+ quantity: line_item.quantity,
+ product_identifier: line_item.sku,
+ 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
+ }
+ end
+ }
+ end
+
def discount(line_item)
::SuperGood::SolidusTaxJar.discount_calculator.new(line_item).discount
end
diff --git a/lib/super_good/solidus_taxjar/version.rb b/lib/super_good/solidus_taxjar/version.rb
index 6ca181f..a27c342 100644
--- a/lib/super_good/solidus_taxjar/version.rb
+++ b/lib/super_good/solidus_taxjar/version.rb
@@ -1,5 +1,5 @@
module SuperGood
module SolidusTaxJar
- VERSION = "0.6.2"
+ VERSION = "0.7.0"
end
end