From 116d00a557789b026802f3e35855b43bbd646502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 8 Mar 2023 07:41:19 +0800 Subject: [PATCH] Replaced the hard-coded cash account codes with the ACCUMULATED_CHANGE and NET_CHANGE constants and the accumulated_change() method of the Account data model. --- src/accounting/report/reports/balance_sheet.py | 6 ++---- src/accounting/report/reports/income_expenses.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/accounting/report/reports/balance_sheet.py b/src/accounting/report/reports/balance_sheet.py index 5caeeb1..c5ae4c4 100644 --- a/src/accounting/report/reports/balance_sheet.py +++ b/src/accounting/report/reports/balance_sheet.py @@ -176,12 +176,11 @@ class AccountCollector: :return: None. """ - code: str = "3351-001" amount: Decimal | None = self.__query_accumulated() url: str = url_for("accounting.report.income-statement", currency=self.__currency, period=self.__period.before) - self.__add_owner_s_equity(code, amount, url) + self.__add_owner_s_equity(Account.ACCUMULATED_CHANGE, amount, url) def __query_accumulated(self) -> Decimal | None: """Queries and returns the accumulated profit or loss. @@ -207,11 +206,10 @@ class AccountCollector: :return: None. """ - code: str = "3353-001" amount: Decimal | None = self.__query_currency_period() url: str = url_for("accounting.report.income-statement", currency=self.__currency, period=self.__period) - self.__add_owner_s_equity(code, amount, url) + self.__add_owner_s_equity(Account.ACCUMULATED_CHANGE, amount, url) def __query_currency_period(self) -> Decimal | None: """Queries and returns the net income or loss for current period. diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index 9dd19c3..dc492d4 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -125,7 +125,7 @@ class EntryCollector: entry: Entry = Entry() entry.is_brought_forward = True entry.date = self.__period.start - entry.account = Account.find_by_code("3351-001") + entry.account = Account.accumulated_change() entry.summary = gettext("Brought forward") if balance > 0: entry.income = balance