diff --git a/apps/monitor/calc.py b/apps/monitor/calc.py
index 5526fd4..4c62820 100644
--- a/apps/monitor/calc.py
+++ b/apps/monitor/calc.py
@@ -87,10 +87,10 @@ class Calc:
# calculate all fees.
with connection.cursor() as cursor:
- sql = """SELECT SUM(crypto_fee) as crypto_fee, SUM(fiat_fee) as fiat_fee FROM `transaction` WHERE crypto_currency=%s and owner_id=%s"""
+ sql = """SELECT SUM(crypto_fee) as crypto_fee, SUM(fiat_fee) as fiat_fee FROM `transaction` WHERE crypto_currency=%s and owner_id=%s and transaction_type in ('T','B')"""
cursor.execute(sql, [crypto, userid])
fees = cursor.fetchone()
- if sold[0]:
+ if fees[0]:
total_investment -= Decimal(fees[1])
amount_kept -= Decimal(fees[0])
diff --git a/apps/monitor/templates/monitor.html b/apps/monitor/templates/monitor.html
index 0e7463c..7c58c1a 100644
--- a/apps/monitor/templates/monitor.html
+++ b/apps/monitor/templates/monitor.html
@@ -64,7 +64,7 @@
We have sold {{ c.crypto }} for {{ c.sold|floatformat:2 }} EUR
{% endif %}
{% if c.amount_kept %}
- Current value of our {{ c.amount_kept|formatcurrency }} {{ c.crypto }} is {{ c.current_value|floatformat:2 }} EUR
+ Current value of our {{ c.amount_kept|formatcurrency }} {{ c.crypto }} is {{ c.current_value|floatformat:2 }} EUR
{% endif %}
{% if c.bought_recently %}
We have bought within the last 12 months: {{ c.bought_recently|formatcurrency }} {{ c.crypto }}
diff --git a/apps/monitor/templatetags/filter.py b/apps/monitor/templatetags/filter.py
index 8445b99..e882f68 100644
--- a/apps/monitor/templatetags/filter.py
+++ b/apps/monitor/templatetags/filter.py
@@ -4,6 +4,8 @@ register = template.Library()
@register.filter
def formatcurrency(value):
+ if not value:
+ return "0.00"
if value > 100:
return "%0.0f" % (value,)
if value < 0.01:
diff --git a/apps/transactions/templates/show.html b/apps/transactions/templates/show.html
index b2581ea..49b95ae 100644
--- a/apps/transactions/templates/show.html
+++ b/apps/transactions/templates/show.html
@@ -23,11 +23,11 @@