Replaced the hard-coded cash account codes with the CASH constant and the cash() method of the Account data model.
This commit is contained in:
		| @@ -588,7 +588,7 @@ class Transaction(db.Model): | ||||
|         for currency in self.currencies: | ||||
|             if len(currency.debit) > 1: | ||||
|                 return False | ||||
|             if currency.debit[0].account.code != "1111-001": | ||||
|             if currency.debit[0].account.code != Account.CASH: | ||||
|                 return False | ||||
|         return True | ||||
|  | ||||
| @@ -602,7 +602,7 @@ class Transaction(db.Model): | ||||
|         for currency in self.currencies: | ||||
|             if len(currency.credit) > 1: | ||||
|                 return False | ||||
|             if currency.credit[0].account.code != "1111-001": | ||||
|             if currency.credit[0].account.code != Account.CASH: | ||||
|                 return False | ||||
|         return True | ||||
|  | ||||
|   | ||||
| @@ -58,8 +58,8 @@ class ReportChooser: | ||||
|             Currency, default_currency_code()) \ | ||||
|             if currency is None else currency | ||||
|         """The currency.""" | ||||
|         self.__account: Account = Account.find_by_code("1111-001") \ | ||||
|             if account is None else account | ||||
|         self.__account: Account = Account.cash() if account is None \ | ||||
|             else account | ||||
|         """The currency.""" | ||||
|         self.__reports: list[OptionLink] = [] | ||||
|         """The links to the reports.""" | ||||
| @@ -110,7 +110,7 @@ class ReportChooser: | ||||
|         """ | ||||
|         account: Account = self.__account | ||||
|         if not re.match(r"[12][12]", account.base_code): | ||||
|             account: Account = Account.find_by_code("1111-001") | ||||
|             account: Account = Account.cash() | ||||
|         url: str = url_for("accounting.report.income-expenses-default", | ||||
|                            currency=self.__currency, account=account) \ | ||||
|             if self.__period.is_default \ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user