From 4ba308357cd8bf39486bb683d23a48f7d5700caf Mon Sep 17 00:00:00 2001 From: tomtom5152 Date: Wed, 4 Mar 2015 15:49:00 +0000 Subject: [PATCH] Fix for #9 Added ORDER BY statement to the invoice page. Ordered all other invoice pages. --- RIGS/finance.py | 11 ++++++++--- RIGS/models.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RIGS/finance.py b/RIGS/finance.py index 5632dea0..46e4a6eb 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -22,7 +22,8 @@ class InvoiceIndex(generic.ListView): "(SELECT SUM(p.amount) FROM \"RIGS_payment\" as p WHERE p.invoice_id=\"RIGS_invoice\".id) AS \"payments\", " \ "\"RIGS_invoice\".\"id\", \"RIGS_invoice\".\"event_id\", \"RIGS_invoice\".\"invoice_date\", \"RIGS_invoice\".\"void\" FROM \"RIGS_invoice\") " \ "AS sub " \ - "WHERE (((cost > 0.0) AND (payment_count=0)) OR (cost - payments) <> 0.0) AND void = '0'" + "WHERE (((cost > 0.0) AND (payment_count=0)) OR (cost - payments) <> 0.0) AND void = '0'" \ + "ORDER BY invoice_date" query = self.model.objects.raw(sql) @@ -56,9 +57,13 @@ class InvoiceWaiting(generic.ListView): template_name = 'RIGS/event_invoice.html' 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(), - invoice__isnull=True).select_related('person', 'organisation', 'venue', - 'mic') # @todo find a way to select items + invoice__isnull=True) \ + .order_by('start_date') \ + .select_related('person', + 'organisation', + 'venue', 'mic') return events diff --git a/RIGS/models.py b/RIGS/models.py index 56886ca0..6ed759b7 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -366,6 +366,7 @@ class Invoice(models.Model): permissions = ( ('view_invoice', 'Can view Invoices'), ) + ordering = ['-invoice_date'] class Payment(models.Model):