Changeset - 4dbe69574c2a
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-09-03 02:17:39
chrisjrn@gmail.com
Adds report that tracks the free money in the system

Fixes #52
2 files changed with 37 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/reporting/views.py
Show inline comments
...
 
@@ -89,6 +89,42 @@ def items_sold(request, form):
 
    return Report("Paid items", headings, data)
 

	
 

	
 
@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)
 
def product_status(request, form):
 
    ''' Summarises the inventory status of the given items, grouping by
registrasion/urls.py
Show inline comments
...
 
@@ -42,6 +42,7 @@ reports = [
 
    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)