various fixes

This commit is contained in:
2021-05-11 22:30:57 +02:00
parent 1ef459bcad
commit 2818d9c11f
4 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -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])
+1 -1
View File
@@ -64,7 +64,7 @@
We have sold {{ c.crypto }} for {{ c.sold|floatformat:2 }} EUR<br/>
{% endif %}
{% if c.amount_kept %}
Current value of our {{ c.amount_kept|formatcurrency }} {{ c.crypto }} is {{ c.current_value|floatformat:2 }} EUR<br/>
Current value of our <span title="{{ c.amount_kept }} {{ c.crypto }}">{{ c.amount_kept|formatcurrency }} {{ c.crypto }}</span> is {{ c.current_value|floatformat:2 }} EUR<br/>
{% endif %}
{% if c.bought_recently %}
We have bought within the last 12 months: {{ c.bought_recently|formatcurrency }} {{ c.crypto }}<br/>
+2
View File
@@ -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: