Skip to main content

OFXStatement plugin for financial institutions providing MT940 statements.

Project description

ofxstatement-mt940

This project provides a custom ofxstatement plugin for financial institutions providing MT940 statements.

ofxstatement is a tool to convert a proprietary bank statement to OFX format, suitable for importing into programs like GnuCash or Beancount. The plugin for ofxstatement parses the bank statement and produces a common data structure, that is then formatted into an OFX file.

See also the MT940 project. Without that project this plugin would not have been possible.

Installation

Using pip

$ pip install ofxstatement-mt940

Development version from source

$ git clone https://github.com/gpaulissen/ofxstatement-mt940.git
$ pip install -e .

Troubleshooting

This package depends on ofxstatement with a version at least 0.6.5. This version may not yet be available in PyPI so install that from source like this:

$ git clone https://github.com/gpaulissen/ofxstatement.git
$ pip install -e .

Test

To run the tests from the development version you can use the py.test command:

$ py.test

You may need to install the required test packages first:

$ pip install -r test_requirements.txt

Usage

Show installed plugins

This shows the all installed plugins, not only those from this package:

$ ofxstatement list-plugins

You should see at least:

The following plugins are available:

  ...
  mt940            MT940, text
  ...

Convert

This will convert a mt940 file to an OFX file.

$ ofxstatement convert -t mt940 mt940.txt mt940.ofx

Configuration

The ASN bank from the Netherlands is the default. If you want a different bank code and/or bank id you need to define it in the ofxstatement configuration:

$ ofxstatement edit-config

This is a sample configuration (do not forget to specify plugin for each section):

[ing:nl]
plugin = mt940
bank_id = myingbankid

[mBank]
plugin = mt940
bank_code = mBank

[asnb]
plugin = mt940
bank_code = ASNB
bank_id = myasnbbankid

Bank codes and their bank id

These are the predefined bank codes (case insensitive) and their corresponding bank id's (tag BANKID) in the OFX file:

Bank code Bank id Comment
ASN ASNBNL21 Dutch bank with special processing instructions for MT940 tag 61, see test_tags.py
ABNAMRO ABNANL2A Dutch bank
ING INGBNL2A Dutch bank
KNAB KNABNL2H Dutch bank
RABO RABONL2U Dutch bank
SNS SNSBNL2A Dutch bank
TRIODOS TRIONL2U Dutch bank
MBANK BREXPLPW Polish bank with special post processing instructions, see test_processors.py.


Please note that this list is not exhaustive and you can process a MT940 from any bank. Just define a bank code from this list above or else your own bank id in the ofxstatement configuration.

From the MT940 project I have copied the special processing instructions for the banks tested there, thus ASN and MBANK. Other banks do not seem to need special instructions to parse their MT940 file.

Other configuration options

In certain situations you may get this error from your bank document download:

The statement end date (2020-09-02) should be greater than the largest statement line date (2020-09-03)

In that case the MT940 Closing Balance(tag 62) or Finale Closing Balance (tag 62F) has a date before the latest Statement Line (tag 61) date. You can set the statement end date to the highest of the (Final) Closing Balance date and latest Statement Line (tag 61) date by setting end_date_derived_from_statements to true.

The default is false, i.e. use only tag 62 or 62F.

[asnb]
plugin = mt940
bank_code = ASNB
bank_id = myasnbbankid
end_date_derived_from_statements = true

Advanced conversions (using the configuration)

This will generate an OFX to standard output with "myingbankid" for OFX tag BANKID:

$ ofxstatement convert -t ing:nl src/ofxstatement/plugins/tests/samples/ing.sta -

And this will generate an OFX to standard output with "BREXPLPW" for OFX tag BANKID:

$ ofxstatement convert -t mBank src/ofxstatement/plugins/tests/samples/mt940_mBank.txt -

Finally this will use the special instructions for ASNB but use "myasnbbankid" for OFX tag BANKID:

$ ofxstatement convert -t asnb src/ofxstatement/plugins/tests/samples/mt940_ASNB.txt -

Change history

See the Changelog (CHANGELOG.md).

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

[1.3.1] - 2022-01-05

Added

  • Reviewed and added test requirements

[1.3.0] - 2020-09-06

Changed

  • Replaced ignore_check_end_date configuration option by end_date_derived_from_statements

[1.2.0] - 2020-09-06

Added

  • Added ignore_check_end_date configuration option

Changed

  • Improved code quality by using pycodestyle and Python typing module

[1.1.0] - 2020-03-26

Added

  • Added reference to the Changelog in the Readme.
  • The Readme mentions test_requirements.txt for installing test modules.
  • More checks concerning the content (dates with start and end date exclusive) that may result in a ValidationError exception.
  • Added GNU Makefile for keeping the important operations together.
  • MANIFEST.in now includes the Makefile and CHANGELOG.md.

Changed

  • The generation af a unique OFX id did only return a counter in case of duplicates.
  • The Readme mentions now my fork of the ofxstatement instead of https://github.com/kedder/ofxstatement.git.
  • The about.py file outputs the version number and that is used in the Makefile.
  • Code refactoring.
  • Readme enhanced.

[1.0.0] - 2020-03-15

Added

  • First version to convert a Swift MT940 file to an OFX file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ofxstatement-mt940-1.3.1.tar.gz (10.5 kB view hashes)

Uploaded Source

Built Distribution

ofxstatement_mt940-1.3.1-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page