From fe66be673aa6f2eeda5053c1cc872350328687fd Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 26 Jul 2020 17:35:13 +0200 Subject: [PATCH] Some extra code for #3578 --- app/Support/Amount.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Support/Amount.php b/app/Support/Amount.php index a896b5e58d..bf51878cf1 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -219,8 +219,16 @@ class Amount $positivePrefixed = '' !== $fmt->getAttribute(NumberFormatter::POSITIVE_PREFIX); $negativePrefixed = '' !== $fmt->getAttribute(NumberFormatter::NEGATIVE_PREFIX); + $formatAccounting = (int) $fmt->getAttribute(NumberFormatter::CURRENCY_ACCOUNTING); + $positive = ($positivePrefixed) ? '%s %v' : '%v %s'; - $negative = ($negativePrefixed) ? '%s %v' : '%v %s'; + $negative = ($negativePrefixed) ? '%s -%v' : '-%v %s'; + + if(0 !== $formatAccounting) { + $negative = '(%v %s)'; + } + + return [ 'mon_decimal_point' => $fmt->getSymbol(NumberFormatter::MONETARY_SEPARATOR_SYMBOL),