Skip to content

Commit

Permalink
added patch provided by @MrMoronIV. Still needs tests to verify
Browse files Browse the repository at this point in the history
// see #63
  • Loading branch information
fruitl00p committed Mar 18, 2019
1 parent 9c754a9 commit 0564d5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Parser/Banking/Mt940/Engine/Ing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions test/Parser/Banking/Mt940/Engine/Ing/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

}
}

0 comments on commit 0564d5c

Please sign in to comment.