From 598bb39f846289f0353aa09a457a67edf1d33416 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Tue, 3 Nov 2015 11:09:04 +0000 Subject: [PATCH] Added ne bill total list filter --- TODO.md | 2 ++ orchestra/contrib/bills/filters.py | 5 ++++- orchestra/contrib/orders/billing.py | 9 ++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 7b243d91..c3daa469 100644 --- a/TODO.md +++ b/TODO.md @@ -447,3 +447,5 @@ mkhomedir_helper or create ssh homes with bash.rc and such # show base and total desglosed + +# CLOSE&DOWNLOAD doesn't redirect to anything, confusing for users diff --git a/orchestra/contrib/bills/filters.py b/orchestra/contrib/bills/filters.py index 4aa772fd..14a64765 100644 --- a/orchestra/contrib/bills/filters.py +++ b/orchestra/contrib/bills/filters.py @@ -49,8 +49,9 @@ class TotalListFilter(SimpleListFilter): def lookups(self, request, model_admin): return ( ('gt', mark_safe("total > 0")), - ('eq', "total = 0"), ('lt', mark_safe("total < 0")), + ('eq', "total = 0"), + ('ne', mark_safe("total ≠ 0")), ) def queryset(self, request, queryset): @@ -60,6 +61,8 @@ class TotalListFilter(SimpleListFilter): return queryset.filter(approx_total=0) elif self.value() == 'lt': return queryset.filter(approx_total__lt=0) + elif self.value() == 'ne': + return queryset.exclude(approx_total=0) return queryset diff --git a/orchestra/contrib/orders/billing.py b/orchestra/contrib/orders/billing.py index 813ae9c0..f199bb44 100644 --- a/orchestra/contrib/orders/billing.py +++ b/orchestra/contrib/orders/billing.py @@ -22,7 +22,9 @@ class BillsBackend(object): bill = ProForma.objects.create(account=account) else: bill = ProForma.objects.filter(account=account, is_open=True).last() - if not bill: + if bill: + bill.updated() + else: bill = ProForma.objects.create(account=account, is_open=True) bills.append(bill) else: @@ -37,7 +39,9 @@ class BillsBackend(object): bill = Invoice.objects.create(account=account) else: bill = Invoice.objects.filter(account=account, is_open=True).last() - if not bill: + if bill: + bill.updated() + else: bill = Invoice.objects.create(account=account, is_open=True) bills.append(bill) else: @@ -58,7 +62,6 @@ class BillsBackend(object): order_billed_until=line.order.old_billed_until ) self.create_sublines(billine, line.discounts) - bill.updated() return bills # def format_period(self, ini, end):