Renamed the "PageParams" class to "BasePageParams", and renamed its module from "accounting.report.reports.utils.page_params" to "accounting.report.reports.utils.base_page_params". Renamed all its subclasses to PageParams, to shorten their names and make code more readable.

This commit is contained in:
2023-03-08 17:27:19 +08:00
parent 11ab4a4ba6
commit cb89f34455
8 changed files with 65 additions and 71 deletions

View File

@ -32,7 +32,7 @@ from accounting.utils.pagination import Pagination
from .utils.base_report import BaseReport
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
from .utils.option_link import OptionLink
from .utils.page_params import PageParams
from .utils.base_page_params import BasePageParams
from .utils.period_choosers import IncomeExpensesPeriodChooser
from .utils.report_chooser import ReportChooser
from .utils.report_type import ReportType
@ -246,8 +246,8 @@ class CSVRow(BaseCSVRow):
self.income, self.expense, self.balance, self.note]
class IncomeExpensesPageParams(PageParams):
"""The HTML parameters of the income and expenses log."""
class PageParams(BasePageParams):
"""The HTML page parameters."""
def __init__(self, currency: Currency,
account: IncomeExpensesAccount,
@ -257,7 +257,7 @@ class IncomeExpensesPageParams(PageParams):
brought_forward: Entry | None,
entries: list[Entry],
total: Entry | None):
"""Constructs the HTML parameters of the income and expenses log.
"""Constructs the HTML page parameters.
:param currency: The currency.
:param account: The account.
@ -474,14 +474,13 @@ class IncomeExpenses(BaseReport):
if len(page_entries) > 0 and page_entries[-1].is_total:
total = page_entries[-1]
page_entries = page_entries[:-1]
params: IncomeExpensesPageParams = IncomeExpensesPageParams(
currency=self.__currency,
account=self.__account,
period=self.__period,
has_data=has_data,
pagination=pagination,
brought_forward=brought_forward,
entries=page_entries,
total=total)
params: PageParams = PageParams(currency=self.__currency,
account=self.__account,
period=self.__period,
has_data=has_data,
pagination=pagination,
brought_forward=brought_forward,
entries=page_entries,
total=total)
return render_template("accounting/report/income-expenses.html",
report=params)