diff options
Diffstat (limited to 'lib/super_good')
-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 |