Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No result and no errors? #72

Open
websafe opened this issue Oct 17, 2019 · 7 comments
Open

No result and no errors? #72

websafe opened this issue Oct 17, 2019 · 7 comments

Comments

@websafe
Copy link

websafe commented Oct 17, 2019

Hello,

I'm testing this parser on a sta file from ING (Poland) using this code:

<?php
require 'vendor/autoload.php';
$mt940file = __DIR__ . '/test.sta';
$parser = new \Kingsquare\Parser\Banking\Mt940();
$engine = new \Kingsquare\Parser\Banking\Mt940\Engine\Ing();
$parsedStatements = $parser->parse(file_get_contents($mt940file), $engine);
var_dump($parsedStatements);

but all I get is:

array(0) {
}

Am I missing something? Or maybe is my file format not supported?

@fruitl00p
Copy link
Owner

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)

@fruitl00p fruitl00p self-assigned this Oct 18, 2019
@websafe
Copy link
Author

websafe commented Oct 19, 2019

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:

protected function parseStatementData()
{
$results = preg_split(
'/(^:20:|^-X{,3}$|\Z)/m',
$this->getRawData(),
-1,
PREG_SPLIT_NO_EMPTY
);
array_shift($results); // remove the header
return $results;
}

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)

@websafe
Copy link
Author

websafe commented Oct 19, 2019

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)

@fruitl00p
Copy link
Owner

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)

@websafe
Copy link
Author

websafe commented Oct 21, 2019

Thank you, I'll try to find some time :-)

@websafe
Copy link
Author

websafe commented Nov 1, 2019

@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?

@fruitl00p
Copy link
Owner

@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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants