Changed the format_amount_input filter to accept None, and return an empty string if the value is None.

This commit is contained in:
2023-03-06 01:35:04 +08:00
parent a7bcf4b5c1
commit bfb08cf5fc
4 changed files with 7 additions and 5 deletions

View File

@ -57,12 +57,14 @@ def to_transfer(uri: str) -> str:
return urlunparse(parts)
def format_amount_input(value: Decimal) -> str:
def format_amount_input(value: Decimal | None) -> str:
"""Format an amount for an input value.
:param value: The amount.
:return: The formatted amount text for an input value.
"""
if value is None:
return ""
whole: int = int(value)
frac: Decimal = (value - whole).normalize()
return str(whole) + str(frac)[1:]