Skip to content

Commit 9133124

Browse files
committed
Show quantity/amount of payments in credit card view module
1 parent 5d41f04 commit 9133124

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

esp/esp/program/modules/handlers/creditcardviewer_cybersource.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
from esp.web.util import render_to_response
3939
from datetime import datetime
4040
from django.db.models.query import Q
41+
from django.db.models import Sum
4142
from esp.users.models import User, ESPUser
43+
from esp.accounting.models import Transfer
4244
from esp.accounting.controllers import ProgramAccountingController, IndividualAccountingController
4345
from esp.middleware import ESPError
4446

@@ -59,11 +61,22 @@ def viewpay_cybersource(self, request, tl, one, two, module, extra, prog):
5961
student_list = list(pac.all_students())
6062
payment_table = []
6163

64+
# Fetch detailed information for every student associated with the program
6265
for student in student_list:
6366
iac = IndividualAccountingController(prog, student)
6467
payment_table.append((student, iac.get_transfers(), iac.amount_requested(), iac.amount_due()))
6568

66-
context = { 'program': prog, 'payment_table': payment_table }
69+
# Also fetch summary information about the payments
70+
lt = pac.default_payments_lineitemtype()
71+
payments = Transfer.objects.filter(line_item=lt)
72+
73+
context = {
74+
'program': prog,
75+
'payment_table': payment_table,
76+
'num_students': len(student_list),
77+
'num_payments': payments.count(),
78+
'total_payment': payments.aggregate(total=Sum('amount_dec'))['total'],
79+
}
6780

6881
return render_to_response(self.baseDir() + 'viewpay_cybersource.html', request, context)
6982

esp/templates/program/modules/creditcardviewer_cybersource/viewpay_cybersource.html

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
{% block content %}
3232
<h1>Credit Card Payments</h1>
3333

34+
<ul>
35+
<li>Total number of students: {{ num_students }}</li>
36+
<li>Number of credit card payments so far: {{ num_payments }}</li>
37+
<li>Amount of credit card payments so far: ${{ total_payment|floatformat:2 }}</li>
38+
</ul>
39+
3440
<div id="program_form">
3541
<table>
3642

0 commit comments

Comments
 (0)