Class: SpreeAvataxOfficial::Transactions::FindOrderTransactionService

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_avatax_official/transactions/find_order_transaction_service.rb

Constant Summary

Constants inherited from Base

Base::APP_NAME, Base::APP_VERSION, Base::CONNECTION_OPTIONS, Base::SUCCESS_STATUSES

Instance Method Summary collapse

Instance Method Details

#call(order:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/services/spree_avatax_official/transactions/find_order_transaction_service.rb', line 4

def call(order:)
  return success(true)  if order.avatax_sales_invoice_transaction.present?
  return failure(false) if get_transaction(order).failure?

  order.create_avatax_sales_invoice_transaction(code: order.number)

  # ensure taxable items have avatax_uuid
  order.taxable_items.each { |item| item.update(avatax_uuid: SecureRandom.uuid) }

  success(true)
end