Sha256: d25e9f2dac6b2514b229fdc3f623bfab1f0eff056c63c547c605d0e3d8ae0067

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module ACH
  module Record
    # A subclass of ACH::Record::Base, an Entry appears in an ACH::Batch
    # component. It is the main record for representing a particular
    # transaction.
    #
    # == Fields
    #
    # * record_type
    # * transaction_code
    # * routing_number
    # * bank_account
    # * amount
    # * customer_acct
    # * customer_name
    # * transaction_type
    # * addenda
    # * bank_15
    class Entry < Base
      # List of digits that Credit transaction code should start from.
      CREDIT_TRANSACTION_CODE_ENDING_DIGITS = ('0'..'4').to_a.freeze

      fields :record_type,
        :transaction_code,
        :routing_number,
        :bank_account,
        :amount,
        :customer_acct,
        :customer_name,
        :transaction_type,
        :addenda,
        :bank_15

      defaults :record_type => BATCH_ENTRY_RECORD_TYPE,
        :transaction_code   => 27,
        :transaction_type   => 'S',
        :customer_acct      => '',
        :addenda            => 0,
        :bank_15            => ''

      # Return +true+ if +self+ is not a credit record.
      #
      # @return [Boolean]
      def debit?
        !credit?
      end

      # Return +true+ if the second digit of a value of the +transaction_code+ field
      # is one of +CREDIT_TRANSACTION_CODE_ENDING_DIGITS+.
      #
      # @return [Boolean]
      def credit?
        CREDIT_TRANSACTION_CODE_ENDING_DIGITS.include? transaction_code.to_s[1..1]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ach_builder-0.2.2 lib/ach/record/entry.rb