Class: ACH::Records::EntryDetail

Inherits:
Record
  • Object
show all
Defined in:
lib/ach/records/entry_detail.rb

Overview

PPD Entry Detail. Some other entry details, such as CCD, are close enough to use this class. Version 1.x will have support for other types.

Direct Known Subclasses

BalancingEntryDetail, CtxEntryDetail

Constant Summary collapse

CREDIT_RECORD_TRANSACTION_CODE_ENDING_DIGITS =
["0", "1", "2", "3", "4"]

Constants included from FieldIdentifiers

FieldIdentifiers::ENCODING_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Record

#case_sensitive

Instance Method Summary collapse

Methods inherited from Record

fields

Methods included from FieldIdentifiers

#const_field, #field, #left_justify, #spaceless_routing_field

Constructor Details

#initializeEntryDetail

Returns a new instance of EntryDetail.



37
38
39
# File 'lib/ach/records/entry_detail.rb', line 37

def initialize
  @addenda = []
end

Instance Attribute Details

#addendaObject (readonly)

Returns the value of attribute addenda.



35
36
37
# File 'lib/ach/records/entry_detail.rb', line 35

def addenda
  @addenda
end

#sorterObject

Returns the value of attribute sorter.



9
10
11
# File 'lib/ach/records/entry_detail.rb', line 9

def sorter
  @sorter
end

Instance Method Details

#addenda_records?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ach/records/entry_detail.rb', line 53

def addenda_records?
  return !self.addenda.empty?
end

#amount_valueObject



49
50
51
# File 'lib/ach/records/entry_detail.rb', line 49

def amount_value
  return self.amount
end

#credit?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ach/records/entry_detail.rb', line 41

def credit?
  CREDIT_RECORD_TRANSACTION_CODE_ENDING_DIGITS.include?(@transaction_code[1..1])
end

#debit?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ach/records/entry_detail.rb', line 45

def debit?
  !credit?
end

#records_countInteger

Returns Length of addenda plus 1, used by Batch#entry_count.

Returns:

  • (Integer)

    Length of addenda plus 1, used by Batch#entry_count



71
72
73
# File 'lib/ach/records/entry_detail.rb', line 71

def records_count
  1 + self.addenda.length
end

#to_ach(eol: ACH.eol) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ach/records/entry_detail.rb', line 57

def to_ach eol: ACH.eol
  self.addenda_record_indicator = (self.addenda.empty? ? 0 : 1) if self.respond_to?(:addenda_record_indicator)
  self.number_of_addenda_records = self.addenda.length if self.respond_to?(:number_of_addenda_records)

  ach_string = super

  self.addenda.each {|a|
    a.entry_detail_sequence_number = self.trace_number
    ach_string << eol + a.to_ach
  }
  return ach_string
end