Fixed and moved the account_text pseudo property from the RecurringExpenseForm form to its base RecurringItemForm form.

This commit is contained in:
依瑪貓 2023-03-22 19:28:46 +08:00
parent 37a4c26f86
commit 067afdb165

View File

@ -108,6 +108,17 @@ class RecurringItemForm(FlaskForm):
description_template = StringField()
"""The description template."""
@property
def account_text(self) -> str | None:
"""Returns the account text.
:return: The account text.
"""
if self.account_code.data is None:
return None
account: Account | None = Account.find_by_code(self.account_code.data)
return None if account is None else str(account)
class RecurringExpenseForm(RecurringItemForm):
"""The sub-form to add or update the recurring expenses."""
@ -130,17 +141,6 @@ class RecurringExpenseForm(RecurringItemForm):
"Please fill in the description template."))])
"""The template for the line item description."""
@property
def account_text(self) -> str | None:
"""Returns the account text.
:return: The account text.
"""
if self.account_code.data is None:
return None
account: Account | None = Account.find_by_code(self.account_code.data)
return None if account is None else str(account)
class RecurringIncomeForm(RecurringItemForm):
"""The sub-form to add or update the recurring incomes."""