mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 01:42:19 +00:00
Added support for multiple decimal places
This commit is contained in:
@@ -23,6 +23,18 @@ class Amount extends BasicConverter implements ConverterInterface
|
|||||||
* Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
|
* Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
|
||||||
* - Jamie Zawinski
|
* - Jamie Zawinski
|
||||||
*
|
*
|
||||||
|
* 0.01 4 1
|
||||||
|
* 0.10 4 1
|
||||||
|
* 0.1 3 0
|
||||||
|
* 1.00 4 1
|
||||||
|
* 1.0 3 0
|
||||||
|
* 1 1 -3
|
||||||
|
* 1.01 4 1
|
||||||
|
* 1.10 4 1
|
||||||
|
* 1.1 3 0
|
||||||
|
* 1.11 4 1
|
||||||
|
*
|
||||||
|
*
|
||||||
* @param $value
|
* @param $value
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
@@ -33,12 +45,11 @@ class Amount extends BasicConverter implements ConverterInterface
|
|||||||
$decimalPosition = $len - 3;
|
$decimalPosition = $len - 3;
|
||||||
$decimal = null;
|
$decimal = null;
|
||||||
|
|
||||||
if ($len > 2 && $value{$decimalPosition} == '.') {
|
if (($len > 2 && $value{$decimalPosition} == '.') || ($len > 2 && strpos($value, '.') > $decimalPosition)) {
|
||||||
$decimal = '.';
|
$decimal = '.';
|
||||||
}
|
} else if ($len > 2 && $value{$decimalPosition} == ',') {
|
||||||
if ($len > 2 && $value{$decimalPosition} == ',') {
|
|
||||||
$decimal = ',';
|
$decimal = ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if decimal is dot, replace all comma's and spaces with nothing. then parse as float (round to 4 pos)
|
// if decimal is dot, replace all comma's and spaces with nothing. then parse as float (round to 4 pos)
|
||||||
if ($decimal === '.') {
|
if ($decimal === '.') {
|
||||||
|
Reference in New Issue
Block a user