mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Fix #1474
This commit is contained in:
@@ -109,6 +109,11 @@ class Amount implements ConverterInterface
|
|||||||
*/
|
*/
|
||||||
private function stripAmount(string $value): string
|
private function stripAmount(string $value): string
|
||||||
{
|
{
|
||||||
|
if (0 === strpos($value, '--')) {
|
||||||
|
$value = substr($value, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$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]) {
|
||||||
|
@@ -156,6 +156,13 @@ class AmountTest extends TestCase
|
|||||||
'(33.52)' => '-33.52',
|
'(33.52)' => '-33.52',
|
||||||
'€(63.12)' => '-63.12',
|
'€(63.12)' => '-63.12',
|
||||||
'($182.77)' => '-182.77',
|
'($182.77)' => '-182.77',
|
||||||
|
|
||||||
|
// double minus because why the hell not
|
||||||
|
'--0.03881677' => '0.03881677',
|
||||||
|
'--0.33' => '0.33',
|
||||||
|
'--$1.23' => '1.23',
|
||||||
|
'--63 5212.4440' => '635212.444',
|
||||||
|
'--,2' => '0.2',
|
||||||
];
|
];
|
||||||
foreach ($values as $value => $expected) {
|
foreach ($values as $value => $expected) {
|
||||||
$converter = new Amount;
|
$converter = new Amount;
|
||||||
|
Reference in New Issue
Block a user