Module: ACH::Batch::Builder
- Included in:
- ACH::Batch
- Defined in:
- lib/ach/batch/builder.rb
Overview
Supports building a string representation of a particular instance of an ACH batch. Supports building ACH lines. Included by ACH::File.
Instance Method Summary collapse
-
#entry_addenda_count ⇒ Object
Returns total amount of entry and addenda records within batch.
-
#entry_hash ⇒ Object
Returns ‘hashed’ representation of all entries within batch.
-
#has_credit? ⇒ Boolean
Returns
true
if any of internal ACH entries has ‘credit’ transaction code. -
#has_debit? ⇒ Boolean
Returns
true
if any internal ACH entry has ‘debit’ transaction code. -
#to_ach ⇒ Object
Returns ACH record objects that represent the batch.
-
#total_credit_amount ⇒ Object
Returns total amount of all ‘credit’ entries within a batch.
-
#total_debit_amount ⇒ Object
Returns total amount of all ‘debit’ entries within a batch.
Instance Method Details
#entry_addenda_count ⇒ Object
Returns total amount of entry and addenda records within batch
16 17 18 |
# File 'lib/ach/batch/builder.rb', line 16 def entry_addenda_count entries.size + addendas.values.flatten.size end |
#entry_hash ⇒ Object
Returns ‘hashed’ representation of all entries within batch. See NACHA documentation for more details on entry hash
22 23 24 |
# File 'lib/ach/batch/builder.rb', line 22 def entry_hash entries.map{ |entry| entry.routing_number.to_i / 10 }.compact.inject(&:+) end |
#has_credit? ⇒ Boolean
Returns true
if any of internal ACH entries has ‘credit’ transaction code
6 7 8 |
# File 'lib/ach/batch/builder.rb', line 6 def has_credit? entries.any?(&:credit?) end |
#has_debit? ⇒ Boolean
Returns true
if any internal ACH entry has ‘debit’ transaction code
11 12 13 |
# File 'lib/ach/batch/builder.rb', line 11 def has_debit? entries.any?(&:debit?) end |
#to_ach ⇒ Object
Returns ACH record objects that represent the batch
37 38 39 |
# File 'lib/ach/batch/builder.rb', line 37 def to_ach [header] + fetch_entries + [control] end |
#total_credit_amount ⇒ Object
Returns total amount of all ‘credit’ entries within a batch
32 33 34 |
# File 'lib/ach/batch/builder.rb', line 32 def total_credit_amount amount_sum_for(:credit?) end |
#total_debit_amount ⇒ Object
Returns total amount of all ‘debit’ entries within a batch
27 28 29 |
# File 'lib/ach/batch/builder.rb', line 27 def total_debit_amount amount_sum_for(:debit?) end |