Sha256: 35e4d34bfc77823b645531e47a89ee1368ca978ad1703f37cb92098e8a1c9a5f
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
module LedgerSync module Adaptors module QuickBooksOnline module Deposit module Operations class Create < Operation::Create class Contract < LedgerSync::Adaptors::Contract params do required(:ledger_id).value(:nil) required(:account).hash(Types::Reference) required(:currency).filled(:string) required(:memo).filled(:string) required(:transaction_date).filled(:date?) required(:exchange_rate).maybe(:float) required(:line_items).array(Types::Reference) end end private def operate response = adaptor.post( resource: 'deposit', payload: local_resource_data ) resource.ledger_id = response.dig('Id') success(response: response) end def local_resource_data { 'CurrencyRef' => { 'value' => resource.currency, }, 'TxnDate' => resource.transaction_date.to_s, # Format: YYYY-MM-DD 'PrivateNote' => resource.memo, 'ExchangeRate' => resource.exchange_rate, 'DepositToAccountRef' => { 'value' => resource.account.ledger_id }, 'Line' => resource.line_items.map do |line_item| { 'DetailType' => 'DepositLineDetail', 'DepositLineDetail' => { 'AccountRef' => { 'value' => line_item.account&.ledger_id } }, 'Amount' => line_item.amount / 100.0, 'Description' => line_item.description } end } end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.1.1 | lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/create.rb |