From c189615ca444b0514a4a375f4815f37621f921a0 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 18:31:35 +0800 Subject: [PATCH] Renamed the CASH, ACCUMULATED_CHANGE, and NET_CHANGE constants to CASH_CODE, ACCUMULATED_CHANGE_CODE, and NET_CHANGE_CODE, respectively, to avoid confusion. --- src/accounting/models.py | 14 +++++++------- src/accounting/report/reports/balance_sheet.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index 68de0e2..839c50f 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -141,11 +141,11 @@ class Account(db.Model): entries = db.relationship("JournalEntry", back_populates="account") """The journal entries.""" - CASH = "1111-001" + CASH_CODE = "1111-001" """The code of the cash account,""" - ACCUMULATED_CHANGE = "3351-001" + ACCUMULATED_CHANGE_CODE = "3351-001" """The code of the accumulated-change account,""" - NET_CHANGE = "3353-001" + NET_CHANGE_CODE = "3353-001" """The code of the net-change account,""" def __str__(self) -> str: @@ -265,7 +265,7 @@ class Account(db.Model): :return: The cash account """ - return cls.find_by_code(cls.CASH) + return cls.find_by_code(cls.CASH_CODE) @classmethod def accumulated_change(cls) -> t.Self: @@ -273,7 +273,7 @@ class Account(db.Model): :return: The accumulated-change account """ - return cls.find_by_code(cls.ACCUMULATED_CHANGE) + return cls.find_by_code(cls.ACCUMULATED_CHANGE_CODE) @property def is_modified(self) -> bool: @@ -550,7 +550,7 @@ class Transaction(db.Model): for currency in self.currencies: if len(currency.debit) > 1: return False - if currency.debit[0].account.code != Account.CASH: + if currency.debit[0].account.code != Account.CASH_CODE: return False return True @@ -564,7 +564,7 @@ class Transaction(db.Model): for currency in self.currencies: if len(currency.credit) > 1: return False - if currency.credit[0].account.code != Account.CASH: + if currency.credit[0].account.code != Account.CASH_CODE: return False return True diff --git a/src/accounting/report/reports/balance_sheet.py b/src/accounting/report/reports/balance_sheet.py index 5ea269e..49f1fad 100644 --- a/src/accounting/report/reports/balance_sheet.py +++ b/src/accounting/report/reports/balance_sheet.py @@ -180,7 +180,7 @@ class AccountCollector: url: str = url_for("accounting.report.income-statement", currency=self.__currency, period=self.__period.before) - self.__add_owner_s_equity(Account.ACCUMULATED_CHANGE, amount, url) + self.__add_owner_s_equity(Account.ACCUMULATED_CHANGE_CODE, amount, url) def __query_accumulated(self) -> Decimal | None: """Queries and returns the accumulated profit or loss. @@ -209,7 +209,7 @@ class AccountCollector: 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(Account.NET_CHANGE, amount, url) + self.__add_owner_s_equity(Account.NET_CHANGE_CODE, amount, url) def __query_currency_period(self) -> Decimal | None: """Queries and returns the net income or loss for current period.