Sha256: 7c8868b03bd35ebcafb752631730e214dfe42c7717ec068332548a9452e2a711

Contents?: true

Size: 1.37 KB

Versions: 13

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

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

module LedgerSync
  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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ledger_sync-quickbooks_online-2.0.0 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-1.0.1 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-1.0.0 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.4.0 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.3.1 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.3.0 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.6 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.5 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.4 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.2 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.1 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.2.0 lib/ledger_sync/quickbooks_online/expense/deserializer.rb
ledger_sync-quickbooks_online-0.1.1 lib/ledger_sync/quickbooks_online/expense/deserializer.rb