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

Opening Balance #84

Closed mzaanen closed 4 years ago

mzaanen commented 4 years ago

MT_940_opening_balance.swi.txt

First of all: thanks you for the package!

In the documentation it states that: id='60F' ==> FinalOpeningBalance.

In the enclosed file from a Rabo download I see for the first transaction starting at line 32 of the file: :60F:C200203EUR000000013527,84. :61:200201D000000000005,62N093NONREF//00003HI04-02 0000000000 :62F:C200204EUR000000013522,22

I had expected the opening balance to be € 13.527.84 and the closing balance € 13.522,22

However, after running exactly the code shown in https://mt940.readthedocs.io/en/latest/ ==>"Set opening / closing balance information on each transaction:"
I get: {'amount': <-5.62 EUR>, 'available_balance': <<13522.22 EUR> @ 2020-03-01>, 'bank_reference': '00003HI04-02', 'currency': 'EUR', 'customer_reference': 'NONREF', 'date': Date(2020, 2, 1), 'extra_details': '0000000000', 'final_closing_balance': <<13522.22 EUR> @ 2020-03-01>, 'final_opening_balance': <<13522.22 EUR> @ 2020-03-01>,

In summary, the closing balance is in line with my expectations, but not the opening balance.

First of all, is it an issue? Or am I not interpreting things quite correctly?

Thank you for your time,

Kind regards, Maarten Zaanen 06-26118172

wolph commented 4 years ago

The problem here is that the rows are grouped by statement (:61) and the higher balance comes before that.

If that's a problem depends on what you're trying to do.

As it looks now I don't see an easy way of fixing this in a good way. The file seems to include daily balance updates which is something that isn't accounted for at all currently. The library currently assumes everything to be grouped by transaction.

mzaanen commented 4 years ago

Quite. As I interpret the standard:

wolph commented 4 years ago

In that case the regular behavior of the library is actually correct, save for one caveat. It assumes 1 file per set of balances. Extending that behavior to support a multi-file shouldn't be that hard :)

The standard is rather variable per bank though, most banks I've seen simply have a single set of balances. And the ones that have multiple usually have some sort of separator.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.