[add]: loan_repayment event
This commit is contained in:
@@ -26,6 +26,16 @@ class Loan(db.Model):
|
||||
return False, "Customer has active loans"
|
||||
return True, "No active loans"
|
||||
|
||||
@classmethod
|
||||
def get_customer_loan(cls, loan_id, customer_id):
|
||||
"""
|
||||
Check if a loan with the given ID exists and if the loan belongs to the specified customer_id.
|
||||
"""
|
||||
loan = cls.query.filter_by(id=loan_id, customer_id=customer_id).first()
|
||||
if not loan:
|
||||
raise ValueError(f"Loan with ID {loan_id} does not exist or does not belong to customer {customer_id}.")
|
||||
return loan
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Loan {self.id}>'
|
||||
Reference in New Issue
Block a user