Sha256: ea588d39902696f5349fb6ec0d3cf38660eb9af23bbb467b6bdc5cc9206d4d23
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module LedgerSync module Adaptors module QuickBooksOnline module JournalEntry module Operations class Update < Operation::Update class Contract < LedgerSync::Adaptors::Contract schema do required(:ledger_id).filled(:string) optional(:currency).filled(:string) optional(:memo).filled(:string) optional(:transaction_date).filled(:date?) optional(:line_items).array(Types::Reference) end end private def operate ledger_resource_data = adaptor.find( resource: 'journal_entry', id: resource.ledger_id ) response = adaptor.post( resource: 'journal_entry', payload: merge_into(from: local_resource_data, to: ledger_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, 'Line' => resource.line_items.map do |line_item| { 'DetailType' => 'JournalEntryLineDetail', 'JournalEntryLineDetail' => { 'PostingType': Mapping::LINE_ITEM_TYPES[line_item.entry_type], '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/journal_entry/operations/update.rb |