class Ach::FileControlRecord

Attributes

batch_count[RW]
block_count[RW]
entry_addenda[RW]
entry_hash_total[RW]
record_type[RW]
total_credits[RW]
total_debits[RW]

Public Class Methods

decode(record,processor) click to toggle source
# File lib/ach/creator.rb, line 448
def self.decode(record,processor)
  file_control = CustomOrderedHash.new
  file_control.insert(:record_type,record[0].chr)
  file_control.insert(:batch_count, record[1,6])
  file_control.insert(:block_count, record[7,6])
  file_control.insert(:entry_addenda, record[13,8])
  file_control.insert(:entry_hash_total, record[21,10])
  file_control.insert(:total_debits, record[31,12])
  file_control.insert(:total_credits, record[43,12])
  processor.process(file_control)
end
new(options={}) click to toggle source
# File lib/ach/creator.rb, line 436
def initialize(options={})
  @record_type = '9'
  @batch_count = options[:batch_count]
  @block_count = options[:block_count]
  @entry_addenda = options[:entry_addenda]
  @entry_hash_total = options[:entry_hash_total]
  @total_debits = options[:total_debits]
  @total_credits = options[:total_credits]
  @write_to_file = options[:write_to_file]
  encode
end

Protected Instance Methods

encode() click to toggle source
# File lib/ach/creator.rb, line 462
def encode
  begin
    file = @record_type
    file << @batch_count.to_s.rjust(6,"0")
    file << @block_count.to_s.rjust(6,"0")
    file << @entry_addenda.to_s.rjust(8,"0")
    @entry_hash_total_digit_count = @entry_hash_total.to_s.split(//)
    if @entry_hash_total_digit_count.size >= 10
      file << @entry_hash_total.to_s.slice(1..10).rjust(10,"0")
    else
      file << @entry_hash_total.to_s.slice(0..10).rjust(10,"0")
    end
    file << @total_debits.rjust(12,"0")
    file << @total_credits.rjust(12,"0")
    file << "".ljust(39)
    Ach::Creator.write_header(file,@write_to_file)
  rescue Exception => ex
    puts "\n Exception writing ACH file -- #{ex}"
  end
end