Fix bug when no payment to refund
This commit is contained in:
parent
31a077ef83
commit
b3674b516d
1 changed files with 8 additions and 3 deletions
|
@ -1,17 +1,22 @@
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from refunding.forms import RefundForm, RefundFormPublic
|
from refunding.forms import RefundFormPublic
|
||||||
from refunding.models import Payment, Refund
|
from refunding.models import Payment, Refund
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def not_refunded_payments(request):
|
def not_refunded_payments(request):
|
||||||
payments = Payment.objects.filter(refund=None)
|
payments = Payment.objects.filter(refund=None)
|
||||||
sum = payments.aggregate(Sum('value')).get('value__sum') / 100
|
value_sum = payments.aggregate(Sum('value')).get('value__sum')
|
||||||
|
if value_sum:
|
||||||
|
value_sum /= 100
|
||||||
|
else:
|
||||||
|
value_sum = 0
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'payments': payments,
|
'payments': payments,
|
||||||
'sum': sum,
|
'sum': value_sum,
|
||||||
'default_nothing': 'No payment to be refunded.'
|
'default_nothing': 'No payment to be refunded.'
|
||||||
}
|
}
|
||||||
return render(request, "refunding/payments.html", context)
|
return render(request, "refunding/payments.html", context)
|
||||||
|
|
Loading…
Reference in a new issue