Changeset - 4c9f426a472c
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-09-13 06:26:40
chrisjrn@gmail.com
Simplifies a bunch of older reports.
1 file changed with 12 insertions and 24 deletions:
0 comments (0 inline, 0 general)
registrasion/reporting/views.py
Show inline comments
...
 
@@ -242,97 +242,85 @@ def credit_notes(request, form):
 

	
 
    return ListReport(
 
        "Credit Notes",
 
        headings,
 
        data,
 
        link_view=views.credit_note,
 
    )
 

	
 

	
 
@report_view("Attendee", form_type=forms.UserIdForm)
 
def attendee(request, form, user_id=None):
 
    ''' Returns a list of all manifested attendees if no attendee is specified,
 
    else displays the attendee manifest. '''
 

	
 
    if user_id is None and not form.has_changed():
 
        return attendee_list(request)
 

	
 
    if form.cleaned_data["user"] is not None:
 
        user_id = form.cleaned_data["user"]
 

	
 
    attendee = people.Attendee.objects.get(user__id=user_id)
 
    name = attendee.attendeeprofilebase.attendee_name()
 

	
 
    reports = []
 

	
 
    links = []
 
    links.append((
 
        reverse(views.amend_registration, args=[user_id]),
 
        "Amend current cart",
 
    ))
 
    reports.append(Links("Actions for " + name, links))
 

	
 
    # Paid and pending  products
 
    ic = ItemController(attendee.user)
 
    # Paid products
 
    headings = ["Product", "Quantity"]
 
    data = []
 

	
 
    for pq in ic.items_purchased():
 
        data.append([
 
            pq.product,
 
            pq.quantity,
 
        ])
 

	
 
    reports.append(ListReport("Paid Products", headings, data))
 

	
 
    # Unpaid products
 
    headings = ["Product", "Quantity"]
 
    data = []
 

	
 
    for pq in ic.items_pending():
 
        data.append([
 
            pq.product,
 
            pq.quantity,
 
        ])
 

	
 
    reports.append(ListReport("Unpaid Products", headings, data))
 
    reports.append(ListReport(
 
        "Paid Products",
 
        ["Product", "Quantity"],
 
        [(pq.product, pq.quantity) for pq in ic.items_purchased()],
 
    ))
 
    reports.append(ListReport(
 
        "Unpaid Products",
 
        ["Product", "Quantity"],
 
        [(pq.product, pq.quantity) for pq in ic.items_pending()],
 
    ))
 

	
 
    # Invoices
 
    # TODO make this a querysetreport
 
    headings = ["Invoice ID", "Status", "Value"]
 
    data = []
 

	
 
    invoices = commerce.Invoice.objects.filter(
 
        user=attendee.user,
 
    )
 
    # TODO make this a querysetreport
 
    for invoice in invoices:
 
        data.append([
 
            invoice.id, invoice.get_status_display(), invoice.value,
 
        ])
 

	
 
    reports.append(
 
        ListReport("Invoices", headings, data, link_view=views.invoice)
 
    )
 

	
 
    # Credit Notes
 
    credit_notes = commerce.CreditNote.objects.filter(
 
        invoice__user=attendee.user,
 
    )
 
    reports.append(QuerysetReport(
 
        "Credit Notes",
 
        ["Note ID", "Status", "Value"],
 
        ["id", "status", "value"],
 
        credit_notes,
 
        link_view=views.credit_note,
 
    ))
 

	
 
    # All payments
 
    payments = commerce.PaymentBase.objects.filter(
 
        invoice__user=attendee.user,
 
    )
 
    reports.append(QuerysetReport(
 
        "Payments",
 
        ["To Invoice", "Payment ID", "Reference", "Amount"],
 
        ["invoice__id", "id", "reference", "amount"],
 
        payments,
 
        link_view=views.invoice,
 
    ))
0 comments (0 inline, 0 general)