diff --git a/src/accounting/option/forms.py b/src/accounting/option/forms.py index 9e4906b..8cb0663 100644 --- a/src/accounting/option/forms.py +++ b/src/accounting/option/forms.py @@ -27,7 +27,7 @@ from accounting.forms import CurrencyExists, AccountExists, IsDebitAccount, \ IsCreditAccount from accounting.locale import lazy_gettext from accounting.models import Account -from accounting.utils.current_account import CurrentAccount, current_accounts +from accounting.utils.current_account import CurrentAccount from accounting.utils.options import Options from accounting.utils.strip_text import strip_text @@ -240,4 +240,4 @@ class OptionForm(FlaskForm): :return: The current accounts. """ - return current_accounts() + return CurrentAccount.accounts() diff --git a/src/accounting/utils/current_account.py b/src/accounting/utils/current_account.py index fcd6c47..14df622 100644 --- a/src/accounting/utils/current_account.py +++ b/src/accounting/utils/current_account.py @@ -66,19 +66,18 @@ class CurrentAccount: account.str = account.title return account + @classmethod + def accounts(cls) -> list[t.Self]: + """Returns the current assets and liabilities accounts. -def current_accounts() -> list[CurrentAccount]: - """Returns accounts for the income and expenses log. - - :return: The accounts for the income and expenses log. - """ - accounts: list[CurrentAccount] \ - = [CurrentAccount.current_assets_and_liabilities()] - accounts.extend([CurrentAccount(x) - for x in db.session.query(Account) - .filter(sa.or_(Account.base_code.startswith("11"), - Account.base_code.startswith("12"), - Account.base_code.startswith("21"), - Account.base_code.startswith("22"))) - .order_by(Account.base_code, Account.no)]) - return accounts + :return: The current assets and liabilities accounts. + """ + accounts: list[cls] = [cls.current_assets_and_liabilities()] + accounts.extend([CurrentAccount(x) + for x in db.session.query(Account) + .filter(sa.or_(Account.base_code.startswith("11"), + Account.base_code.startswith("12"), + Account.base_code.startswith("21"), + Account.base_code.startswith("22"))) + .order_by(Account.base_code, Account.no)]) + return accounts