Renamed the TrialBalanceAccount, IncomeStatementAccount, and BalanceSheetAccount classes to ReportAccount, to be short and clear.

This commit is contained in:
依瑪貓 2023-03-08 17:55:34 +08:00
parent c8230c949d
commit 729a7fd107
3 changed files with 34 additions and 34 deletions

View File

@ -36,11 +36,11 @@ from .utils.report_chooser import ReportChooser
from .utils.report_type import ReportType
class BalanceSheetAccount:
"""An account in the balance sheet."""
class ReportAccount:
"""An account in the report."""
def __init__(self, account: Account, amount: Decimal, url: str):
"""Constructs an account in the balance sheet.
"""Constructs an account in the report.
:param account: The account.
:param amount: The amount.
@ -64,7 +64,7 @@ class Subsection:
"""
self.title: BaseAccount = title
"""The title account."""
self.accounts: list[BalanceSheetAccount] = []
self.accounts: list[ReportAccount] = []
"""The accounts in the subsection."""
@property
@ -111,10 +111,10 @@ class AccountCollector:
"""The currency."""
self.__period: Period = period
"""The period."""
self.accounts: list[BalanceSheetAccount] = self.__query_balances()
self.accounts: list[ReportAccount] = self.__query_balances()
"""The balance sheet accounts."""
def __query_balances(self) -> list[BalanceSheetAccount]:
def __query_balances(self) -> list[ReportAccount]:
"""Queries and returns the balances.
:return: The balances.
@ -158,8 +158,8 @@ class AccountCollector:
currency=self.__currency, account=account,
period=self.__period)
self.accounts: list[BalanceSheetAccount] \
= [BalanceSheetAccount(account=account_by_id[x.id],
self.accounts: list[ReportAccount] \
= [ReportAccount(account=account_by_id[x.id],
amount=x.balance,
url=get_url(account_by_id[x.id]))
for x in account_balances]
@ -240,10 +240,10 @@ class AccountCollector:
:return: None.
"""
# There is an existing balance.
account_balance_by_code: dict[str, BalanceSheetAccount] \
account_balance_by_code: dict[str, ReportAccount] \
= {x.account.code: x for x in self.accounts}
if code in account_balance_by_code:
balance: BalanceSheetAccount = account_balance_by_code[code]
balance: ReportAccount = account_balance_by_code[code]
balance.url = url
if amount is not None:
balance.amount = balance.amount + amount
@ -253,7 +253,7 @@ class AccountCollector:
return
account_by_code: dict[str, Account] \
= {x.code: x for x in self.__all_accounts}
self.accounts.append(BalanceSheetAccount(account=account_by_code[code],
self.accounts.append(ReportAccount(account=account_by_code[code],
amount=amount,
url=url))
@ -399,7 +399,7 @@ class BalanceSheet(BaseReport):
:return: None.
"""
balances: list[BalanceSheetAccount] = AccountCollector(
balances: list[ReportAccount] = AccountCollector(
self.__currency, self.__period).accounts
titles: list[BaseAccount] = BaseAccount.query\

View File

@ -36,11 +36,11 @@ from .utils.report_chooser import ReportChooser
from .utils.report_type import ReportType
class IncomeStatementAccount:
"""An account in the income statement."""
class ReportAccount:
"""An account in the report."""
def __init__(self, account: Account, amount: Decimal, url: str):
"""Constructs an account in the income statement.
"""Constructs an account in the report.
:param account: The account.
:param amount: The amount.
@ -78,7 +78,7 @@ class Subsection:
"""
self.title: BaseAccount = title
"""The title account."""
self.accounts: list[IncomeStatementAccount] = []
self.accounts: list[ReportAccount] = []
"""The accounts in the subsection."""
@property
@ -225,7 +225,7 @@ class IncomeStatement(BaseReport):
:return: None.
"""
balances: list[IncomeStatementAccount] = self.__query_balances()
balances: list[ReportAccount] = self.__query_balances()
titles: list[BaseAccount] = BaseAccount.query\
.filter(BaseAccount.code.in_({"4", "5", "6", "7", "8", "9"})).all()
@ -257,7 +257,7 @@ class IncomeStatement(BaseReport):
total = total + section.total
section.accumulated.amount = total
def __query_balances(self) -> list[IncomeStatementAccount]:
def __query_balances(self) -> list[ReportAccount]:
"""Queries and returns the balances.
:return: The balances.
@ -298,7 +298,7 @@ class IncomeStatement(BaseReport):
currency=self.__currency, account=account,
period=self.__period)
return [IncomeStatementAccount(account=accounts[x.account_id],
return [ReportAccount(account=accounts[x.account_id],
amount=x.balance,
url=get_url(accounts[x.account_id]))
for x in balances]

View File

@ -35,11 +35,11 @@ from .utils.report_chooser import ReportChooser
from .utils.report_type import ReportType
class TrialBalanceAccount:
"""An account in the trial balance."""
class ReportAccount:
"""An account in the report."""
def __init__(self, account: Account, amount: Decimal, url: str):
"""Constructs an account in the trial balance.
"""Constructs an account in the report.
:param account: The account.
:param amount: The amount.
@ -103,7 +103,7 @@ class PageParams(BasePageParams):
def __init__(self, currency: Currency,
period: Period,
accounts: list[TrialBalanceAccount],
accounts: list[ReportAccount],
total: TrialBalanceTotal):
"""Constructs the HTML page parameters.
@ -116,7 +116,7 @@ class PageParams(BasePageParams):
"""The currency."""
self.period: Period = period
"""The period."""
self.accounts: list[TrialBalanceAccount] = accounts
self.accounts: list[ReportAccount] = accounts
"""The accounts in the trial balance."""
self.total: TrialBalanceTotal = total
"""The total of the trial balance."""
@ -176,7 +176,7 @@ class TrialBalance(BaseReport):
"""The currency."""
self.__period: Period = period
"""The period."""
self.__accounts: list[TrialBalanceAccount]
self.__accounts: list[ReportAccount]
"""The accounts in the trial balance."""
self.__total: TrialBalanceTotal
"""The total of the trial balance."""
@ -220,7 +220,7 @@ class TrialBalance(BaseReport):
currency=self.__currency, account=account,
period=self.__period)
self.__accounts = [TrialBalanceAccount(account=accounts[x.id],
self.__accounts = [ReportAccount(account=accounts[x.id],
amount=x.balance,
url=get_url(accounts[x.id]))
for x in balances]