Added the limitation so that essential accounts, like cash, and the accounts in use, cannot be deleted.
This commit is contained in:
@ -236,6 +236,16 @@ class Account(db.Model):
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def can_delete(self) -> bool:
|
||||
"""Returns whether the account can be deleted.
|
||||
|
||||
:return: True if the account can be deleted, or False otherwise.
|
||||
"""
|
||||
if self.code in {"1111-001", "3351-001", "3353-001"}:
|
||||
return False
|
||||
return len(self.line_items) == 0
|
||||
|
||||
def delete(self) -> None:
|
||||
"""Deletes this account.
|
||||
|
||||
|
Reference in New Issue
Block a user