Skip to content

Commit

Permalink
Merge pull request #64 from fruitl00p/rabo-pref
Browse files Browse the repository at this point in the history
updated rabo handling for PREF fields...
  • Loading branch information
fruitl00p authored Mar 18, 2019
2 parents 9c754a9 + ce7cd25 commit 4596513
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Parser/Banking/Mt940/Engine/Rabo.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ protected function sanitizeDescription($string)
return $results[1];
}

if (strpos($description, '/PREF/') !== false
&& preg_match('#/PREF/(.*)/?#s', $description, $results) && !empty($results[1])
) {
return $results[1];
}

return $description;
}

Expand Down
12 changes: 12 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,16 @@ public function testHandlingOfDescriptions() {
$statements = $this->engine->parse();
$this->assertSame('some descripton here thatends with', $statements[1]->getTransactions()[0]->getDescription());
}

public function testHandlingOfEREF() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample4'));
$statements = $this->engine->parse();
$this->assertSame('20151208123123987 0030001100999991 Rabobank.nl - Order 347347', $statements[0]->getTransactions()[0]->getDescription());
}

public function testHandlingOfPREF() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample4'));
$statements = $this->engine->parse();
$this->assertSame('PmtInfId-20151208-987', $statements[0]->getTransactions()[1]->getDescription());
}
}
20 changes: 20 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Rabo/sample4
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
:940:
:20:940S130403
:25:NL50RABO0123456789
:28C:0
:60F:C130402EUR000000001147,95

:61:151208D000000000098,99N102EREF
NL44RABO0123456789
:86:/EREF/08-12-2015 10:22 0030001100999991/BENM//NAME/Rabobank RCKV/
REMI/20151208123123987 0030001100999991 Rabobank.nl - Order 347347

:61:151208D000000000840,20N586PREF
0000000000
:86:/PREF/PmtInfId-20151208-987

:61:151208D000000000840,20N586PREF
0000000000
:86:/PREF/PmtInfId-20151208-987/SOMETHING ELSE

:62F:C130404EUR000000018846,34

0 comments on commit 4596513

Please sign in to comment.