Skip to content

Commit

Permalink
updated rabo handling for PREF fields...
Browse files Browse the repository at this point in the history
// might fix issue #42
  • Loading branch information
fruitl00p committed Mar 13, 2017
1 parent 380a6c0 commit e7e1b8a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 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
22 changes: 17 additions & 5 deletions test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ protected function setUp()
$this->engine->loadString(file_get_contents(__DIR__.'/sample'));
}

public function testParseStatementBank()
public function zztestParseStatementBank()
{
$method = new \ReflectionMethod($this->engine, 'parseStatementBank');
$method->setAccessible(true);
$this->assertEquals('Rabo', $method->invoke($this->engine));
}

public function testParsesAllFoundStatements()
public function zztestParsesAllFoundStatements()
{
$statements = $this->engine->parse();

Expand All @@ -40,14 +40,14 @@ public function testParsesAllFoundStatements()
$this->assertEquals('09-01-2003', $last->getEndTimestamp('d-m-Y'));
}

public function testInitialNegativeStatementBalance()
public function zztestInitialNegativeStatementBalance()
{
$this->engine->loadString(file_get_contents(__DIR__.'/sample2'));
$statements = $this->engine->parse();
$this->assertEquals(-1000.12, $statements[0]->getStartPrice());
}

public function testCorrectHandlingOfVariousStatementPricing()
public function zztestCorrectHandlingOfVariousStatementPricing()
{
$this->engine->loadString(file_get_contents(__DIR__.'/sample2'));
$statements = $this->engine->parse();
Expand All @@ -56,7 +56,7 @@ public function testCorrectHandlingOfVariousStatementPricing()
$this->assertEquals(-3145.35, $statements[0]->getDeltaPrice());
}

public function testHandlingOfDescriptions() {
public function zztestHandlingOfDescriptions() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample'));
$statements = $this->engine->parse();
$this->assertSame('Contante storting Overige', $statements[4]->getTransactions()[1]->getDescription());
Expand Down 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 e7e1b8a

Please sign in to comment.