This commit is contained in:
James Cole 2018-12-30 06:19:16 +01:00
parent fd233510ee
commit 7fa2fed147
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 10 additions and 4 deletions

View File

@ -219,10 +219,10 @@ class Amount implements ConverterInterface
if (0 === strpos($value, '--')) {
$value = substr($value, 2);
}
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = \strlen($str);
// have to strip the € because apparantly the Postbank (DE) thinks "1.000,00 €" is a normal way to format a number.
$value = trim((string)str_replace(['€'], '', $value));
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = \strlen($str);
if ('(' === $str[0] && ')' === $str[$len - 1]) {
$str = '-' . substr($str, 1, $len - 2);
}

View File

@ -174,6 +174,12 @@ class AmountTest extends TestCase
'--$1.23' => '1.23',
'--63 5212.4440' => '635212.4440',
'--,2' => '0.2',
// Postbank (DE) tests
'1.000,00 €' => '1000.00',
'120,34 €' => '120.34',
'-120,34 €' => '-120.34',
'-1.000,00 €' => '-1000.00',
];
foreach ($values as $value => $expected) {
$converter = new Amount;