mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 01:41:14 -06:00
Fix for #1938
This commit is contained in:
parent
fd233510ee
commit
7fa2fed147
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user