From 681fc47a68d67c467d75a428d99fd9a5c5b3c9fb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 17 Feb 2023 17:19:33 +1100 Subject: [PATCH] Fixes for displaying negative currencies --- app/Utils/Number.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 4d2379839..f19aefc69 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -137,6 +137,8 @@ class Number { $value = floatval($value); + $_value = $value; + $currency = $entity->currency(); $thousand = $currency->thousand_separator; @@ -177,6 +179,15 @@ class Number } elseif ($swapSymbol) { return "{$value} ".trim($symbol); } elseif ($entity->getSetting('show_currency_code') === false) { + + /* Ensures we place the negative symbol ahead of the currency symbol*/ + if($_value < 0){ + + $value = substr($value, 1); + $symbol = "-{$symbol}"; + + } + return "{$symbol}{$value}"; } else { return self::formatValue($value, $currency);