smaller fixes for recent changes
This commit is contained in:
@@ -26,15 +26,17 @@
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>{{ transaction.date_valid }}</td>
|
||||
<td>{{ transaction.crypto_amount|floatformat:3 }}
|
||||
{% if transaction.crypto_fee and transaction.crypto_fee > 0 %}Fee: {{ transaction.crypto_fee|floatformat:3 }}{% endif %}
|
||||
{{ transaction.crypto_currency }}
|
||||
</td>
|
||||
<td>{{ transaction.fiat_amount|formatcurrency }}
|
||||
{% if transaction.fiat_fee and transaction.fiat_fee > 0 %}Fee: {{ transaction.fiat_fee|floatformat:2 }}{% endif %}
|
||||
{{ transaction.fiat_currency }}
|
||||
</td>
|
||||
<td>{{ transaction.date_valid }}</td>
|
||||
<td><span title="{% if transaction.crypto_fee and transaction.crypto_fee > 0 %}Fee: {{ transaction.crypto_fee }}{% else %}{{ transaction.crypto_total }}{% endif %}">
|
||||
{{ transaction.crypto_total|floatformat:3 }}
|
||||
{{ transaction.crypto_currency }}
|
||||
</span>
|
||||
</td>
|
||||
<td><span title="{% if transaction.fiat_fee and transaction.fiat_fee > 0 %}Fee: {{ transaction.fiat_fee }}{% else %}{{ transaction.fiat_total }}{% endif %}">
|
||||
{{ transaction.fiat_total|formatcurrency }}
|
||||
{{ transaction.fiat_currency }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{% if transaction.transaction_type == 'S' %}
|
||||
{{ transaction.exchange_rate|formatcurrency }} {{ transaction.crypto_currency }}/{{ transaction.fiat_currency }}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import Value
|
||||
from apps.transactions.forms import TransactionForm
|
||||
from apps.transactions.forms import ImportForm
|
||||
from apps.transactions.models import Transaction
|
||||
@@ -43,9 +44,20 @@ def importbtcde(request):
|
||||
@login_required
|
||||
def show(request):
|
||||
if 'crypto' in request.GET:
|
||||
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid')
|
||||
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0))
|
||||
else:
|
||||
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid')
|
||||
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0))
|
||||
for tr in transactions:
|
||||
tr.crypto_total = 0.0
|
||||
if tr.crypto_amount:
|
||||
tr.crypto_total += float(tr.crypto_amount)
|
||||
if tr.crypto_fee:
|
||||
tr.crypto_total += float(tr.crypto_fee)
|
||||
tr.fiat_total = 0.0
|
||||
if tr.fiat_amount:
|
||||
tr.fiat_total += float(tr.fiat_amount)
|
||||
if tr.fiat_fee:
|
||||
tr.fiat_total += float(tr.fiat_fee)
|
||||
return render(request,"show.html",{'transactions':transactions})
|
||||
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user