wolph / mt940

A library to parse MT940 files and returns smart Python collections for statistics and manipulation.
https://mt940.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
94 stars 50 forks source link

Non-numeric statement number #92

Closed not7cd closed 1 year ago

not7cd commented 2 years ago

Hi, I encountered error while parsing statements from polish bank.

RuntimeError: ("Unable to parse <mt940.tags.StatementNumber object at 0x7f359f603730> from '09/2021/M'", <mt940.tags.StatementNumber object at 0x7f359f603730>, '09/2021/M')

It seems that they are also inconsistent with their own spec which says that StatementNumber follows this pattern

:28C:0668-2019/BPL

While actual data privdes this

:28C:09/2021/M

Can I somehow bypass this, or maybe define my own tag parsers?

wolph commented 2 years ago

That's an odd format indeed. With regards to fixing it, I can think of two options:

  1. Use a pre-processor to convert the value into something the parser can handle
  2. Monkeypatch tags.StatementNumber.pattern so it matches this data

The pre-processor is the cleaner solution, but I think patching the pattern might be an easier solution here.

not7cd commented 5 months ago

This issue has bitten me again. How can I monkey patch this?