Changeset - c64d0eaab857
[Not reviewed]
Merge
0 3 0
Christopher Neugebauer - 8 years ago 2016-09-03 03:53:09
chrisjrn@gmail.com
Merge branch 'chrisjrn/more_reports'
3 files changed with 76 insertions and 21 deletions:
0 comments (0 inline, 0 general)
registrasion/models/people.py
Show inline comments
...
 
@@ -69,2 +69,9 @@ class AttendeeProfileBase(models.Model):
 

	
 
    def attendee_name(self):
 
        if type(self) == AttendeeProfileBase:
 
            real = AttendeeProfileBase.objects.get_subclass(id=self.id)
 
        else:
 
            real = self
 
        return getattr(real, real.name_field())
 

	
 
    def invoice_recipient(self):
registrasion/reporting/views.py
Show inline comments
...
 
@@ -91,2 +91,38 @@ def items_sold(request, form):
 

	
 
@report_view("Reconcilitation")
 
def reconciliation(request, form):
 
    ''' Reconciles all sales in the system with the payments in the
 
    system. '''
 

	
 
    headings = ["Thing", "Total"]
 
    data = []
 

	
 
    sales = commerce.LineItem.objects.filter(
 
        invoice__status=commerce.Invoice.STATUS_PAID,
 
    ).values(
 
        "price", "quantity"
 
    ).aggregate(total=Sum(F("price") * F("quantity")))
 

	
 
    data.append(["Paid items", sales["total"]])
 

	
 
    payments = commerce.PaymentBase.objects.values(
 
        "amount",
 
    ).aggregate(total=Sum("amount"))
 

	
 
    data.append(["Payments", payments["total"]])
 

	
 
    ucn = commerce.CreditNote.unclaimed().values(
 
        "amount"
 
    ).aggregate(total=Sum("amount"))
 

	
 
    data.append(["Unclaimed credit notes", 0 - ucn["total"]])
 

	
 
    data.append([
 
        "(Money not on invoices)",
 
        sales["total"] - payments["total"] - ucn["total"],
 
    ])
 

	
 
    return Report("Sales and Payments", headings, data)
 

	
 

	
 
@report_view("Product status", form_type=forms.ProductAndCategoryForm)
...
 
@@ -273,2 +309,19 @@ def attendee(request, form, attendee_id=None):
 

	
 
    # All payments
 
    headings = ["To Invoice", "Payment ID", "Reference", "Amount"]
 
    data = []
 

	
 
    payments = commerce.PaymentBase.objects.filter(
 
        invoice__user=attendee.user,
 
    )
 
    for payment in payments:
 
        data.append([
 
            payment.invoice.id, payment.id, payment.reference, payment.amount,
 
        ])
 

	
 
    reports.append(
 
        Report("Payments", headings, data, link_view="invoice")
 
    )
 

	
 

	
 
    return reports
...
 
@@ -281,5 +334,6 @@ def attendee_list(request):
 
        "attendeeprofilebase",
 
        "user",
 
    )
 

	
 
    attendees = attendees.values("id", "user__email").annotate(
 
    attendees = attendees.annotate(
 
        has_registered=Count(
...
 
@@ -290,3 +344,3 @@ def attendee_list(request):
 
    headings = [
 
        "User ID", "Email", "Has registered",
 
        "User ID", "Name", "Email", "Has registered",
 
    ]
...
 
@@ -297,5 +351,6 @@ def attendee_list(request):
 
        data.append([
 
            attendee["id"],
 
            attendee["user__email"],
 
            attendee["has_registered"],
 
            attendee.id,
 
            attendee.attendeeprofilebase.attendee_name(),
 
            attendee.user.email,
 
            attendee.has_registered > 0,
 
        ])
...
 
@@ -303,3 +358,3 @@ def attendee_list(request):
 
    # Sort by whether they've registered, then ID.
 
    data.sort(key=lambda attendee: (-attendee[2], attendee[0]))
 
    data.sort(key=lambda attendee: (-attendee[3], attendee[0]))
 

	
registrasion/urls.py
Show inline comments
 
from reporting import views as reporting_views
 
from reporting import views as rv
 

	
...
 
@@ -38,16 +38,9 @@ public = [
 
reports = [
 
    url(r"^$", reporting_views.reports_list, name="reports_list"),
 
    url(r"^attendee/?$", reporting_views.attendee, name="attendee"),
 
    url(r"^attendee/([0-9]*)$", reporting_views.attendee, name="attendee"),
 
    url(
 
        r"^credit_notes/?$",
 
        reporting_views.credit_notes,
 
        name="credit_notes"
 
    ),
 
    url(
 
        r"^product_status/?$",
 
        reporting_views.product_status,
 
        name="product_status",
 
    ),
 
    url(r"^items_sold/?$", reporting_views.items_sold, name="items_sold"),
 
    url(r"^$", rv.reports_list, name="reports_list"),
 
    url(r"^attendee/?$", rv.attendee, name="attendee"),
 
    url(r"^attendee/([0-9]*)$", rv.attendee, name="attendee"),
 
    url(r"^credit_notes/?$", rv.credit_notes, name="credit_notes"),
 
    url(r"^items_sold/?$", rv.items_sold, name="items_sold"),
 
    url(r"^product_status/?$", rv.product_status, name="product_status"),
 
    url(r"^reconciliation/?$", rv.reconciliation, name="reconciliation"),
 
]
0 comments (0 inline, 0 general)