wimverstuyf / php-coda-parser

PHP parser for Belgian CODA banking files
GNU Lesser General Public License v3.0
42 stars 25 forks source link

Grouped transactions with single transaction parsed twice #31

Open Douglasdc3 opened 3 months ago

Douglasdc3 commented 3 months ago

When using grouped transactions we notice the globalizationCode is set to 1 where the group starts and set to 1 when group ends this is also described in the febelfin docs

Globalisation code Marks the beginning and end of a globalisation for each hierarchy level.

This means when you have multiple transactions the group record has code 1 all transactions in between have code 0 the last transaction of the code has code 1 again.

When you have a grouped transaction with only one transaction the first group record has code 1 and the first transaction (and thus last) record has code 1.

This then results in statement transactions returning 2 transactions instead of returning 1 transaction. This bug was introduced in v2.5 up to v2.4 the output only contained 1 transaction. To demonstrate the bug see referenced PR

astalpaert commented 2 months ago

@wimverstuyf Any chance you could have a look at this please? Thanks in advance!

wimverstuyf commented 2 weeks ago

Sorry for the late response.

This seems to be "interesting" as it does not respond to another way of globalization (see unit test sample7.cod). In this other case the globalization code marks the beginning of the globalization with the next transactions getting a "zero" globalization-code and no globalization code at the end.

The parser is written for this other case but fails for this "different" usage of the globalization code. The documentation does state a globalization code should come at the end but it doesn't really state how (new final record or last detail record) and I hadn't seen this before.

At the moment it is not clear how to support both usages at the same time (as they contradict each other). Do you have an example where this globalization is used for multiple transactions (in the example in PR #32 the globalization only has one detail transaction). This might make clear how it differentiates from the other usage.