display small crypto amounts with more decimals

fixes #23
This commit is contained in:
2021-03-24 21:25:47 +01:00
parent 19cb3a8c02
commit 91c264e9cd
3 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -64,13 +64,13 @@
We have sold {{ c.crypto }} for {{ c.sold|floatformat:2 }} EUR<br/> We have sold {{ c.crypto }} for {{ c.sold|floatformat:2 }} EUR<br/>
{% endif %} {% endif %}
{% if c.amount_kept %} {% if c.amount_kept %}
Current value of our {{ c.amount_kept|floatformat:3 }} {{ c.crypto }} is {{ c.current_value|floatformat:2 }} EUR<br/> Current value of our {{ c.amount_kept|formatcurrency }} {{ c.crypto }} is {{ c.current_value|floatformat:2 }} EUR<br/>
{% endif %} {% endif %}
{% if c.bought_recently %} {% if c.bought_recently %}
We have bought within the last 12 months: {{ c.bought_recently|floatformat:3 }} {{ c.crypto }}<br/> We have bought within the last 12 months: {{ c.bought_recently|formatcurrency }} {{ c.crypto }}<br/>
{% endif %} {% endif %}
{% if c.bought_tax_free %} {% if c.bought_tax_free %}
We can sell without paying taxes: {{ c.bought_tax_free|floatformat:3 }} {{ c.crypto }} for {{ c.value_tax_free|floatformat:2 }} EUR<br/> We can sell without paying taxes: {{ c.bought_tax_free|formatcurrency }} {{ c.crypto }} for {{ c.value_tax_free|floatformat:2 }} EUR<br/>
{% endif %} {% endif %}
<br/><a href="/transactions/show?crypto={{ c.crypto }}">My transactions</a><br/> <br/><a href="/transactions/show?crypto={{ c.crypto }}">My transactions</a><br/>
+4
View File
@@ -6,5 +6,9 @@ register = template.Library()
def formatcurrency(value): def formatcurrency(value):
if value > 100: if value > 100:
return "%0.0f" % (value,) return "%0.0f" % (value,)
if value < 0.01:
return "%0.5f" % (value,)
if value < 0.1:
return "%0.4f" % (value,)
return "%0.2f" % (value,) return "%0.2f" % (value,)
+4
View File
@@ -6,5 +6,9 @@ register = template.Library()
def formatcurrency(value): def formatcurrency(value):
if value > 100: if value > 100:
return "%0.0f" % (value,) return "%0.0f" % (value,)
if value < 0.01:
return "%0.4f" % (value,)
if value < 0.1:
return "%0.3f" % (value,)
return "%0.2f" % (value,) return "%0.2f" % (value,)