This is a simple gem to parse Nigerian bank statements of all formats. If your bank and/or file format is not supported, consider reading the contribute wiki and submitting a pull request.
Because not everyone develops in rails, we created a public API to use the gem at http://bank-parser.devcenter.co/parse. The parameters are (bank_key, file_path, password). Read the Usage section for more information
http://bank-parser.devcenter.co/parse(bank_key, file_path, password)
Add this line to your application's Gemfile:
gem 'ng-bank-parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ng-bank-parser
Using the gem is pretty straightforward and simple.
result = NgBankParser::Router.parse(bank_key, file_path, password)
bank_name
is the name key of the bank that statement is from. There's a list of supported banks and formats below.
file_path
is obviously where the file you're trying to parse exists.
password
(optional) it's only required when the file you want to parse is password protected.
result
is a hash that contains all the information you need from your statment.
result = {
status: 1,
data: {
bank_name: the_bank_name,
account_number: the_account_number,
account_name: the_account_name,
from_date: first_transaction_date,
to_date: last_transaction_date,
transactions: an_array_of_transaction_hashes
}
}
:status
can either be 1 or 0. 1 for when the parsing is succesful and 0 for when it's not. A status of 0 is accompanied with an error message that aims to clarify why it could not parse the file.
result = {
status: 0,
message: "RELEVANT ERROR MESSAGE"
}
Furthermore, :transactions
in the result
hash is an array of hashes. Below is an example of a transaction hash
transaction = {
date: transaction_date,
amount: transaction_amount,
type: debit_or_credit,
balance: balance_after_transaction,
remarks: remarks,
ref: reference_id, # as provided by the statment
}
United Bank for Africa:
- key: uba
- supported formats: pdf
Guaranty Trust Bank:
- key: gtb
- supported formats: xls, xlsx
First Bank:
- key: firstbank
- supported formats: pdf
Documentation on contribution can be found in the contribution wiki
The gem is available as open source under the terms of the MIT License.