Shortened the names of the IncomeStatementSection, IncomeStatementSubsection, and IncomeStatementAccumulatedTotal classes to Section, Subsection, and AccumulatedTotal, respectively.

This commit is contained in:
依瑪貓 2023-03-08 17:40:08 +08:00
parent cb89f34455
commit d47e2e231b

View File

@ -54,11 +54,11 @@ class IncomeStatementAccount:
"""The URL to the ledger of the account.""" """The URL to the ledger of the account."""
class IncomeStatementAccumulatedTotal: class AccumulatedTotal:
"""An accumulated total in the income statement.""" """An accumulated total."""
def __init__(self, title: str): def __init__(self, title: str):
"""Constructs an accumulated total in the income statement. """Constructs an accumulated total.
:param title: The title. :param title: The title.
""" """
@ -68,11 +68,11 @@ class IncomeStatementAccumulatedTotal:
"""The amount of the account.""" """The amount of the account."""
class IncomeStatementSubsection: class Subsection:
"""A subsection in the income statement.""" """A subsection."""
def __init__(self, title: BaseAccount): def __init__(self, title: BaseAccount):
"""Constructs a subsection in the income statement. """Constructs a subsection.
:param title: The title account. :param title: The title account.
""" """
@ -90,21 +90,21 @@ class IncomeStatementSubsection:
return sum([x.amount for x in self.accounts]) return sum([x.amount for x in self.accounts])
class IncomeStatementSection: class Section:
"""A section in the income statement.""" """A section."""
def __init__(self, title: BaseAccount, accumulated_title: str): def __init__(self, title: BaseAccount, accumulated_title: str):
"""Constructs a section in the income statement. """Constructs a section.
:param title: The title account. :param title: The title account.
:param accumulated_title: The title for the accumulated total. :param accumulated_title: The title for the accumulated total.
""" """
self.title: BaseAccount = title self.title: BaseAccount = title
"""The title account.""" """The title account."""
self.subsections: list[IncomeStatementSubsection] = [] self.subsections: list[Subsection] = []
"""The subsections in the section.""" """The subsections in the section."""
self.accumulated: IncomeStatementAccumulatedTotal \ self.accumulated: AccumulatedTotal \
= IncomeStatementAccumulatedTotal(accumulated_title) = AccumulatedTotal(accumulated_title)
@property @property
def total(self) -> Decimal: def total(self) -> Decimal:
@ -144,7 +144,7 @@ class PageParams(BasePageParams):
def __init__(self, currency: Currency, def __init__(self, currency: Currency,
period: Period, period: Period,
has_data: bool, has_data: bool,
sections: list[IncomeStatementSection],): sections: list[Section], ):
"""Constructs the HTML page parameters. """Constructs the HTML page parameters.
:param currency: The currency. :param currency: The currency.
@ -157,7 +157,7 @@ class PageParams(BasePageParams):
"""The period.""" """The period."""
self.__has_data: bool = has_data self.__has_data: bool = has_data
"""True if there is any data, or False otherwise.""" """True if there is any data, or False otherwise."""
self.sections: list[IncomeStatementSection] = sections self.sections: list[Section] = sections
self.period_chooser: IncomeStatementPeriodChooser \ self.period_chooser: IncomeStatementPeriodChooser \
= IncomeStatementPeriodChooser(currency) = IncomeStatementPeriodChooser(currency)
"""The period chooser.""" """The period chooser."""
@ -216,7 +216,7 @@ class IncomeStatement(BaseReport):
"""The period.""" """The period."""
self.__has_data: bool self.__has_data: bool
"""True if there is any data, or False otherwise.""" """True if there is any data, or False otherwise."""
self.__sections: list[IncomeStatementSection] self.__sections: list[Section]
"""The sections.""" """The sections."""
self.__set_data() self.__set_data()
@ -241,11 +241,10 @@ class IncomeStatement(BaseReport):
"8": gettext("after tax income"), "8": gettext("after tax income"),
"9": gettext("net income or loss for current period")} "9": gettext("net income or loss for current period")}
sections: dict[str, IncomeStatementSection] \ sections: dict[str, Section] \
= {x.code: IncomeStatementSection(x, total_titles[x.code]) = {x.code: Section(x, total_titles[x.code]) for x in titles}
for x in titles} subsections: dict[str, Subsection] \
subsections: dict[str, IncomeStatementSubsection] \ = {x.code: Subsection(x) for x in subtitles}
= {x.code: IncomeStatementSubsection(x) for x in subtitles}
for subsection in subsections.values(): for subsection in subsections.values():
sections[subsection.title.code[0]].subsections.append(subsection) sections[subsection.title.code[0]].subsections.append(subsection)
for balance in balances: for balance in balances: