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

This commit is contained in:
imacat committed 2023-03-09 06:37:09 +08:00
1 parent a7bcf4b5c1
commit bfb08cf5fc
4 files changed
+7 -5

No files matched your search

@@ -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:]