Fixes invoicing payment logic
This commit is contained in:
		
							parent
							
								
									eff5686dcf
								
							
						
					
					
						commit
						83b11cd722
					
				
					 3 changed files with 16 additions and 2 deletions
				
			
		|  | @ -122,7 +122,7 @@ class InvoiceController(object): | |||
|         ) | ||||
|         payment.save() | ||||
| 
 | ||||
|         payments = rego.Payment.objects .filter(invoice=self.invoice) | ||||
|         payments = rego.Payment.objects.filter(invoice=self.invoice) | ||||
|         agg = payments.aggregate(Sum("amount")) | ||||
|         total = agg["amount__sum"] | ||||
| 
 | ||||
|  |  | |||
|  | @ -33,5 +33,19 @@ | |||
|   </tr> | ||||
| </table> | ||||
| 
 | ||||
| <table> | ||||
|   <tr> | ||||
|     <th>Payment time</th> | ||||
|     <th>Reference</th> | ||||
|     <th>Amount</th> | ||||
|   </tr> | ||||
|   {% for payment in invoice.payment_set.all %} | ||||
|     <tr> | ||||
|       <td>{{payment.time}}</td> | ||||
|       <td>{{payment.reference}}</td> | ||||
|       <td>{{payment.amount}}</td> | ||||
|     </tr> | ||||
|   {% endfor %} | ||||
| </table> | ||||
| 
 | ||||
| {% endblock %} | ||||
|  |  | |||
|  | @ -217,7 +217,7 @@ def pay_invoice(request, invoice_id): | |||
|     invoice_id = int(invoice_id) | ||||
|     inv = rego.Invoice.objects.get(pk=invoice_id) | ||||
|     current_invoice = InvoiceController(inv) | ||||
|     if not inv.paid and not current_invoice.is_valid(): | ||||
|     if not inv.paid and current_invoice.is_valid(): | ||||
|         current_invoice.pay("Demo invoice payment", inv.value) | ||||
| 
 | ||||
|     return redirect("invoice", current_invoice.invoice.id) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer