Open websafe opened 5 years ago
Have you run it through a debugger? Also the ING parser was created for the Dutch ING bank, it could be that the Polish ING has a different markup.
My suggestion to debug is allow the parser to detect it. Should it fallback to the generic parser, it should give a clue as to where to start looking ;) (and confirm that the Dutch ING and Polish ING differ in their MT940)
I did some "debugging" ;-) but wasn't able to fix it really. It all starts with parseStatementData()
in Engine.php
.
My sta begins with:
:20:MT940
:25:/PL12345678912345678912345678
:28C:9
:60F:C190930PLN66666,66
:61:1909020902D850,39S02097202028342
:86:020
:86:020~00IBCG
The problem begins in: https://github.com/fruitl00p/php-mt940/blob/d7cdbc0b05009685fa927bf05323f18cfe1f589a/src/Parser/Banking/Mt940/Engine.php#L172-L182
As I understand my statements are not separated by ^:20
but by ^:86:
so I "fixed" '/(^:20:|^-X{,3}$|\Z)/m'
into '/(^:86:|^-X{,3}$|\Z)/m'
and got an array with 156 entries as result.
But still verry messy. Just an example:
15 =>
object(Kingsquare\Banking\Statement)[26]
private 'bank' => string 'ING' (length=3)
private 'account' => string '' (length=0)
private 'transactions' =>
array (size=1)
0 =>
object(Kingsquare\Banking\Transaction)[27]
...
private 'startPrice' => float 0
private 'endPrice' => float 0
private 'startTimestamp' => int 0
private 'endTimestamp' => int 0
private 'number' => string '' (length=0)
private 'currency' => string '' (length=0)
public 'rawData' => string '020~00IBCG
~20Faktura 11-116089-09196
~21~22
~23~24
~25
~3010301931~319000010015184076
~32Orange Polska S.A. Al. ~33Jerozolimskie 160 02-326
~34020
~38PL42103019319000010015184076
~62Warszawa
:61:1909050905D1,00S02097202113823
' (length=239)
I have found the english description for MT940 used by ING-PL https://www.ing.pl/_fileserver/item/1003276
I guess it should be :61:
not :86:
but the result with 77 entries is still messy.
At least 77
matches the real transaction count. Same transaction as before as an example of the result I'm getting:
7 =>
object(Kingsquare\Banking\Statement)[11]
private 'bank' => string 'ING' (length=3)
private 'account' => string '' (length=0)
private 'transactions' =>
array (size=0)
empty
private 'startPrice' => float 0
private 'endPrice' => float 0
private 'startTimestamp' => int 0
private 'endTimestamp' => int 0
private 'number' => string '' (length=0)
private 'currency' => string '' (length=0)
public 'rawData' => string '1909050905D141,45S02097202112873
:86:020
:86:020~00IBCG
~20Faktura 11-116089-09196
~21~22
~23~24
~25
~3010301931~319000010015184076
~32Orange Polska S.A. Al. ~33Jerozolimskie 160 02-326
~34020
~38PL42103019319000010015184076
~62Warszawa
' (length=250)
Hmmm... thanks for the link to the docs...
It seems ING Poland has some type of prefix for all the :86: lines... (as mentioned in the docs) You might want to have a look at pages 60+ from the PDF you mentioned. It should be doable to create a custom / new ING-Poland parser based on one of the other already available parsers.
I currently don't have the time personally to look too deep into this, but PRs are welcome ;) (will flag this issue as #hacktoberfest to get some attention)
Thank you, I'll try to find some time :-)
@fruitl00p So I've started writing the IngPl parser, looks promising :-) But I'll have few questions. Is it OK to ask them using separate Issues?
@websafe a single thread is also doable.. .Just be sure to include a reproducable scenario et al... You might even go as far as creating a PR which isnt finished yet so I might be able to see how far your getting..
Its really up to you ;)
Hello,
I'm testing this parser on a sta file from ING (Poland) using this code:
but all I get is:
Am I missing something? Or maybe is my file format not supported?