parent
							
								
									96e691c5dd
								
							
						
					
					
						commit
						4dbe69574c
					
				
					 2 changed files with 37 additions and 0 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
|  | @ -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"), | ||||
| ] | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer