wimverstuyf / php-coda-parser

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

Bad results when transaction concerns credit repayment (tested with KBC coda) #10

Closed tix02be closed 6 years ago

tix02be commented 6 years ago

Hello,

I use your parser for an app used in intern and I found a bug when a transaction is regarding a credit repayment operation (in my case VISA or simple Bank credit). It appears that the parser returns many "21" operations (which is ok regarding CODA specs at https://www.febelfin.be/sites/default/files/Standard-CODA-2.3-FR.pdf), but when parsed, only the last operation "21" is returned when the first was expected (the one with "sequence_number_detail" prop == 0000).

To fix that in my app I simply added a condition in Parser.php before the line 156, so the code looks like this: if( $coda_line->sequence_number_detail == '0000' ) $current_account_transaction->transactions[$trans_idx]->{'line'.$coda_line->record_code.$coda_line->article_code} = $coda_line;

Don't know if all coda transactions will work with this "fix" but in my case that does the job.

Thanks for the great work !

wimverstuyf commented 6 years ago

Thx for the feedback. I'll check if the fix can be applied. If you have an example file you can share where the issue pops up that would be great.

tix02be commented 6 years ago

Hi Wim,

Here is a file you can test with.

Réception CODA.2017-10-30.txt

The file contains only one transaction: a credit repayment. As you see if you var_dump($coda_line) in Parser::convertToRaw, you'll get 3 lines "21" for this transaction.

Thank you !

wimverstuyf commented 6 years ago

Bug has been fixed in master.