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:
parent
11ab4a4ba6
commit
cb89f34455
@ -30,7 +30,7 @@ from accounting.report.period import Period
|
||||
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 BalanceSheetPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
@ -297,8 +297,8 @@ class CSVRow(BaseCSVRow):
|
||||
self.liability_title, self.liability_amount]
|
||||
|
||||
|
||||
class BalanceSheetPageParams(PageParams):
|
||||
"""The HTML parameters of the balance sheet."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, currency: Currency,
|
||||
period: Period,
|
||||
@ -306,7 +306,7 @@ class BalanceSheetPageParams(PageParams):
|
||||
assets: BalanceSheetSection,
|
||||
liabilities: BalanceSheetSection,
|
||||
owner_s_equity: BalanceSheetSection):
|
||||
"""Constructs the HTML parameters of the balance sheet.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param currency: The currency.
|
||||
:param period: The period.
|
||||
@ -485,8 +485,7 @@ class BalanceSheet(BaseReport):
|
||||
|
||||
:return: The report as HTML.
|
||||
"""
|
||||
params: BalanceSheetPageParams = BalanceSheetPageParams(
|
||||
currency=self.__currency,
|
||||
params: PageParams = PageParams(currency=self.__currency,
|
||||
period=self.__period,
|
||||
has_data=self.__has_data,
|
||||
assets=self.__assets,
|
||||
|
@ -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,8 +474,7 @@ 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,
|
||||
params: PageParams = PageParams(currency=self.__currency,
|
||||
account=self.__account,
|
||||
period=self.__period,
|
||||
has_data=has_data,
|
||||
|
@ -30,7 +30,7 @@ from accounting.report.period import Period
|
||||
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 IncomeStatementPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
@ -138,14 +138,14 @@ class CSVRow(BaseCSVRow):
|
||||
return [self.text, self.amount]
|
||||
|
||||
|
||||
class IncomeStatementPageParams(PageParams):
|
||||
"""The HTML parameters of the income statement."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, currency: Currency,
|
||||
period: Period,
|
||||
has_data: bool,
|
||||
sections: list[IncomeStatementSection],):
|
||||
"""Constructs the HTML parameters of the income statement.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param currency: The currency.
|
||||
:param period: The period.
|
||||
@ -340,8 +340,7 @@ class IncomeStatement(BaseReport):
|
||||
|
||||
:return: The report as HTML.
|
||||
"""
|
||||
params: IncomeStatementPageParams = IncomeStatementPageParams(
|
||||
currency=self.__currency,
|
||||
params: PageParams = PageParams(currency=self.__currency,
|
||||
period=self.__period,
|
||||
has_data=self.__has_data,
|
||||
sections=self.__sections)
|
||||
|
@ -30,7 +30,7 @@ from accounting.report.period import Period
|
||||
from accounting.utils.pagination import Pagination
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.page_params import PageParams
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.period_choosers import JournalPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
@ -113,13 +113,13 @@ class CSVRow(BaseCSVRow):
|
||||
self.debit, self.credit, self.note]
|
||||
|
||||
|
||||
class JournalPageParams(PageParams):
|
||||
"""The HTML parameters of the journal."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, period: Period,
|
||||
pagination: Pagination[Entry],
|
||||
entries: list[Entry]):
|
||||
"""Constructs the HTML parameters of the journal.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param period: The period.
|
||||
:param entries: The journal entries.
|
||||
@ -235,8 +235,7 @@ class Journal(BaseReport):
|
||||
pagination: Pagination[Entry] = Pagination[Entry](self.__entries)
|
||||
page_entries: list[Entry] = pagination.list
|
||||
_populate_entries(page_entries)
|
||||
params: JournalPageParams = JournalPageParams(
|
||||
period=self.__period,
|
||||
params: PageParams = PageParams(period=self.__period,
|
||||
pagination=pagination,
|
||||
entries=page_entries)
|
||||
return render_template("accounting/report/journal.html",
|
||||
|
@ -31,7 +31,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 LedgerPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
@ -223,8 +223,8 @@ class CSVRow(BaseCSVRow):
|
||||
self.debit, self.credit, self.balance, self.note]
|
||||
|
||||
|
||||
class LedgerPageParams(PageParams):
|
||||
"""The HTML parameters of the ledger."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, currency: Currency,
|
||||
account: Account,
|
||||
@ -234,7 +234,7 @@ class LedgerPageParams(PageParams):
|
||||
brought_forward: Entry | None,
|
||||
entries: list[Entry],
|
||||
total: Entry | None):
|
||||
"""Constructs the HTML parameters of the ledger.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param currency: The currency.
|
||||
:param account: The account.
|
||||
@ -426,8 +426,7 @@ class Ledger(BaseReport):
|
||||
if len(page_entries) > 0 and page_entries[-1].is_total:
|
||||
total = page_entries[-1]
|
||||
page_entries = page_entries[:-1]
|
||||
params: LedgerPageParams = LedgerPageParams(
|
||||
currency=self.__currency,
|
||||
params: PageParams = PageParams(currency=self.__currency,
|
||||
account=self.__account,
|
||||
period=self.__period,
|
||||
has_data=has_data,
|
||||
|
@ -30,7 +30,7 @@ from accounting.utils.pagination import Pagination
|
||||
from accounting.utils.query import parse_query_keywords
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download
|
||||
from .utils.page_params import PageParams
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
|
||||
@ -112,12 +112,12 @@ class CSVRow(BaseCSVRow):
|
||||
self.debit, self.credit, self.note]
|
||||
|
||||
|
||||
class SearchPageParams(PageParams):
|
||||
"""The HTML parameters of the search result."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, pagination: Pagination[Entry],
|
||||
entries: list[Entry]):
|
||||
"""Constructs the HTML parameters of the search result.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param entries: The search result entries.
|
||||
"""
|
||||
@ -297,7 +297,7 @@ class Search(BaseReport):
|
||||
pagination: Pagination[Entry] = Pagination[Entry](self.__entries)
|
||||
page_entries: list[Entry] = pagination.list
|
||||
_populate_entries(page_entries)
|
||||
params: SearchPageParams = SearchPageParams(pagination=pagination,
|
||||
params: PageParams = PageParams(pagination=pagination,
|
||||
entries=page_entries)
|
||||
return render_template("accounting/report/search.html",
|
||||
report=params)
|
||||
|
@ -29,7 +29,7 @@ from accounting.report.period import Period
|
||||
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 TrialBalancePeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
@ -98,14 +98,14 @@ class CSVRow(BaseCSVRow):
|
||||
return [self.text, self.debit, self.credit]
|
||||
|
||||
|
||||
class TrialBalancePageParams(PageParams):
|
||||
"""The HTML parameters of the trial balance."""
|
||||
class PageParams(BasePageParams):
|
||||
"""The HTML page parameters."""
|
||||
|
||||
def __init__(self, currency: Currency,
|
||||
period: Period,
|
||||
accounts: list[TrialBalanceAccount],
|
||||
total: TrialBalanceTotal):
|
||||
"""Constructs the HTML parameters of the trial balance.
|
||||
"""Constructs the HTML page parameters.
|
||||
|
||||
:param currency: The currency.
|
||||
:param period: The period.
|
||||
@ -256,8 +256,7 @@ class TrialBalance(BaseReport):
|
||||
|
||||
:return: The report as HTML.
|
||||
"""
|
||||
params: TrialBalancePageParams = TrialBalancePageParams(
|
||||
currency=self.__currency,
|
||||
params: PageParams = PageParams(currency=self.__currency,
|
||||
period=self.__period,
|
||||
accounts=self.__accounts,
|
||||
total=self.__total)
|
||||
|
@ -28,8 +28,8 @@ from accounting.utils.txn_types import TransactionType
|
||||
from .report_chooser import ReportChooser
|
||||
|
||||
|
||||
class PageParams(ABC):
|
||||
"""The page parameters of a report."""
|
||||
class BasePageParams(ABC):
|
||||
"""The base HTML page parameters class."""
|
||||
|
||||
@property
|
||||
@abstractmethod
|
Loading…
Reference in New Issue
Block a user