Sha256: b28e4e7a336e14251e8007a849d41fa40caa6ea5632d759007c3c08bc7295019

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_relative '../reference/serializer'
require_relative '../check_line_item/serializer'

module LedgerSync
  module NetSuite
    class Check
      class Serializer < NetSuite::Serializer
        attribute :memo
        attribute :trandate

        references_one :account,
                       serializer: Reference::Serializer, if: :account_present?

        references_one :department,
                       serializer: Reference::Serializer, if: :department_present?

        references_one :currency,
                       serializer: Reference::Serializer, if: :currency_present?

        references_one :entity,
                       serializer: Reference::Serializer

        references_many 'expense.items',
                        resource_attribute: :line_items,
                        serializer: CheckLineItem::Serializer

        def account_present?(args = {})
          resource = args.fetch(:resource)

          resource.account.present?
        end

        def department_present?(args = {})
          resource = args.fetch(:resource)

          resource.department.present?
        end

        def currency_present?(args = {})
          resource = args.fetch(:resource)

          resource.currency.present?
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ledger_sync-netsuite-0.7.1 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.6.2 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.6.1 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.6.0 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.5.0 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.4.2 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.6 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.5 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.4 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.3 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.2 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.1 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.3.0 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.2.0 lib/ledger_sync/netsuite/check/serializer.rb
ledger_sync-netsuite-0.1.1 lib/ledger_sync/netsuite/check/serializer.rb