GithubHelp home page GithubHelp logo

ach's Introduction

ACH

Note: I'm no longer actively maintaining this gem, and would be happy to turn it over to someone else. Let me know if you'd like to take over.

Build Status

ach is a Ruby helper for builder ACH files. In particular, it helps with field order and alignment, and adds padding lines to end of file.

This library has only been used in two production applications and for very limited purposes. Please test thoroughly before using in a production environment.

See ACH::Builder for a similar Perl library

Example

You should consult a copy of the ACH Rules for details on individual fields. You can probably obtain a copy from your bank.

require 'ach'

# Create ACH file
ach = ACH::ACHFile.new
trace_number = 0

# File Header
fh = ach.header
fh.immediate_destination = '000000000'
fh.immediate_destination_name = 'BANK NAME'
fh.immediate_origin = '000000000'
fh.immediate_origin_name = 'BANK NAME'
# Optional - This value is used in the File Creation Date/Time attributes - if excluded will default to Time.now
# Note that you may wish to modify the time zone here if your environment has a different time zone than the banks
# For example if your server is in UTC and the bank's is in US/Eastern, any files sent after 8pm Eastern/Midnight UTC
#   would have a File Creation Date of the next day from the bank's perspective
fh.transmission_datetime = Time.now

# Batch
batch = ACH::Batch.new
bh = batch.header
bh.company_name = 'Company Name'
bh.company_identification = '123456789' # Use 10 characters if you're not using an EIN
bh.standard_entry_class_code = 'PPD'
bh.company_entry_description = 'DESCRIPTION'
bh.company_descriptive_date = Date.today # Or string with 'SDHHMM' for same day ACH
bh.effective_entry_date = ACH::NextFederalReserveEffectiveDate.new(Date.today).result
bh.originating_dfi_identification = '00000000'
ach.batches << batch

# Detail Entry
ed = ACH::EntryDetail.new
ed.transaction_code = ACH::CHECKING_CREDIT
ed.routing_number = '000000000'
ed.account_number = '00000000000'
ed.amount = 100 # In cents
ed.individual_id_number = 'Employee Name'
ed.individual_name = 'Employee Name'
ed.originating_dfi_identification = '00000000'
batch.entries << ed
# ... Additional detail entries, possibly including *offsetting entry*, if needed.

# Insert trace numbers
batch.entries.each.with_index(1) { |entry, index| entry.trace_number = index }


File.write('ach.txt', ach.to_s)

p ach.report
# Parse an ACH file
ach = ACH::ACHFile.new(File.read('examples/ach/fixtures/return_noc.txt'))
ach.batches.first.entries.first.addenda.first.payment_data
=> "C05992222220280489      1211403932                                          1211"

Note: When adding an amount to your ach file, it needs to be in cents. So you'll want to multiply any dollar amounts by 100

Copyright

Copyright (c) 2008-2009 Jared E Morgan, released under the MIT license

ach's People

Contributors

antstorm avatar aripollak avatar barmstrong avatar binarypaladin avatar bthews avatar chubchenko avatar destinf avatar hassenfratzk avatar henriquegasques avatar jcbantuelle avatar jm81 avatar jodell avatar joshpuetz avatar mhoffmeyer avatar phlipper avatar rawsyntax avatar samgranieri avatar sumahiremath avatar terryjray avatar tubergen avatar zackperdue avatar zcotter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.