Changed the format_amount template filter to return None when the value is None.
This commit is contained in:
parent
cd49ca44b1
commit
a7bcf4b5c1
@ -25,13 +25,15 @@ from flask_babel import get_locale
|
|||||||
from accounting.locale import gettext
|
from accounting.locale import gettext
|
||||||
|
|
||||||
|
|
||||||
def format_amount(value: Decimal | None) -> str:
|
def format_amount(value: Decimal | None) -> str | None:
|
||||||
"""Formats an amount for readability.
|
"""Formats an amount for readability.
|
||||||
|
|
||||||
:param value: The amount.
|
:param value: The amount.
|
||||||
:return: The formatted amount text.
|
:return: The formatted amount text.
|
||||||
"""
|
"""
|
||||||
if value is None or value == 0:
|
if value is None:
|
||||||
|
return None
|
||||||
|
if value == 0:
|
||||||
return "-"
|
return "-"
|
||||||
whole: int = int(value)
|
whole: int = int(value)
|
||||||
frac: Decimal = (value - whole).normalize()
|
frac: Decimal = (value - whole).normalize()
|
||||||
|
Loading…
Reference in New Issue
Block a user