From 75ce777090014f25de3fcbf7bbdd02f518eac5f1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 27 Dec 2022 20:00:18 +0100 Subject: [PATCH] Fix https://github.com/firefly-iii/firefly-iii/issues/6743 --- app/Support/Amount.php | 8 ++++---- app/Support/Steam.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 02a71a513d..4f2d120f2a 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -72,20 +72,20 @@ class Amount public function formatFlat(string $symbol, int $decimalPlaces, string $amount, bool $coloured = null): string { $locale = app('steam')->getLocale(); - + $rounded = app('steam')->bcround($amount, $decimalPlaces); $coloured = $coloured ?? true; $fmt = new NumberFormatter($locale, NumberFormatter::CURRENCY); $fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, $symbol); $fmt->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $decimalPlaces); $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces); - $result = $fmt->format((float)app('steam')->bcround($amount, $decimalPlaces)); // intentional float + $result = $fmt->format((float)$rounded); // intentional float if (true === $coloured) { - if (1 === bccomp($amount, '0')) { + if (1 === bccomp($rounded, '0')) { return sprintf('%s', $result); } - if (-1 === bccomp($amount, '0')) { + if (-1 === bccomp($rounded, '0')) { return sprintf('%s', $result); } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index e38787bfce..4f31bf42b0 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -116,7 +116,7 @@ class Steam if(false !== stripos($number,'e')) { $number = sprintf('%.24f',$number); } - + Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision)); if (str_contains($number, '.')) { if ($number[0] !== '-') {