Sha256: 5579375f1b837e188f4b0272f8cf5493b610bf29c5424120120765985482b02d

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ledger_sync-1.6.0 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/netsuite/check/serializer.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/netsuite/check/serializer.rb