From b0a4a735f333bbc1d76fc595fba3477eea8e8237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 8 Mar 2023 11:37:05 +0800 Subject: [PATCH] Added the is_a_month property to the Period utility. --- src/accounting/report/period.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/accounting/report/period.py b/src/accounting/report/period.py index 4c0413d..62a8ca6 100644 --- a/src/accounting/report/period.py +++ b/src/accounting/report/period.py @@ -63,6 +63,8 @@ class Period: """The period specification.""" self.desc: str = "" """The text description.""" + self.is_a_month: bool = False + """Whether the period is a whole month.""" self.is_type_month: bool = False """Whether the period is for the month chooser.""" self.is_a_year: bool = False @@ -89,8 +91,9 @@ class Period: self.desc = self.__get_desc() if self.start is None or self.end is None: return - self.is_type_month \ - = self.start.day == 1 and self.end == _month_end(self.start) + self.is_a_month = self.start.day == 1 \ + and self.end == _month_end(self.start) + self.is_type_month = self.is_a_month self.is_a_year = self.start == datetime.date(self.start.year, 1, 1) \ and self.end == datetime.date(self.start.year, 12, 31) self.is_a_day = self.start == self.end