From 5f7fc0b8e8db205f26291cc055d9fef355bb675c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 18 Mar 2023 19:33:41 +0800 Subject: [PATCH] Added the is_real pseudo property to the Account data model, and changed the is_nominal pseudo property to be the opposite of the is_real pseudo property. --- src/accounting/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index 43ca54c..f9f6615 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -198,13 +198,21 @@ class Account(db.Model): return self.l10n.append(AccountL10n(locale=current_locale, title=value)) + @property + def is_real(self) -> bool: + """Returns whether the account is a real account. + + :return: True if the account is a real account, or False otherwise. + """ + return self.base_code[0] in {"1", "2", "3"} + @property def is_nominal(self) -> bool: """Returns whether the account is a nominal account. :return: True if the account is a nominal account, or False otherwise. """ - return self.base_code[0] not in {"1", "2", "3"} + return not self.is_real @property def query_values(self) -> list[str]: