diff --git a/src/Parser/Banking/Mt940/Engine/Rabo.php b/src/Parser/Banking/Mt940/Engine/Rabo.php index a5f94d2..5280260 100644 --- a/src/Parser/Banking/Mt940/Engine/Rabo.php +++ b/src/Parser/Banking/Mt940/Engine/Rabo.php @@ -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]; } diff --git a/test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php b/test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php index 5714c45..3b970c1 100644 --- a/test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php +++ b/test/Parser/Banking/Mt940/Engine/Rabo/ParseTest.php @@ -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(<<engine->parse(); + $this->assertSame('some descripton here thatends with', $statements[1]->getTransactions()[0]->getDescription()); + } } diff --git a/test/Parser/Banking/Mt940/Engine/Rabo/README.md b/test/Parser/Banking/Mt940/Engine/Rabo/README.md new file mode 100644 index 0000000..684318c --- /dev/null +++ b/test/Parser/Banking/Mt940/Engine/Rabo/README.md @@ -0,0 +1 @@ +Sample 3 was copied from https://github.com/dovadi/mt940/blob/master/test/fixtures/rabobank_sepa.txt \ No newline at end of file diff --git a/test/Parser/Banking/Mt940/Engine/Rabo/sample3 b/test/Parser/Banking/Mt940/Engine/Rabo/sample3 new file mode 100644 index 0000000..34454e4 --- /dev/null +++ b/test/Parser/Banking/Mt940/Engine/Rabo/sample3 @@ -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 \ No newline at end of file