Revised the __add_owner_s_equity method of the AccountCollector of the balance sheet to receive the period instead of the URL, and does its job when there is an amount, so that the URL is build only when there is an amount.
This commit is contained in:
parent
965df82c1c
commit
34af52e3c3
@ -165,10 +165,9 @@ class AccountCollector:
|
|||||||
|
|
||||||
:return: None.
|
:return: None.
|
||||||
"""
|
"""
|
||||||
self.__add_owner_s_equity(
|
self.__add_owner_s_equity(Account.ACCUMULATED_CHANGE_CODE,
|
||||||
Account.ACCUMULATED_CHANGE_CODE,
|
|
||||||
self.__query_accumulated(),
|
self.__query_accumulated(),
|
||||||
income_statement_url(self.__currency, self.__period.before))
|
self.__period)
|
||||||
|
|
||||||
def __query_accumulated(self) -> Decimal | None:
|
def __query_accumulated(self) -> Decimal | None:
|
||||||
"""Queries and returns the accumulated profit or loss.
|
"""Queries and returns the accumulated profit or loss.
|
||||||
@ -187,10 +186,9 @@ class AccountCollector:
|
|||||||
|
|
||||||
:return: None.
|
:return: None.
|
||||||
"""
|
"""
|
||||||
self.__add_owner_s_equity(
|
self.__add_owner_s_equity(Account.NET_CHANGE_CODE,
|
||||||
Account.NET_CHANGE_CODE,
|
|
||||||
self.__query_currency_period(),
|
self.__query_currency_period(),
|
||||||
income_statement_url(self.__currency, self.__period))
|
self.__period)
|
||||||
|
|
||||||
def __query_currency_period(self) -> Decimal | None:
|
def __query_currency_period(self) -> Decimal | None:
|
||||||
"""Queries and returns the net income or loss for current period.
|
"""Queries and returns the net income or loss for current period.
|
||||||
@ -223,25 +221,26 @@ class AccountCollector:
|
|||||||
return db.session.scalar(select_balance)
|
return db.session.scalar(select_balance)
|
||||||
|
|
||||||
def __add_owner_s_equity(self, code: str, amount: Decimal | None,
|
def __add_owner_s_equity(self, code: str, amount: Decimal | None,
|
||||||
url: str) -> None:
|
period: Period) -> None:
|
||||||
"""Adds an owner's equity balance.
|
"""Adds an owner's equity balance.
|
||||||
|
|
||||||
:param code: The code of the account to add.
|
:param code: The code of the account to add.
|
||||||
:param amount: The amount.
|
:param amount: The amount.
|
||||||
|
:param period: The period.
|
||||||
:return: None.
|
:return: None.
|
||||||
"""
|
"""
|
||||||
|
if amount is None:
|
||||||
|
return
|
||||||
|
url: str = income_statement_url(self.__currency, period)
|
||||||
# There is an existing balance.
|
# There is an existing balance.
|
||||||
account_balance_by_code: dict[str, ReportAccount] \
|
account_balance_by_code: dict[str, ReportAccount] \
|
||||||
= {x.account.code: x for x in self.accounts}
|
= {x.account.code: x for x in self.accounts}
|
||||||
if code in account_balance_by_code:
|
if code in account_balance_by_code:
|
||||||
balance: ReportAccount = account_balance_by_code[code]
|
balance: ReportAccount = account_balance_by_code[code]
|
||||||
if amount is not None:
|
|
||||||
balance.amount = balance.amount + amount
|
balance.amount = balance.amount + amount
|
||||||
balance.url = url
|
balance.url = url
|
||||||
return
|
return
|
||||||
# Add a new balance
|
# Add a new balance
|
||||||
if amount is None:
|
|
||||||
return
|
|
||||||
account_by_code: dict[str, Account] \
|
account_by_code: dict[str, Account] \
|
||||||
= {x.code: x for x in self.__all_accounts}
|
= {x.code: x for x in self.__all_accounts}
|
||||||
self.accounts.append(ReportAccount(account=account_by_code[code],
|
self.accounts.append(ReportAccount(account=account_by_code[code],
|
||||||
|
Loading…
Reference in New Issue
Block a user