This week we’ve released a ruby gem for parsing Q43 SEPA (Single Euro Payments Area) files1, also known as norma43 in Spain. These files can be downloaded from all the banks that offer their services in Spain territory and includes all the transactions from one or more bank accounts.
A tricky thing that you should know is that all banks use the same standard format but each one may use the defined fields for different information, for example: if you are looking for the transfer details, some banks will use the specified fields and others will use the additional fields.
How to use it
First of all you’ll need to include norma43_parser in your Gemfile.
require "norma43" norma43_file_contents = File.open("path_to_file.n43", encoding: "iso-8859-1") document = norma43.parse norma43_file_contents
The parser returns a Norma43 Document that may include multiple accounts.
The account object has all the information described in the standard format and the transactions between start_date andend_date.
abbreviated_name="ACCOUNT NAME", account_number=1234567, balance_amount=504585, balance_code=2, bank_code=81, branch_code=54, credit_amount=254785, credit_entries=45, currency_code=978, debit_amount=0, debit_entries=0, start_date=Tue, 04 Feb 2016, end_date=Tue, 04 Feb 2016, information_mode_code=3, transactions=[transaction1..transactionN]
The transaction object has all the information described in the standard format and may include a maximum of five additional items.
additional_currency=nil, amount=3206, amount_code=2, document_number=0, origin_branch_code=123, own_item=16, reference_1=0, reference_2=nil, shared_item=4, transaction_date=Tue, 04 Feb 2016, value_date=Tue, 04 Feb 2016, additional_items=[additional_item1..aditional_item5]
The additional item object has an identifier and two free text fields that may include or not relevant information
data_code=1, item_1="TRANSFERENC. ANTONIO JOSE GARCIA MARTI", item_2="NEZ"
We believe in UNIX philosophy Do One Thing and Do It Well2 so we don’t expect to add new file parsing capabilities to the norma43_parser gem, instead it’s possible that we release new gems for parsing or generating the distinct SEPA files definitions once we make sure they are ready to be used in production. We’ve been using it for three months without any problem with most of Spanish banks, said that we’ll take care of all maintenance but pull requests and bug reports are welcome.
Update: Now published on Rubygems!
Finally we would like to send a big shout-out to the Total-IN3 creators and maintainers since this gem was originally forked from it.
- Find SEPA Q43 file definition here
- More information about Do One Thing and Do It Well here
- Total-IN repository here