Added the accounting_txn_format_amount_input template filter to properly format the decimal amount for the number input fields.

This commit is contained in:
2023-02-27 18:40:54 +08:00
parent 59c55ef574
commit d67c57056b
5 changed files with 18 additions and 5 deletions

View File

@ -60,6 +60,17 @@ def format_amount(value: Decimal | None) -> str:
return "{:,}".format(whole) + str(frac)[1:]
def format_amount_input(value: Decimal) -> str:
"""Format an amount for an input value.
:param value: The amount.
:return: The formatted amount text for an input value.
"""
whole: int = int(value)
frac: Decimal = (value - whole).normalize()
return str(whole) + str(frac)[1:]
def format_date(value: date) -> str:
"""Formats a date to be human-friendly.