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