From 7ccc8faf20a308cfae943aad60a8b77918b459db Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 24 May 2016 17:32:58 +0100 Subject: [PATCH] Add total for waiting events --- RIGS/finance.py | 8 ++++++++ RIGS/templates/RIGS/event_invoice.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/RIGS/finance.py b/RIGS/finance.py index 57721a9f..9025e15b 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -103,6 +103,14 @@ class InvoiceWaiting(generic.ListView): paginate_by = 25 template_name = 'RIGS/event_invoice.html' + def get_context_data(self, **kwargs): + context = super(InvoiceWaiting, self).get_context_data(**kwargs) + total = 0 + for obj in context['object_list']: + total += obj.sum_total + context['total'] = total + return context + def get_queryset(self): # @todo find a way to select items events = self.model.objects.filter(is_rig=True, end_date__lt=datetime.date.today(), diff --git a/RIGS/templates/RIGS/event_invoice.html b/RIGS/templates/RIGS/event_invoice.html index 805eb3d9..29c56f42 100644 --- a/RIGS/templates/RIGS/event_invoice.html +++ b/RIGS/templates/RIGS/event_invoice.html @@ -5,7 +5,7 @@ {% block content %}
-

Events for Invoice

+

Events for Invoice (£ {{ total|floatformat:2 }})

{% if is_paginated %}
{% paginator %}