[update]: model class methods

This commit is contained in:
VivianDee
2025-03-28 10:11:44 +01:00
parent ad39b1c75c
commit bc8f8e2cdd
6 changed files with 30 additions and 33 deletions
+9
View File
@@ -22,6 +22,15 @@ class Account(db.Model):
# viewonly=True
# )
@classmethod
def is_valid_account(cls, account_id, customer_id):
account = cls.query.filter_by(id=account_id, customer_id=customer_id).first()
if not account:
return False, "Account not found or doesn't belong to customer"
if account.lien_amount > 0:
return False, "Account has an existing lien"
return True, "Account is valid"
def __repr__(self):
return f'<Account {self.id}>'