Sha256: 92250684f6c3dcc24968efcd3d1ecbe68f714afe4e5f95c75e086685c2f589e0

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require_relative '../expense_line/deserializer'
require_relative '../reference/deserializer'

module LedgerSync
  module Ledgers
    module QuickBooksOnline
      class Expense
        class Deserializer < QuickBooksOnline::Deserializer
          id

          attribute :DocNumber
          date :TxnDate
          attribute :PrivateNote

          attribute :ExchangeRate

          mapping :PaymentType,
                  hash: Expense::PAYMENT_TYPES.invert

          attribute(:Entity) do |args = {}|
            hash = args.fetch(:hash)
            value = hash['EntityRef']

            unless value.nil?
              Client.resource_from_ledger_type(
                type: value['type']
              ).new(
                ledger_id: value['value']
              )
            end
          end

          references_one :Currency,
                         hash_attribute: 'CurrencyRef',
                         deserializer: Reference::Deserializer

          references_one :Account,
                         hash_attribute: 'AccountRef',
                         deserializer: Reference::Deserializer

          references_one :Department,
                         hash_attribute: 'DepartmentRef',
                         deserializer: Reference::Deserializer

          references_many :Line,
                          hash_attribute: 'Line',
                          deserializer: ExpenseLine::Deserializer
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ledger_sync-1.6.0 lib/ledger_sync/ledgers/quickbooks_online/expense/deserializer.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/quickbooks_online/expense/deserializer.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/quickbooks_online/expense/deserializer.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/quickbooks_online/expense/deserializer.rb