mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
feat: properly displays the negative signal before prefix
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import datetime
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.template.defaultfilters import floatformat
|
from django.template.defaultfilters import floatformat
|
||||||
|
|
||||||
@@ -8,7 +7,11 @@ register = template.Library()
|
|||||||
|
|
||||||
|
|
||||||
def _format_string(prefix, amount, decimal_places, suffix):
|
def _format_string(prefix, amount, decimal_places, suffix):
|
||||||
return f"{prefix}{floatformat(amount, decimal_places)}{suffix}"
|
formatted_amount = floatformat(abs(amount), f"{decimal_places}g")
|
||||||
|
if amount < 0:
|
||||||
|
return f"-{prefix}{formatted_amount}{suffix}"
|
||||||
|
else:
|
||||||
|
return f"{prefix}{formatted_amount}{suffix}"
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(name="transaction_amount")
|
@register.simple_tag(name="transaction_amount")
|
||||||
|
|||||||
Reference in New Issue
Block a user