Added ORDER BY statement to the invoice page.
Ordered all other invoice pages.
This commit is contained in:
tomtom5152
2015-03-04 15:49:00 +00:00
parent 0a54a1f2e3
commit 4ba308357c
2 changed files with 9 additions and 3 deletions

View File

@@ -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

View File

@@ -366,6 +366,7 @@ class Invoice(models.Model):
permissions = (
('view_invoice', 'Can view Invoices'),
)
ordering = ['-invoice_date']
class Payment(models.Model):