mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 02:03:40 +00:00
Fix for #1938
This commit is contained in:
@@ -219,10 +219,10 @@ class Amount implements ConverterInterface
|
|||||||
if (0 === strpos($value, '--')) {
|
if (0 === strpos($value, '--')) {
|
||||||
$value = substr($value, 2);
|
$value = substr($value, 2);
|
||||||
}
|
}
|
||||||
|
// 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);
|
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
|
||||||
$len = \strlen($str);
|
$len = \strlen($str);
|
||||||
if ('(' === $str[0] && ')' === $str[$len - 1]) {
|
if ('(' === $str[0] && ')' === $str[$len - 1]) {
|
||||||
$str = '-' . substr($str, 1, $len - 2);
|
$str = '-' . substr($str, 1, $len - 2);
|
||||||
}
|
}
|
||||||
|
@@ -174,6 +174,12 @@ class AmountTest extends TestCase
|
|||||||
'--$1.23' => '1.23',
|
'--$1.23' => '1.23',
|
||||||
'--63 5212.4440' => '635212.4440',
|
'--63 5212.4440' => '635212.4440',
|
||||||
'--,2' => '0.2',
|
'--,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) {
|
foreach ($values as $value => $expected) {
|
||||||
$converter = new Amount;
|
$converter = new Amount;
|
||||||
|
Reference in New Issue
Block a user