Bank: add sign to money log.
This commit is contained in:
parent
1d6cb59293
commit
a22e3dba47
2 changed files with 4 additions and 5 deletions
|
@ -22,7 +22,7 @@
|
|||
{{ transaction.date }}
|
||||
</td>
|
||||
<td class="align-middle text-right {% if transaction.amount < 0 %}text-danger{% else %}text-success{% endif %}">
|
||||
{% format_money transaction.amount %}
|
||||
{% format_money transaction.amount force_sign=True %}
|
||||
</td>
|
||||
<td class="align-middle text-right">
|
||||
{% format_money transaction.balance %}
|
||||
|
|
|
@ -6,10 +6,9 @@ register = template.Library()
|
|||
|
||||
|
||||
@register.simple_tag()
|
||||
def format_money(copper: int):
|
||||
balance_str = str(abs(copper)).rjust(5, "0") # pad until 0 gold
|
||||
if copper < 0:
|
||||
balance_str = "-" + balance_str
|
||||
def format_money(copper: int, force_sign=False):
|
||||
sign = "+" if force_sign else "-"
|
||||
balance_str = f"{copper:{sign}06}" # force sign if requested and zero-pad until 0 gold
|
||||
return format_html(
|
||||
"""
|
||||
<span>
|
||||
|
|
Loading…
Reference in a new issue