From 8c7ffc9b76e534097831eb00b9d7500fcc292e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 11 Aug 2020 11:13:01 +0800 Subject: [PATCH] Added to filter the empty accounts in the trial balance, income statement, and balance sheet in the accounting application. --- accounting/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index 184d120..b889875 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -529,7 +529,7 @@ def trial_balance(request, period): amount=Sum(Case( When(record__is_credit=True, then=-1), default=1) * F("record__amount"))) - .filter(amount__isnull=False) + .filter(Q(amount__isnull=False), ~Q(amount=0)) .annotate( debit_amount=Case( When(amount__gt=0, then=F("amount")), @@ -550,7 +550,7 @@ def trial_balance(request, period): amount=Sum(Case( When(record__is_credit=True, then=-1), default=1) * F("record__amount"))) - .filter(amount__isnull=False) + .filter(Q(amount__isnull=False), ~Q(amount=0)) .annotate( debit_amount=Case( When(amount__gt=0, then=F("amount")), @@ -632,7 +632,7 @@ def income_statement(request, period): amount=Sum(Case( When(record__is_credit=True, then=1), default=-1) * F("record__amount"))) - .filter(amount__isnull=False) + .filter(Q(amount__isnull=False), ~Q(amount=0)) .order_by("code")) groups = list(Account.objects.filter( code__in=[x.code[:2] for x in accounts])) @@ -707,7 +707,7 @@ def balance_sheet(request, period): amount=Sum(Case( When(record__is_credit=True, then=-1), default=1) * F("record__amount"))) - .filter(amount__isnull=False) + .filter(Q(amount__isnull=False), ~Q(amount=0)) .order_by("code")) for account in accounts: account.url = reverse("accounting:ledger", args=(account, period))