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

'RuntimeException' with message 'No suitable parser found.' #26

Closed
websafe opened this issue Oct 17, 2019 · 3 comments
Closed

'RuntimeException' with message 'No suitable parser found.' #26

websafe opened this issue Oct 17, 2019 · 3 comments

Comments

@websafe
Copy link

@websafe websafe commented Oct 17, 2019

Hello.

I'm trying to understand how to use this parser, so I'm not sure if it's me or my MT940 file's fault ;-)
My sta file is from ING (Poland).

I've tried this:

<?php
require 'vendor/autoload.php';
use Jejik\MT940\Reader;

$mt940file = 'test.sta';
$reader = new Reader();
var_dump($reader->getParsers());
$reader->setParsers(array('ING' => 'Jejik\MT940\Parser\Ing'));
var_dump($reader->getParsers());

$statements = $reader->getStatements(file_get_contents($mt940file));
foreach ($statements as $statement) {
  echo $statement->getOpeningBalance()->getAmount() . "\n";
  foreach ($statement->getTransactions() as $transaction) {
    echo $transaction->getAmount() . "\n";
  }
  echo $statement->getClosingBalance()->getAmount() . "\n";
}

But all I get is:

array(0) {
}
array(1) {
  ["ING"]=>
  string(22) "Jejik\MT940\Parser\Ing"
}
PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'No suitable parser found.' in /tmp/mt940-2/vendor/jejik/mt940/lib/Jejik/MT940/Reader.php:489
Stack trace:
#0 /tmp/mt940-2/index.php(17): Jejik\MT940\Reader->getStatements(':20:MT940\r\n:25:...')
#1 {main}
  thrown in /tmp/mt940-2/vendor/jejik/mt940/lib/Jejik/MT940/Reader.php on line 489

Did I forget something or is it something with my test.sta?

@sandermarechal

This comment has been minimized.

Copy link
Owner

@sandermarechal sandermarechal commented Oct 21, 2019

The file format may have changed. Can you share the first line from your STA file? The files used to start like this:

{1:F01INGBNL2AXXXX00001}

The ING parser specifically looks for the string INGBNL or it will refose to parse the file.

@websafe

This comment has been minimized.

Copy link
Author

@websafe websafe commented Oct 21, 2019

Hello @sandermarechal

My sta begins with:

:20:MT940
:25:/PL12345678912345678912345678
:28C:9
:60F:C190930PLN66666,66
:61:1909020902D850,39S02097202028342
:86:020
:86:020~00IBCG

and the official docs for MT940 used by ING-PL (ING-BSK) are located here: https://www.ing.pl/_fileserver/item/1003276

@sandermarechal

This comment has been minimized.

Copy link
Owner

@sandermarechal sandermarechal commented Oct 21, 2019

That appears to be a different format than the ING bank uses in The Netherlands. Your file appears to be just a raw MT940 file, while the Dutch version embeds the raw MT940 code inside a carrier format that uses curly braces as a delimiter.

I think you are better off implementing a custom parser for your file. Start out using the AbstractParser which can parse most of the standard MT940 files. Then see if it needs tweaking by overriding some of the methods. Looking at your documentation it appears that the description field contains many ING-PL specific subfields marked with ~ signs. You could try adding support for those as well.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.