Skip to content

Commit

Permalink
updated RABO parsing to support /REMI/ stuff better.
Browse files Browse the repository at this point in the history
This should also address #36

I've added more sample data (taken from https://github.com/dovadi/mt940/blob/master/test/fixtures/rabobank_sepa.txt) with slight alterations... The tests are kind of crude, but seem to demonstrate the workings of the description parsing...
  • Loading branch information
fruitl00p committed Jun 2, 2016
1 parent ab0b77a commit 86e0678
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parser/Banking/Mt940/Engine/Rabo.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function sanitizeDescription($string)
{
$description = parent::sanitizeDescription($string);
if (strpos($description, '/REMI/') !== false
&& preg_match('#/REMI/(.*?)/(ISDT|CSID|RTRN)/#s', $description, $results) && !empty($results[1])
&& preg_match('#/REMI/(.*?)(/((PURP|ISDT|CSID|RTRN)/)|$)#s', $description, $results) && !empty($results[1])
) {
return $results[1];
}
Expand Down
41 changes: 41 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,45 @@ public function testCorrectHandlingOfVariousStatementPricing()
$this->assertEquals(2145.23, $statements[0]->getEndPrice());
$this->assertEquals(-3145.35, $statements[0]->getDeltaPrice());
}

public function testHandlingOfDescriptions() {
$this->engine->loadString(file_get_contents(__DIR__.'/sample'));
$statements = $this->engine->parse();
$this->assertSame('Contante storting Overige', $statements[4]->getTransactions()[1]->getDescription());
$this->assertSame('INVOICE 38', $statements[14]->getTransactions()[3]->getDescription());
$this->assertSame('VOLGENS AFSPRAAK', $statements[15]->getTransactions()[0]->getDescription());
$this->assertSame('FAKTUUR 3549', $statements[15]->getTransactions()[1]->getDescription());

$this->engine->loadString(file_get_contents(__DIR__.'/sample3'));
$statements = $this->engine->parse();
// enclosed
$this->assertSame('674725433 1120000153447185 14144467636004962', $statements[0]->getTransactions()[0]->getDescription());
// ending
$this->assertSame('861835-574631143', $statements[0]->getTransactions()[2]->getDescription());
// with slash
$this->assertSame('/IBS.00008908/ 1001680-P796142 KINDEROPVANG', $statements[0]->getTransactions()[3]->getDescription());

$this->assertSame('Factuur 307472', $statements[1]->getTransactions()[0]->getDescription());

$this->engine->loadString(<<<PURPTEST
:940:
:20:940S130403
:25:NL50RABO0123456789
:28C:0
:60F:C130402EUR000000001147,95
:20:940S160503
:25:NL93RABO0157787990 EUR
:28C:16085
:60F:C160502EUR000000146645,88
:61:160503D000000000015,55N102EREF
NL34DEUT0499438906
:86:/EREF/02-06-2016 09:00 1230000456789011/BENM//NAME/Some Name
d company/REMI/some descripton here that
ends with/PURP//CD/EPAY
:62F:C160503EUR000000146630,33
PURPTEST
);
$statements = $this->engine->parse();
$this->assertSame('some descripton here thatends with', $statements[1]->getTransactions()[0]->getDescription());
}
}
1 change: 1 addition & 0 deletions test/Parser/Banking/Mt940/Engine/Rabo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sample 3 was copied from https://github.com/dovadi/mt940/blob/master/test/fixtures/rabobank_sepa.txt
74 changes: 74 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Rabo/sample3
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
:940:
:20:940S130403
:25:NL50RABO0123456789
:28C:0
:60F:C130402EUR000000001147,95

:61:130403D000000000127,50N102EREF
NL96RBOS0523149468
:86:/EREF/02-04-2013 22:56 1120000153447185/BENM//NAME/Nespresso Nede
rland B.V./REMI/674725433 1120000153447185 14144467636004962
/ISDT/2013-04-03

:61:130403C000000000169,90N122NONREF
0663616476
:86:/ORDP//NAME/Bedrijf B.V./REMI/NR.201303-111/11.3.2013
NR.201303-112/11.3.2013/ISDT/2013-04-03

:61:131125C000000000173,50N541NONREF
NL02INGB0002447973
:86:/ORDP//NAME/Hr R Kuil en/of Mw A Kuil-Germain/REMI/861835-5746311
43

:61:131206C000000000171,66N122NONREF
0444656227
:86:/ORDP//NAME/D VAN WAARD CJ/REMI//IBS.00008908/ 1001680-P796142 KI
NDEROPVANG

:62F:C130403EUR000000001190,35

:20:940S130404
:25:NL50RABO0123456789
:28C:0
:60F:C130403EUR000000001190,35

:61:130404D000000000585,60N071NONREF
P004500018
:86:/BENM//NAME/DIVV afd parkeergebouwewn/REMI/Factuur 307472/ISDT/20
13-04-04

:61:130404C000000001640,76N127NONREF
0117888613
:86:/ORDP//NAME/DLN CONSULTING/REMI/factuurnummer 201303-128cursus ce
rtified PO/ISDT/2013-04-04

:61:130404D000000000674,73N060NONREF
P004238192
:86:/BENM//NAME/INFRACOM INTERNET BV/REMI/BETALINGSKENM. 231732INCASS
O FACTUUR 231732INCASSO 02-04-2013INFRACOM INTERNET BV*ZWOLLE
/ISDT/2013-04-04

:61:130401D000000000130,29N093NONREF
:86:/REMI/KostenPeriode 01-01-2013 t/m 31-03-2013/ISDT/2013-04-01

:61:130404C000000002050,95N122NONREF
0691765731
:86:/ORDP//NAME/Wehkamp BV
04

:61:130404C000000001923,90N541EREF
NL82RBOS0602069890
:86:/EREF/1134027115/ORDP//NAME/BEDRIJF NV/ADDR/STRAATWEG 68 123
2 AA AMSTERDAM THE NETHERLANDS NL/REMI/Ref: 201302-080/ISDT/2013-04-
04

:61:130404C000000013431,00N122NONREF
0477502946
:86:/ORDP//NAME/EVEREST BV/REMI/12420/20001512 201303-088 XX201303-08
8XX ZILVERLINE TRAINING1098 TW AMSTERDAM/ISDT/2013-04-04

:61:130920C000000000384,75N541NONREF
NL54INGB0006752576
:86:/ACCW/NL54INGB0006752576,INGBNL2A/ORDP//NAME/Hr A B Huibers en/of
Mw S L Huibers-Huveneers/REMI/1000122-P5549161
:62F:C130404EUR000000018846,34

0 comments on commit 86e0678

Please sign in to comment.