Makes as many reports under attendee() as possible a QuerysetReport

This commit is contained in:
Christopher Neugebauer 2016-09-13 16:24:50 +10:00
parent fa717dee65
commit f7326eedf7

View file

@ -303,6 +303,7 @@ def attendee(request, form, user_id=None):
invoices = commerce.Invoice.objects.filter( invoices = commerce.Invoice.objects.filter(
user=attendee.user, user=attendee.user,
) )
# TODO make this a querysetreport
for invoice in invoices: for invoice in invoices:
data.append([ data.append([
invoice.id, invoice.get_status_display(), invoice.value, invoice.id, invoice.get_status_display(), invoice.value,
@ -313,32 +314,24 @@ def attendee(request, form, user_id=None):
) )
# Credit Notes # Credit Notes
headings = ["Note ID", "Status", "Value"]
data = []
credit_notes = commerce.CreditNote.objects.filter( credit_notes = commerce.CreditNote.objects.filter(
invoice__user=attendee.user, invoice__user=attendee.user,
) )
for credit_note in credit_notes: reports.append(QuerysetReport(
data.append([ "Credit Notes",
credit_note.id, credit_note.status, credit_note.value, ["Note ID", "Status", "Value"],
]) ["id", "status", "value"],
credit_notes,
reports.append( link_view=views.credit_note,
ListReport("Credit Notes", headings, data, link_view=views.credit_note) ))
)
# All payments # All payments
headings = ["To Invoice", "Payment ID", "Reference", "Amount"]
data = []
payments = commerce.PaymentBase.objects.filter( payments = commerce.PaymentBase.objects.filter(
invoice__user=attendee.user, invoice__user=attendee.user,
) )
reports.append(QuerysetReport( reports.append(QuerysetReport(
"Payments", "Payments",
headings, ["To Invoice", "Payment ID", "Reference", "Amount"],
["invoice__id", "id", "reference", "amount"], ["invoice__id", "id", "reference", "amount"],
payments, payments,
link_view=views.invoice, link_view=views.invoice,