Shortened the names of the BalanceSheetSubsection and BalanceSheetSubsection classes to Section and Subsection, respectively.

This commit is contained in:
依瑪貓 2023-03-08 17:41:07 +08:00
parent d47e2e231b
commit fb06e9db44

View File

@ -54,11 +54,11 @@ class BalanceSheetAccount:
"""The URL to the ledger of the account.""" """The URL to the ledger of the account."""
class BalanceSheetSubsection: class Subsection:
"""A subsection in the balance sheet.""" """A subsection."""
def __init__(self, title: BaseAccount): def __init__(self, title: BaseAccount):
"""Constructs a subsection in the balance sheet. """Constructs a subsection.
:param title: The title account. :param title: The title account.
""" """
@ -76,17 +76,17 @@ class BalanceSheetSubsection:
return sum([x.amount for x in self.accounts]) return sum([x.amount for x in self.accounts])
class BalanceSheetSection: class Section:
"""A section in the balance sheet.""" """A section."""
def __init__(self, title: BaseAccount): def __init__(self, title: BaseAccount):
"""Constructs a section in the balance sheet. """Constructs a section.
:param title: The title account. :param title: The title account.
""" """
self.title: BaseAccount = title self.title: BaseAccount = title
"""The title account.""" """The title account."""
self.subsections: list[BalanceSheetSubsection] = [] self.subsections: list[Subsection] = []
"""The subsections in the section.""" """The subsections in the section."""
@property @property
@ -303,9 +303,9 @@ class PageParams(BasePageParams):
def __init__(self, currency: Currency, def __init__(self, currency: Currency,
period: Period, period: Period,
has_data: bool, has_data: bool,
assets: BalanceSheetSection, assets: Section,
liabilities: BalanceSheetSection, liabilities: Section,
owner_s_equity: BalanceSheetSection): owner_s_equity: Section):
"""Constructs the HTML page parameters. """Constructs the HTML page parameters.
:param currency: The currency. :param currency: The currency.
@ -321,11 +321,11 @@ 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.assets: BalanceSheetSection = assets self.assets: Section = assets
"""The assets.""" """The assets."""
self.liabilities: BalanceSheetSection = liabilities self.liabilities: Section = liabilities
"""The liabilities.""" """The liabilities."""
self.owner_s_equity: BalanceSheetSection = owner_s_equity self.owner_s_equity: Section = owner_s_equity
"""The owner's equity.""" """The owner's equity."""
self.period_chooser: BalanceSheetPeriodChooser \ self.period_chooser: BalanceSheetPeriodChooser \
= BalanceSheetPeriodChooser(currency) = BalanceSheetPeriodChooser(currency)
@ -385,11 +385,11 @@ class BalanceSheet(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.__assets: BalanceSheetSection self.__assets: Section
"""The assets.""" """The assets."""
self.__liabilities: BalanceSheetSection self.__liabilities: Section
"""The liabilities.""" """The liabilities."""
self.__owner_s_equity: BalanceSheetSection self.__owner_s_equity: Section
"""The owner's equity.""" """The owner's equity."""
self.__set_data() self.__set_data()
@ -408,10 +408,9 @@ class BalanceSheet(BaseReport):
.filter(BaseAccount.code.in_({x.account.base_code[:2] .filter(BaseAccount.code.in_({x.account.base_code[:2]
for x in balances})).all() for x in balances})).all()
sections: dict[str, BalanceSheetSection] \ sections: dict[str, Section] = {x.code: Section(x) for x in titles}
= {x.code: BalanceSheetSection(x) for x in titles} subsections: dict[str, Subsection] = {x.code: Subsection(x)
subsections: dict[str, BalanceSheetSubsection] \ for x in subtitles}
= {x.code: BalanceSheetSubsection(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:
@ -465,7 +464,7 @@ class BalanceSheet(BaseReport):
return rows return rows
@staticmethod @staticmethod
def __section_csv_rows(section: BalanceSheetSection) -> list[CSVHalfRow]: def __section_csv_rows(section: Section) -> list[CSVHalfRow]:
"""Gathers the CSV rows for a section. """Gathers the CSV rows for a section.
:param section: The section. :param section: The section.