added salary table

This commit is contained in:
Chinenye Nmoh
2025-06-19 21:30:21 +01:00
parent 3be765bf41
commit 7fbb659fc6
7 changed files with 164 additions and 41 deletions
+11 -1
View File
@@ -218,4 +218,14 @@ class Loan(db.Model):
return cls.query.filter(
cls.disburse_date.isnot(None),
cls.disburse_verify.is_(None)
).order_by(cls.created_at.desc()).first()
).order_by(cls.created_at.desc()).first()
@classmethod
def get_customer_loans(cls, customer_id):
"""
Get customer's active loans by customer_id.
"""
customer_loans = cls.query.filter_by( customer_id = customer_id).all()
if not customer_loans:
raise ValueError(f"Customer with Id {customer_id} does not have any loan.")
return customer_loans