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.

This commit is contained in:
依瑪貓 2023-03-18 19:33:41 +08:00
parent 700c179774
commit 5f7fc0b8e8

View File

@ -198,13 +198,21 @@ class Account(db.Model):
return return
self.l10n.append(AccountL10n(locale=current_locale, title=value)) 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 @property
def is_nominal(self) -> bool: def is_nominal(self) -> bool:
"""Returns whether the account is a nominal account. """Returns whether the account is a nominal account.
:return: True if the account is a nominal account, or False otherwise. :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 @property
def query_values(self) -> list[str]: def query_values(self) -> list[str]: