wimverstuyf / php-coda-parser

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

Issue with parsing multiple 31 lines #8

Closed SanderM2 closed 6 years ago

SanderM2 commented 7 years ago

The coda parser has an issue parsing coda files like these:

2100040000310N019418263001137 0000000017233540310517001500000Europese overschrijving (zie bijlage) 31051710101 0 2200040000 + 17.233,54Van: COMPANY BLABLABLAH BVBA - BE64NOT PROVIDED BBRUBEBB 1 0 2300040000BE34359648312345 EURCOMPANY BLABLABLAH BVBA 363120669252 0 1 3100040001310N019418263001137 001500001001COMPANY BLABLABLAH BVBA 1 0 3200040001STRAATSTREEEEEET 123 1111 PLACE 0 1 3100040002310N019418263001137 001500000Europese overschrijving Van: COMPANY BLABLABLAH BVBA STRAATSTREEEEEET 123 0 1 3100040003310N019418263001137 001500000 1111 PLACE Belgie IBAN: BE34359648312349 0 0

As you can see, it has multiple 31 lines and the coda parser is only outputting the last 31 line. All data in previous 31 lines are missing and in some cases those contain important data in order to link the transaction to a customer.

So, the message with this transaction would only be "1111 PLACE Belgie IBAN: BE34359648312349" while it should be "Europese overschrijving Van: COMPANY BLABLABLAH BVBA STRAATSTREEEEEET 123 1111 PLACE Belgie IBAN: BE34359648312349" ...

For testing purposes I'm now using the "raw" output, and replaced this line in the parser:

$current_account_transaction->transactions[$trans_idx]->{'line'.$coda_line->record_code.$coda_line->article_code} = $coda_line;

with:

$current_account_transaction->transactions[$trans_idx]->{'line'.$coda_line->record_code.$coda_line->article_code.intval($coda_line->sequence_number_detail)} = $coda_line;

THIS IS NOT A FIX! It's just a work around to make it work with the "raw" output so that I can get things done with this coda parser library. It's certainly breaking the "simple" output.

wimverstuyf commented 7 years ago

Thanks for the feedback. I'll check how this can be fixed when I can find some time to work on this. Will possibly have to create a breaking change to fix it.

SanderM2 commented 7 years ago

Any news on this?

wimverstuyf-attentia commented 7 years ago

Sorry, still didn't find time to work on this.

elyounssi commented 6 years ago

Any updates on this ?

wimverstuyf commented 6 years ago

Sorry, I still didn't look into this.

kouinkouin commented 6 years ago

I forked the repo to treat (as I could) the multiple payments (1 transaction which contains many transactions). In the few weeks, I will probably have to continue it to perform the result of the parsing of the CODA file.

Have you example of entire CODA files, with expected result to help me ?

wimverstuyf commented 6 years ago

Great! You can find an example of the contents of a CODA-file in the unit tests (tests/ParserTest.php).

SanderM2 commented 6 years ago

kouinkouin I have tested your fork and it does work better but I still have coda files not working correctly.

I have tehese simple php lines for testing:

$parser = new Parser(); $statements = $parser->parseFile('testfile.cod', 'simple');

foreach ($statements as $statement) { echo $statement->date . "\n";

foreach ($statement->transactions as $transaction) {
    echo $transaction->valuta_date.": ".$transaction->account->name . ": " . $transaction->amount . " (".$transaction->message." | ".$transaction->structured_message.")\n";
}

}

And this is what I get with the first coda file I tried:

... a couple normal lines ... 2017-09-25: : -174.17 ( | ) 2017-09-25: : -174.17 ( | ) 2017-09-25: : -119.6 ( | ) 2017-09-25: : -119.6 ( | ) ... some more normal lines ...

With the original versions it doesn't output any normal lines but with your forked version it does. Still, for some reason there are lines without any name or message.

And the transactions are shown double.. The one of 174.17 euro is just one transaction in my account and the one with 119.6 euro is also one transaction.

Still needs more work it seems :(

SanderM2 commented 6 years ago

For completeness: the lines that are shown correctly are also shown only once. No doubles for them...

wimverstuyf commented 6 years ago

Bug has been fixed in master by merging the message of multiple lines into 1 message. If there are any other issues you can open a new issue. I'm closing this issue.