mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 09:22:33 +00:00
Merge branch 'develop' into 5.7.0
This commit is contained in:
@@ -473,6 +473,8 @@ class Steam
|
||||
if ('' === $amount) {
|
||||
return '0';
|
||||
}
|
||||
$amount = $this->floatalize($amount);
|
||||
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
@@ -480,6 +482,34 @@ class Steam
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://framework.zend.com/downloads/archives
|
||||
*
|
||||
* Convert a scientific notation to float
|
||||
* Additionally fixed a problem with PHP <= 5.2.x with big integers
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function floatalize(string $value): string
|
||||
{
|
||||
Log::debug(sprintf('floatalize("%s")', $value));
|
||||
$value = strtoupper($value);
|
||||
if (!str_contains($value, 'E')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$number = substr($value, 0, strpos($value, 'E'));
|
||||
if (str_contains($number, '.')) {
|
||||
$post = strlen(substr($number, strpos($number, '.') + 1));
|
||||
$mantis = substr($value, strpos($value, 'E') + 1);
|
||||
if ($mantis < 0) {
|
||||
$post += abs((int) $mantis);
|
||||
}
|
||||
return number_format((float)$value, $post, '.', '');
|
||||
}
|
||||
return number_format((float)$value, 0, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $amount
|
||||
*
|
||||
|
Reference in New Issue
Block a user