Added missing documentation to the global variables, class properties, and object properties.

This commit is contained in:
2023-06-09 07:28:47 +08:00
parent 64b9c8c11f
commit 501c4b1d22
26 changed files with 103 additions and 5 deletions

View File

@ -168,7 +168,9 @@ class AccountReorderForm:
:param base: The base account.
"""
self.base: BaseAccount = base
"""The base account."""
self.is_modified: bool = False
"""Whether the order is modified."""
def save_order(self) -> None:
"""Saves the order of the account.

View File

@ -65,6 +65,7 @@ class IsDebitAccount:
:param message: The error message.
"""
self.__message: str | LazyString = message
"""The error message."""
def __call__(self, form: FlaskForm, field: StringField) -> None:
if field.data is None:
@ -85,6 +86,7 @@ class IsCreditAccount:
:param message: The error message.
"""
self.__message: str | LazyString = message
"""The error message."""
def __call__(self, form: FlaskForm, field: StringField) -> None:
if field.data is None:

View File

@ -54,7 +54,9 @@ class JournalEntryReorderForm:
:param date: The date.
"""
self.date: dt.date = date
"""The date."""
self.is_modified: bool = False
"""Whether the order is modified."""
def save_order(self) -> None:
"""Saves the order of the account.

View File

@ -166,8 +166,11 @@ class DescriptionRecurring:
:param account: The account.
"""
self.name: str = name
"""The name."""
self.account: DescriptionAccount = DescriptionAccount(account, 0)
"""The account."""
self.description_template: str = description_template
"""The description template."""
@property
def account_codes(self) -> list[str]:

View File

@ -25,8 +25,10 @@ from flask_babel import LazyString, Domain
from flask_babel_js import JAVASCRIPT, c2js
translation_dir: Path = Path(__file__).parent / "translations"
"""The directory of the translation files."""
domain: Domain = Domain(translation_directories=[translation_dir],
domain="accounting")
"""The message domain."""
def gettext(string, **variables) -> str:
@ -120,6 +122,5 @@ def init_app(app: Flask, bp: Blueprint) -> None:
:param bp: The blueprint of the accounting application.
:return: None.
"""
bp.add_url_rule("/_jstrans.js", "babel_catalog",
__babel_js_catalog_view)
bp.add_url_rule("/_jstrans.js", "babel_catalog", __babel_js_catalog_view)
app.jinja_env.globals["A_"] = domain.gettext

View File

@ -145,6 +145,7 @@ class AccountCollector:
.filter(sa.or_(Account.id.in_({x.id for x in account_balances}),
Account.base_code == "3351",
Account.base_code == "3353")).all()
"""The accounts."""
account_by_id: dict[int, Account] \
= {x.id: x for x in self.__all_accounts}
self.accounts: list[ReportAccount] \
@ -154,6 +155,7 @@ class AccountCollector:
account_by_id[x.id],
self.__period))
for x in account_balances]
"""The accounts on the balance sheet."""
self.__add_accumulated()
self.__add_current_period()
self.accounts.sort(key=lambda x: (x.account.base_code, x.account.no))

View File

@ -106,6 +106,7 @@ class Section:
"""The subsections in the section."""
self.accumulated: AccumulatedTotal \
= AccumulatedTotal(accumulated_title)
"""The accumulated total."""
@property
def total(self) -> Decimal:

View File

@ -39,8 +39,11 @@ class RecurringItem:
:param description_template: The description template.
"""
self.name: str = name
"""The name."""
self.account_code: str = account_code
"""The account code."""
self.description_template: str = description_template
"""The description template."""
@property
def account_text(self) -> str:
@ -61,8 +64,10 @@ class Recurring:
"""
self.expenses: list[RecurringItem] \
= [RecurringItem(x[0], x[1], x[2]) for x in data["expense"]]
"""The recurring expenses."""
self.incomes: list[RecurringItem] \
= [RecurringItem(x[0], x[1], x[2]) for x in data["income"]]
"""The recurring incomes."""
@property
def codes(self) -> set[str]:

View File

@ -63,6 +63,7 @@ DEFAULT_PAGE_SIZE: int = 10
"""The default page size."""
T = TypeVar("T")
"""The pagination item type."""
class Pagination(Generic[T]):

View File

@ -27,6 +27,7 @@ from flask import g, Response
from flask_sqlalchemy.model import Model
T = TypeVar("T", bound=Model)
"""The user data model data type."""
class UserUtilityInterface(Generic[T], ABC):