export: filter the transactions by crypto currency
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<center><a href="/transactions/import" class="button button-primary">Import from Bitcoin.de</a></center>
|
<center><a href="/transactions/import" class="button button-primary">Import from Bitcoin.de</a></center>
|
||||||
<br/>
|
<br/>
|
||||||
<center><a href="/transactions/export" class="button button-primary">Export Transactions</a></center>
|
<center><a href="/transactions/export{% if crypto %}?crypto={{ crypto }}{% endif %}" class="button button-primary">Export Transactions</a></center>
|
||||||
<br/>
|
<br/>
|
||||||
<table class="table table-striped table-bordered table-sm">
|
<table class="table table-striped table-bordered table-sm">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
|
|||||||
@@ -47,7 +47,12 @@ def importbtcde(request):
|
|||||||
@login_required
|
@login_required
|
||||||
def show(request):
|
def show(request):
|
||||||
if 'crypto' in request.GET:
|
if 'crypto' in request.GET:
|
||||||
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))
|
crypto = request.GET['crypto']
|
||||||
|
else:
|
||||||
|
crypto = None
|
||||||
|
|
||||||
|
if crypto:
|
||||||
|
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=crypto).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0))
|
||||||
else:
|
else:
|
||||||
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0))
|
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:
|
for tr in transactions:
|
||||||
@@ -61,14 +66,19 @@ def show(request):
|
|||||||
tr.fiat_total += float(tr.fiat_amount)
|
tr.fiat_total += float(tr.fiat_amount)
|
||||||
if tr.fiat_fee:
|
if tr.fiat_fee:
|
||||||
tr.fiat_total += float(tr.fiat_fee)
|
tr.fiat_total += float(tr.fiat_fee)
|
||||||
return render(request,"show.html",{'transactions':transactions})
|
return render(request,"show.html",{'transactions':transactions, 'crypto': crypto})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def export(request):
|
def export(request):
|
||||||
if 'crypto' in request.GET:
|
if 'crypto' in request.GET:
|
||||||
filename="transactions-"+request.GET['crypto']+".xls"
|
crypto = request.GET['crypto']
|
||||||
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid')
|
else:
|
||||||
|
crypto = None
|
||||||
|
|
||||||
|
if crypto:
|
||||||
|
filename="transactions-"+crypto+".xls"
|
||||||
|
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=crypto).order_by('-date_valid')
|
||||||
else:
|
else:
|
||||||
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid')
|
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid')
|
||||||
filename="transactions.xls"
|
filename="transactions.xls"
|
||||||
|
|||||||
Reference in New Issue
Block a user