From 83b11cd7224d66ae67ccf6df34d15ff915b2b8a7 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Thu, 24 Mar 2016 14:20:29 +1100 Subject: [PATCH] Fixes invoicing payment logic --- registrasion/controllers/invoice.py | 2 +- registrasion/templates/invoice.html | 14 ++++++++++++++ registrasion/views.py | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/registrasion/controllers/invoice.py b/registrasion/controllers/invoice.py index e9a654e4..b8087c98 100644 --- a/registrasion/controllers/invoice.py +++ b/registrasion/controllers/invoice.py @@ -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"] diff --git a/registrasion/templates/invoice.html b/registrasion/templates/invoice.html index a66132cf..bd503657 100644 --- a/registrasion/templates/invoice.html +++ b/registrasion/templates/invoice.html @@ -33,5 +33,19 @@ + + + + + + + {% for payment in invoice.payment_set.all %} + + + + + + {% endfor %} +
Payment timeReferenceAmount
{{payment.time}}{{payment.reference}}{{payment.amount}}
{% endblock %} diff --git a/registrasion/views.py b/registrasion/views.py index 6288f4b2..64f4e4b1 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -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)