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 ⇒ Fixnum
Returns total amount of entry and addenda records within batch.
-
#entry_hash ⇒ Fixnum
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 ⇒ Array<ACH::Record::Base>
Returns ACH record objects that represent the batch.
-
#total_credit_amount ⇒ Fixnum
Returns total amount of all ‘credit’ entries within a batch.
-
#total_debit_amount ⇒ Fixnum
Returns total amount of all ‘debit’ entries within a batch.
Instance Method Details
#entry_addenda_count ⇒ Fixnum
Returns total amount of entry and addenda records within batch.
22 23 24 |
# File 'lib/ach/batch/builder.rb', line 22 def entry_addenda_count entries.size + addendas.values.flatten.size end |
#entry_hash ⇒ Fixnum
Returns ‘hashed’ representation of all entries within batch. See NACHA documentation for more details on entry hash.
30 31 32 |
# File 'lib/ach/batch/builder.rb', line 30 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.
8 9 10 |
# File 'lib/ach/batch/builder.rb', line 8 def has_credit? entries.any?(&:credit?) end |
#has_debit? ⇒ Boolean
Returns true
if any internal ACH entry has ‘debit’ transaction code.
15 16 17 |
# File 'lib/ach/batch/builder.rb', line 15 def has_debit? entries.any?(&:debit?) end |
#to_ach ⇒ Array<ACH::Record::Base>
Returns ACH record objects that represent the batch.
51 52 53 |
# File 'lib/ach/batch/builder.rb', line 51 def to_ach [header] + fetch_entries + [control] end |
#total_credit_amount ⇒ Fixnum
Returns total amount of all ‘credit’ entries within a batch.
44 45 46 |
# File 'lib/ach/batch/builder.rb', line 44 def total_credit_amount amount_sum_for(:credit?) end |
#total_debit_amount ⇒ Fixnum
Returns total amount of all ‘debit’ entries within a batch.
37 38 39 |
# File 'lib/ach/batch/builder.rb', line 37 def total_debit_amount amount_sum_for(:debit?) end |