Skip to content

A basic parser for sepa files, e.g. camt and pain files

License

Notifications You must be signed in to change notification settings

viafintech/sepa_file_parser

Repository files navigation

SepaFileParser

Ruby CI

SepaFileParser is a Ruby Gem which does some basic parsing of sepa files, such as camt052, camt053, pain001, pain002, and pain008 files into an object structure for easier usability instead of having to use an XML parser all the time. Keep in mind that this might not include a complete parsing of camt specification. Fields that we did not need for our use-cases are simply ignored for now.

Getting started

  1. add the Gem to the Gemfile
gem 'sepa_file_parser'
  1. Require the Gem at any point before using it
  2. Use it!

Example for camt053

camt = SepaFileParser::File.parse path_to_file
puts camt.group_header.creation_date_time
camt.statements.each do |statement|
  puts statement.account.iban
  statement.entries.each do |entry|
    # Access individual entries/bank transfers
    puts entry.amount
    entry.transactions.each do |transaction|
      puts transaction.debitor
    end
  end
end

Please check the code for fields not mentioned here. Also check the code for other file formats.

Registering new namespaces

In case you have to parse a namespace which is generally compatible with any of the camt parsers, it is possible to register additional namespaces, without requiring a change to this gem.

# Registering a new camt052 namespace
SepaFileParser::Xml.register('<your namespace>', :camt052)
# Registering a new camt053 namespace
SepaFileParser::Xml.register('<your namespace>', :camt053)
# Registering a new camt054 namespace
SepaFileParser::Xml.register('<your namespace>', :camt054)
# Registering a new pain001 namespace
SepaFileParser::Xml.register('<your namespace>', :pain001)
# Registering a new pain002 namespace
SepaFileParser::Xml.register('<your namespace>', :pain002)
# Registering a new pain008 namespace
SepaFileParser::Xml.register('<your namespace>', :pain008)

Bugs and Contribution

For bugs and feature requests open an issue on Github. For code contributions fork the repo, make your changes and create a pull request.

License

LICENSE

About

A basic parser for sepa files, e.g. camt and pain files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages