Fixed the format_amount filter to deal with negative numbers with decimals correctly.

This commit is contained in:
依瑪貓 2023-03-05 11:48:34 +08:00
parent 9d5fce2752
commit 14b871b57a

View File

@ -35,7 +35,7 @@ def format_amount(value: Decimal | None) -> str:
return "-" return "-"
whole: int = int(value) whole: int = int(value)
frac: Decimal = (value - whole).normalize() frac: Decimal = (value - whole).normalize()
return "{:,}".format(whole) + str(frac)[1:] return "{:,}".format(whole) + str(abs(frac))[1:]
def format_date(value: date) -> str: def format_date(value: date) -> str: