Renamed the CASH, ACCUMULATED_CHANGE, and NET_CHANGE constants to CASH_CODE, ACCUMULATED_CHANGE_CODE, and NET_CHANGE_CODE, respectively, to avoid confusion.

This commit is contained in:
依瑪貓 2023-03-08 18:31:35 +08:00
parent 5687852dfb
commit c189615ca4
2 changed files with 9 additions and 9 deletions

View File

@ -141,11 +141,11 @@ class Account(db.Model):
entries = db.relationship("JournalEntry", back_populates="account") entries = db.relationship("JournalEntry", back_populates="account")
"""The journal entries.""" """The journal entries."""
CASH = "1111-001" CASH_CODE = "1111-001"
"""The code of the cash account,""" """The code of the cash account,"""
ACCUMULATED_CHANGE = "3351-001" ACCUMULATED_CHANGE_CODE = "3351-001"
"""The code of the accumulated-change account,""" """The code of the accumulated-change account,"""
NET_CHANGE = "3353-001" NET_CHANGE_CODE = "3353-001"
"""The code of the net-change account,""" """The code of the net-change account,"""
def __str__(self) -> str: def __str__(self) -> str:
@ -265,7 +265,7 @@ class Account(db.Model):
:return: The cash account :return: The cash account
""" """
return cls.find_by_code(cls.CASH) return cls.find_by_code(cls.CASH_CODE)
@classmethod @classmethod
def accumulated_change(cls) -> t.Self: def accumulated_change(cls) -> t.Self:
@ -273,7 +273,7 @@ class Account(db.Model):
:return: The accumulated-change account :return: The accumulated-change account
""" """
return cls.find_by_code(cls.ACCUMULATED_CHANGE) return cls.find_by_code(cls.ACCUMULATED_CHANGE_CODE)
@property @property
def is_modified(self) -> bool: def is_modified(self) -> bool:
@ -550,7 +550,7 @@ class Transaction(db.Model):
for currency in self.currencies: for currency in self.currencies:
if len(currency.debit) > 1: if len(currency.debit) > 1:
return False return False
if currency.debit[0].account.code != Account.CASH: if currency.debit[0].account.code != Account.CASH_CODE:
return False return False
return True return True
@ -564,7 +564,7 @@ class Transaction(db.Model):
for currency in self.currencies: for currency in self.currencies:
if len(currency.credit) > 1: if len(currency.credit) > 1:
return False return False
if currency.credit[0].account.code != Account.CASH: if currency.credit[0].account.code != Account.CASH_CODE:
return False return False
return True return True

View File

@ -180,7 +180,7 @@ class AccountCollector:
url: str = url_for("accounting.report.income-statement", url: str = url_for("accounting.report.income-statement",
currency=self.__currency, currency=self.__currency,
period=self.__period.before) 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: def __query_accumulated(self) -> Decimal | None:
"""Queries and returns the accumulated profit or loss. """Queries and returns the accumulated profit or loss.
@ -209,7 +209,7 @@ class AccountCollector:
amount: Decimal | None = self.__query_currency_period() amount: Decimal | None = self.__query_currency_period()
url: str = url_for("accounting.report.income-statement", url: str = url_for("accounting.report.income-statement",
currency=self.__currency, period=self.__period) 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: 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.