diff --git a/apps/transactions/templates/show.html b/apps/transactions/templates/show.html index 686c339..4438022 100644 --- a/apps/transactions/templates/show.html +++ b/apps/transactions/templates/show.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load humanize %} +{% load filter %} {% block content %}
@@ -22,13 +23,13 @@ {{ transaction.date_valid }} {{ transaction.amount_before_fee|floatformat:3 }} {{ transaction.crypto_currency }} - {{ transaction.amount|floatformat:2 }} {{ transaction.fiat_currency }} + {{ transaction.amount|formatcurrency }} {{ transaction.fiat_currency }} {% if transaction.amount < 0 %} - {{ transaction.exchange_rate|floatformat:0 }} {{ transaction.crypto_currency }}/{{ transaction.fiat_currency }} + {{ transaction.exchange_rate|formatcurrency }} {{ transaction.crypto_currency }}/{{ transaction.fiat_currency }} {% endif %} {% if transaction.amount > 0 %} - {{ transaction.exchange_rate|floatformat:0 }} {{ transaction.crypto_currency }}/{{ transaction.fiat_currency }} + {{ transaction.exchange_rate|formatcurrency }} {{ transaction.crypto_currency }}/{{ transaction.fiat_currency }} {% endif %} diff --git a/apps/transactions/templatetags/__init__.py b/apps/transactions/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/transactions/templatetags/filter.py b/apps/transactions/templatetags/filter.py new file mode 100644 index 0000000..e556ed3 --- /dev/null +++ b/apps/transactions/templatetags/filter.py @@ -0,0 +1,10 @@ +from django import template + +register = template.Library() + +@register.filter +def formatcurrency(value): + if value > 100: + return "%0.0f" % (value,) + return "%0.2f" % (value,) +