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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file ofxstatement-mt940-1.3.1.tar.gz.

File metadata

  • Download URL: ofxstatement-mt940-1.3.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ofxstatement-mt940-1.3.1.tar.gz
Algorithm Hash digest
SHA256 988a0fdd9436651c0cf60bef4143410f74a5c5c1528ffad3d6a035664aad6c11
MD5 758661900d6961972b2f8b0c4a7a0850
BLAKE2b-256 a6fa5fa10cd701b33e3a696c854e609e9f47947e8d52e263e2b2b656161bf49b

See more details on using hashes here.

File details

Details for the file ofxstatement_mt940-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: ofxstatement_mt940-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ofxstatement_mt940-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd85e4fe5ca09484f43e682691d705c27f18d8c375552c31c80878ffa663f6c7
MD5 fafdf782704972761ff1c5c381abba75
BLAKE2b-256 47e0a6c7b0542e363ebec2227a9c44195313a011fd11f154e8c12f3bf907ca23

See more details on using hashes here.

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