Merge pull request #37 from tpokorra/TP-202112-filter_exporting_transactions
export: filter the transactions by crypto currency
This commit was merged in pull request #37.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<br/>
|
||||
<center><a href="/transactions/import" class="button button-primary">Import from Bitcoin.de</a></center>
|
||||
<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/>
|
||||
<table class="table table-striped table-bordered table-sm">
|
||||
<thead class="thead-dark">
|
||||
|
||||
@@ -47,7 +47,12 @@ 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').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:
|
||||
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:
|
||||
@@ -61,14 +66,19 @@ def show(request):
|
||||
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})
|
||||
return render(request,"show.html",{'transactions':transactions, 'crypto': crypto})
|
||||
|
||||
|
||||
@login_required
|
||||
def export(request):
|
||||
if 'crypto' in request.GET:
|
||||
filename="transactions-"+request.GET['crypto']+".xls"
|
||||
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid')
|
||||
crypto = request.GET['crypto']
|
||||
else:
|
||||
crypto = None
|
||||
|
||||
if crypto:
|
||||
filename="transactions-"+crypto+".xls"
|
||||
transactions = Transaction.objects.filter(owner=request.user, crypto_currency=crypto).order_by('-date_valid')
|
||||
else:
|
||||
transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid')
|
||||
filename="transactions.xls"
|
||||
|
||||
Reference in New Issue
Block a user