From 42bc2ed5b986b188f0e827a56065669e66b1a827 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 (cherry picked from commit 681fc47a68d67c467d75a428d99fd9a5c5b3c9fb) --- app/Utils/Number.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Utils/Number.php b/app/Utils/Number.php index e2891b7c5..3312c6134 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -139,6 +139,8 @@ class Number $value = floatval($value); + $_value = $value; + $currency = $entity->currency(); $thousand = $currency->thousand_separator; @@ -179,6 +181,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);