This commit is contained in:
Chinenye Nmoh
2025-06-26 13:36:49 +01:00
parent 9feab46016
commit 79109af695
3 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -247,9 +247,9 @@ class Loan(db.Model):
"""
Get customer's active loans and sum by customer_id.
"""
customer_loans = cls.query.filter_by( customer_id = customer_id).all()
customer_loans = cls.query.filter_by( customer_id = customer_id, status='active').all()
if not customer_loans:
raise ValueError(f"Customer with Id {customer_id} does not have any loan.")
raise ValueError(f"Customer with Id {customer_id} does not have any active loan.")
total_amount = (
cls.query.with_entities(func.coalesce(func.sum(cls.balance), 0.0))