Aba
Generates ABA (Australian Banking Association) file format output
Usage
require 'aba'
aba = Aba.batch(
bsb: "123-345",
financial_institution: "WPC",
user_name: "John Doe",
user_id: "466364",
description: "Payroll",
process_at: Time.now.strftime("%d%m%y")
)
10.times do
aba.add_transaction(
{
bsb: "342-342",
account_number: "3244654",
amount: 10000,
account_name: "John Doe",
transaction_code: 53,
lodgement_reference: "R435564",
trace_bsb: "453-543",
trace_account_number: "45656733",
name_of_remitter: "Remitter"
}
)
end
10.times do
aba.add_return(
{
bsb: '453-543',
account_number: '45656733',
amount: 10000,
account_name: 'John Doe',
transaction_code: 53,
lodgement_reference: 'R435564',
trace_bsb: '342-342',
trace_account_number: '3244654',
name_of_remitter: 'Remitter',
return_code: 8,
original_user_id: 654321,
original_processing_day: 12,
}
)
end
puts aba.to_s
File.write("/Users/me/dd_#{Time.now.to_i}.aba", aba.to_s)
There are a few ways to create a complete set of ABA data:
aba = Aba.batch financial_institution: 'ANZ', user_name: 'Joe Blow', user_id: 123456, process_at: 200615
aba.add_transaction bsb: '123-456', account_number: '000-123-456', amount: 50000, transaction_code: 50
aba.add_transaction bsb: '456-789', account_number: '123-456-789', amount: 10000, transaction_code: 13
aba = Aba.batch financial_institution: 'ANZ', user_name: 'Joe Blow', user_id: 123456, process_at: 200615 do |a|
a.add_transaction bsb: '123-456', account_number: '000-123-456', amount: 50000, transaction_code: 50
a.add_transaction bsb: '456-789', account_number: '123-456-789', amount: 10000, transaction_code: 13
end
aba = Aba.batch(
{ financial_institution: 'ANZ', user_name: 'Joe Blow', user_id: 123456, process_at: 200615 },
[
{ bsb: '123-456', account_number: '000-123-456', amount: 50000, transaction_code: 50 },
{ bsb: '456-789', account_number: '123-456-789', amount: 10000, transaction_code: 13 }
]
)
Note: Positive (n
) and negative (-n
) values are now treated the same.
e.g 5
and -5
are both processed as 5
, without any signage.
To differentiate between a debit and credit, use the correct Transaction Code
Validation errors can be caught in several ways:
aba = Aba.batch(
financial_institution: "ANZ",
user_name: "Jøhn Doe",
user_id: "123456",
process_at: Time.now.strftime("%d%m%y")
)
aba.add_transaction(
bsb: "abc-123",
account_number: "000123456"
)
aba.valid?
puts aba.errors
Validation errors will stop parsing of the data to an ABA formatted string using
to_s
. aba.to_s
will raise a RuntimeError
instead of returning output.
Installation
Add this line to your application's Gemfile:
gem 'aba'
And then execute:
$ bundle
Or install it yourself as:
$ gem install aba
Contributing
- Fork it ( https://github.com/[my-github-username]/aba/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request