From 14b871b57a5b2473dbeac3b763cfa442f2f6e7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 5 Mar 2023 11:48:34 +0800 Subject: [PATCH] Fixed the format_amount filter to deal with negative numbers with decimals correctly. --- src/accounting/template_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accounting/template_filters.py b/src/accounting/template_filters.py index 5b4b92f..2a42b22 100644 --- a/src/accounting/template_filters.py +++ b/src/accounting/template_filters.py @@ -35,7 +35,7 @@ def format_amount(value: Decimal | None) -> str: return "-" whole: int = int(value) frac: Decimal = (value - whole).normalize() - return "{:,}".format(whole) + str(frac)[1:] + return "{:,}".format(whole) + str(abs(frac))[1:] def format_date(value: date) -> str: