wimverstuyf / php-coda-parser

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

CODA with totalized transactions including detail transactions incorrectly parsed #29

Open driesraman opened 4 days ago

driesraman commented 4 days ago

Hi,

I have encountered an issue with the library when handling grouped transactions with a totalized amount for (SEPA-)transactions (Transaction code in record 21 starting with "1" - Amount as totalized by the customer - $transactionPart1Line->getTransactionCode()->getType()->getValue() === '1') but followed by detailed transactions (Transaction code in record 21 starting with "5" - detail lines - $transactionPart1Line->getTransactionCode()->getType()->getValue() === '5').

When processing such transactions, all detailed information and the grouped transaction are treated as a single transaction. As a result, the detailed information is concatenated into one transaction, causing the loss of individual transaction details. This also results in incorrect transaction information, like the (structured-)message, which contains concatenated information from all transactions.

Below is an example of a CODA file that demonstrates this issue (also attached as "KBC-coda-issue.txt"):

0000006062472505        00265207  BOUWBEDRIJF VOOR GROTE WERKREDBEBB   00330158420 00000                                       2
10158138536152215 EUR0BE                  0000000000100000050624BOUWBEDRIJF VOOR GROTE WERKBC-Bedrijfsrekening               158
2100010000BANK-REF-AAAAAAAAAAAA0000000001000000060624105500000                                                     06062415811 0
2200010000                                                     REF-RECUR-06-05                                               0 0
2100010001BANK-REF-BBBBBBBBBBBB0000000000250000060624505500001127060624120BBE2ZZZ3215646432                  SEPA-006062415801 0
220001000100000001                     243690000141            243690000141                       KREDBEBB           SUPP    1 0
23000100010BE22313215646432                    KLANT1 MET NAAM1                                                         0    0 1
3100010002BANK-REF-BBBBBBBBBBBB505500001001KLANT1 MET NAAM1                                                                  1 0
3200010002GROTE WEG            32            3215    HASSELT                                                                 0 0
2100010003BANK-REF-CCCCCCCCCCCC0000000000750000060624505500001127060624120BE25ZZZ548413215                   SEPA-006062415801 0
22000100030000002                      243690000142            243690000142                       KREDBEBB           SUPP    1 0
2300010003BE25646548413215                     KLANT2 MET NAAM2                                                         0    0 1
3100010004BANK-REF-CCCCCCCCCCCC505500001001KLANT2 MET NAAM2                                                                  1 0
3200010004OETGANGERSTRAAT 26                1215        ANTWERPEN                                                            0 0
8158138536152215 EUR0BE                  0000000001100000060624                                                                0
9               000014000000000000000000000001000000                                                                           2

parsed_coda

Wouldn't the expected behavior be to ignore the grouped line ($transactionPart1Line->getTransactionCode()->getType()->getValue() === '1') if detail lines are available ($transactionPart1Line->getTransactionCode()->getType()->getValue() === '5') in the file and provide the detailed transaction information?

Best regards, Dries

KBC-coda-issue.txt

driesraman commented 3 days ago

Hi,

I have created a pull request with a proposal to address this issue. You can find the PR here: https://github.com/wimverstuyf/php-coda-parser/pull/30.

Please don't hesitate to let me know if you have any remarks or feedback.

Best regards, Dries