From 0511dd5df2a753fea9273d7a7cdd3d0355659223 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sat, 17 Feb 2018 16:45:57 -0500 Subject: Order invoiceitems by date --- app/dispatch/models.py | 3 +++ app/dispatch/templates/dispatch/invoice/detail-table.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dispatch/models.py b/app/dispatch/models.py index 451eb31..1d2bae2 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -177,6 +177,9 @@ class Invoice(models.Model): def items(self): return InvoiceItem.objects.filter(invoice__exact=self.pk) + def items_by_date(self): + return InvoiceItem.objects.filter(invoice__exact=self.pk).order_by('date') + def total(self): t = 0 for i in InvoiceItem.objects.filter(invoice__exact=self.pk): diff --git a/app/dispatch/templates/dispatch/invoice/detail-table.html b/app/dispatch/templates/dispatch/invoice/detail-table.html index d09ba76..6f18269 100644 --- a/app/dispatch/templates/dispatch/invoice/detail-table.html +++ b/app/dispatch/templates/dispatch/invoice/detail-table.html @@ -54,7 +54,7 @@ Total - {% for item in object.items %} + {% for item in object.items_by_date %} {{item.date|date:"m/d/Y"}} {{item.description}} -- cgit v1.2.3