From 149aa8391aa726a381e86bbc6b4df74c8246bd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 8 Jul 2020 11:00:14 +0800 Subject: [PATCH] Revised the view of the cash account to use the first and last day of the data from the data source. --- accounting/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index 837d80d..d86fb4e 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -30,7 +30,7 @@ from django.utils.translation import get_language from django.views import generic from django.views.decorators.http import require_GET -from accounting.models import Record +from accounting.models import Record, Transaction from mia_core.period import Period from mia import settings from mia_core.digest_auth import digest_login_required @@ -144,8 +144,12 @@ class CashReportView(BaseReportView): Returns: List[Record]: The accounting records for the cash report """ + first_txn = Transaction.objects.order_by("date").first() + data_start = first_txn.date if first_txn is not None else None + last_txn = Transaction.objects.order_by("-date").first() + data_end = last_txn.date if last_txn is not None else None self.period = Period( - get_language(), date(2000, 1, 1), date(2030, 12, 31), + get_language(), data_start, data_end, self.kwargs["period_spec"]) if self.kwargs["subject_code"] == "0": records = Record.objects.raw(