diff options
author | Jared Norman <jared@super.gd> | 2019-03-19 12:49:03 -0700 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-03-19 12:49:03 -0700 |
commit | 0d3d8783755d18c0d6ebfc95f3109b518e7e1b07 (patch) | |
tree | a786b218ddf0b3147876c329ddb1f96f07e19254 /lib | |
parent | f5f234e82ab8f2cc5044c9299e8894ff9dcbbf8d (diff) |
Report full line item list for transactions
This sends the full list of line items in the order with their SKUs and
tax codes when creating/updating transactions in TaxJar.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/super_good/solidus_taxjar/api_params.rb | 17 |
1 files changed, 17 insertions, 0 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 |