Generate Bankline CSV import files per https://www.business.rbs.co.uk/content/dam/rbs_co_uk/Business_and_Content/PDFs/Bankline/Bankline-import-file-guide-CSV-RBS.pdf, used e.g. by NatWest.
Not intended to be a complete implementation. We have implemented what we need; feel free to make PRs for further behaviour.
Add any number of payments as described below, then generate the CSV content:
file = BanklineCsvImportFile.new
file.add_domestic_payment(…)
file.add_domestic_payment(…)
file.add_international_payment(…)
file.generate # => "foo,bar,…"
At least with NatWest, it seems that the uploaded file must have a .txt
extension, despite containing CSV.
All these arguments are required unless stated otherwise.
file = BanklineCsvImportFile.new
file.add_domestic_payment(
payer_sort_code: "151000",
payer_account_number: "31806542",
amount: "123.45", # Strings and BigDecimal are allowed. (Floats are not advisable for money.) Rounded to 2 decimals.
payment_date: Date.new(2018, 1, 1), # See note below.
beneficiary_sort_code: "151000",
beneficiary_account_number: "44298801",
beneficiary_name: "John Doe", # Truncated to a max length of 35.
beneficiary_reference: "Invoice 123", # Truncated to a max length of 18.
)
file.generate # => "foo,bar,…"
Currency is assumed to be GBP.
Texts are converted to UPPERCASE and characters other than A-Z, 0-9, space and .-/& are automatically removed from free-text values.
Sort codes and account numbers are automatically normalised to the expected format.
Bankline says this about the payment date:
Date payment to arrive (credit date)
Identifies the date on which the funds are to be received by the beneficiary bank. Although not guaranteed this will normally be the same date on which the funds will be made available to the beneficiary.
All these arguments are required unless stated otherwise.
file = BanklineCsvImportFile.new
file.add_international_payment(
payer_sort_code: "151000",
payer_account_number: "31806542",
amount: "123.45", # Strings and BigDecimal are allowed. (Floats are not advisable for money.)
payment_date: Date.new(2018, 1, 1), # See note below.
beneficiary_bic: "SPKHDE2H",
beneficiary_iban: "DE53250501800039370089",
beneficiary_name: "John Doe",
beneficiary_reference: "Invoice 123", # Optional. Truncated to 35 chars per line and max 4 lines.
# Optional but recommended, see below. Truncated to 35 chars per line and max 3 lines.
beneficiary_address: "10 Foo Street\nBartown, Baz County\nABC 123"
)
file.generate # => "foo,bar,…"
Currency is assumed to be GBP.
Characters other than a-z, A-Z, 0-9, space and .-/?:(),+' are automatically removed from free-text values.
Sort codes, account numbers, IBAN and BIC are automatically normalised to the expected format.
Bankline says this about the payment date:
Execution date
Identifies the date on which the payment is to be initiated.
Bankline says this about the beneficiary address:
We strongly recommend providing a beneficiary address as this is mandatory for certain destination countries and failure to populate this may cause the payment to be delayed or even rejected by the receiving bank.
Not currently supported. Pull requests welcome! The documentation is great and this codebase is tiny – you can do it! 💪
Add this line to your application's Gemfile:
gem "bankline_csv_import_file"
And then execute:
$ bundle
Or install it yourself as:
$ gem install bankline_csv_import_file
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
The gem is available as open source under the terms of the MIT License.