class Ach::BatchHeaderRecord

Attributes

ach_file_id[RW]
batch_number[RW]
call_encode[RW]
company_desc_date[RW]
company_descriptive_date[RW]
company_discretionary_data[RW]
company_entry_desc[RW]
company_entry_description[RW]
company_id[RW]
company_name[RW]
effective_entry_date[RW]
originator_status_code[RW]
record_type[RW]
routing_number[RW]
sec_code[RW]
service_class_code[RW]
settlement_date[RW]

Public Class Methods

decode(record,processor) click to toggle source
# File lib/ach/creator.rb, line 258
def self.decode(record,processor)
  batch_header = CustomOrderedHash.new
  batch_header.insert(:record_type,record[0].chr)
  batch_header.insert(:@service_class_code,record[1,3])
  batch_header.insert(:company_name,record[4,16])
  batch_header.insert(:company_disc_data,record[20,20])
  batch_header.insert(:company_id,record[40,10])
  batch_header.insert(:sec_code,record[50,3])
  batch_header.insert(:company_entry_desc,record[53,10])
  batch_header.insert(:company_desc_date,record[63,6])
  batch_header.insert(:posting_date, record[69,6])
  batch_header.insert(:settlement_date,record[75,3])
  batch_header.insert(:originator_status_code,record[78,1])
  batch_header.insert(:routing_number,record[79,8])
  batch_header.insert(:batch_number,record[87,7])
  processor.process(batch_header)
end
new(options={}) click to toggle source
# File lib/ach/creator.rb, line 240
def initialize(options={})
  @record_type = options[:record_type]
  @service_class_code = options[:service_class_code]
  @company_name = options[:company_name]
  @company_discretionary_data = options[:company_discretionary_data]
  @company_id = options[:company_id]
  @sec_code = options[:standard_entry_class_code]
  @company_entry_desc = options[:company_entry_description]
  @company_desc_date = options[:company_descriptive_date]
  @posting_date = options[:effective_entry_date]
  @batch_number = options[:batch_number]
  @originator_status_code = options[:originator_status_code]
  @wellsfargo_routing_number = options[:wellsfargo_routing_number]
  @ach_file_id = options[:ach_file_id]
  @write_to_file = options[:write_to_file]
  @call_encode = encode
end

Protected Instance Methods

encode() click to toggle source
# File lib/ach/creator.rb, line 278
def encode
  begin
    file = @record_type
    file << @service_class_code
    file << @company_name.ljust(16)
    file << (@company_discretionary_data ? @company_discretionary_data.ljust(20) : "".ljust(20))
    file << @company_id.to_s.ljust(10)
    file << @sec_code.upcase.ljust(3)
    file << @company_entry_desc.ljust(10)
    file << (@company_desc_date ? @company_desc_date.ljust(6) : "".ljust(6))
    # file << (Date.today-1).strftime("%m%d%y").ljust(6)                       # Company Descriptive Date
    if @posting_date.is_a?(String)
      file << Date.parse(@posting_date).strftime("%y%m%d").to_s.ljust(6)
    else
      file << @posting_date.strftime("%y%m%d").to_s.ljust(6)
    end
    file << "".ljust(3)                                                 # Settlement date - leave blank
    file << @originator_status_code.to_s.ljust(1)
    file << @wellsfargo_routing_number.to_s.ljust(8)
    @batch_number = "0000000000000"+@batch_number.to_s
    file << @batch_number[-7,7] #added one number and minus from batch num digit count
    Ach::Creator.write_header(file,@write_to_file)
    # batch_header_entry.reload
    # return batch_header_entry.id
  rescue Exception => ex
    puts "Exception while writing ach file -- #{ex.class} #{ex.message} #{ex.backtrace.pp_s}"
  end
end