diff --git a/src/Parser/Banking/Mt940/Engine/Ing.php b/src/Parser/Banking/Mt940/Engine/Ing.php index 326ad2e..d0f390b 100644 --- a/src/Parser/Banking/Mt940/Engine/Ing.php +++ b/src/Parser/Banking/Mt940/Engine/Ing.php @@ -110,19 +110,30 @@ private function parseNameFromTransactionData($transactionData) */ protected function sanitizeDescription($string) { + $descriptionStart = $descriptionEnd = ''; $description = parent::sanitizeDescription($string); + if (strpos($description, '/PREF/') !== false + && preg_match('#/PREF/(.*?)/#s', $description, $results) && !empty($results[1]) + ) { + $descriptionStart = $results[1]; + } + if (strpos($description, '/EREF/') !== false + && preg_match('#/EREF/(.*?)/#s', $description, $results) && !empty($results[1]) + ) { + $descriptionStart = $results[1]; + } if (strpos($description, '/REMI/USTD//') !== false - && preg_match('#/REMI/USTD//(.*?)/#s', $description, $results) && !empty($results[1]) + && preg_match('#/REMI/USTD//(.*?)/$#s', $description, $results) && !empty($results[1]) ) { - return $results[1]; + $descriptionEnd = $results[1]; } if (strpos($description, '/REMI/STRD/CUR/') !== false && preg_match('#/REMI/STRD/CUR/(.*?)/#s', $description, $results) && !empty($results[1]) ) { - return $results[1]; + $descriptionEnd = $results[1]; } - return $description; + return trim($descriptionStart.' '.$descriptionEnd); } /** diff --git a/test/Parser/Banking/Mt940/Engine/Ing/ParseTest.php b/test/Parser/Banking/Mt940/Engine/Ing/ParseTest.php index 5a9e860..32a0779 100644 --- a/test/Parser/Banking/Mt940/Engine/Ing/ParseTest.php +++ b/test/Parser/Banking/Mt940/Engine/Ing/ParseTest.php @@ -38,4 +38,15 @@ public function testParsesAllFoundStatements() $this->assertEquals('23-07-2010', $first->getEndTimestamp('d-m-Y')); $this->assertEquals(-3.47, $first->getDeltaPrice()); } + + /** + * @TODO this is WIP, add more! + */ + public function testSanitizeDescription() + { + $statements = $this->engine->parse(); + $first = $statements[0]->getTransactions()[0]; + $this->assertEquals('', $first->getDescription()); + + } }