Sha256: 33895def1a277ab20b6514360231cb6a095902c91c48bf590c4372ab3c00f1ac

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative '../reference/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

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-1.4.0 lib/ledger_sync/ledgers/netsuite/check/serializer.rb