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. # calculate all fees.
with connection.cursor() as cursor: 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]) cursor.execute(sql, [crypto, userid])
fees = cursor.fetchone() fees = cursor.fetchone()
if sold[0]: if fees[0]:
total_investment -= Decimal(fees[1]) total_investment -= Decimal(fees[1])
amount_kept -= Decimal(fees[0]) 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/> 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|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 %} {% endif %}
{% if c.bought_recently %} {% if c.bought_recently %}
We have bought within the last 12 months: {{ c.bought_recently|formatcurrency }} {{ c.crypto }}<br/> 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 @register.filter
def formatcurrency(value): def formatcurrency(value):
if not value:
return "0.00"
if value > 100: if value > 100:
return "%0.0f" % (value,) return "%0.0f" % (value,)
if value < 0.01: if value < 0.01:
+2 -2
View File
@@ -23,11 +23,11 @@
<tr> <tr>
<td>{{ transaction.date_valid }}</td> <td>{{ transaction.date_valid }}</td>
<td>{{ transaction.crypto_amount|floatformat:3 }} <td>{{ transaction.crypto_amount|floatformat:3 }}
{% if transaction.crypto_fee > 0 %}Fee: {{ transaction.crypto_fee|floatformat:3 }}{% endif %} {% if transaction.crypto_fee and transaction.crypto_fee > 0 %}Fee: {{ transaction.crypto_fee|floatformat:3 }}{% endif %}
{{ transaction.crypto_currency }} {{ transaction.crypto_currency }}
</td> </td>
<td>{{ transaction.fiat_amount|formatcurrency }} <td>{{ transaction.fiat_amount|formatcurrency }}
{% if transaction.fiat_fee > 0 %}Fee: {{ transaction.fiat_fee|floatformat:2 }}{% endif %} {% if transaction.fiat_fee and transaction.fiat_fee > 0 %}Fee: {{ transaction.fiat_fee|floatformat:2 }}{% endif %}
{{ transaction.fiat_currency }} {{ transaction.fiat_currency }}
</td> </td>
<td>{% if transaction.transaction_type == 'S' %} <td>{% if transaction.transaction_type == 'S' %}