balance
This commit is contained in:
+2
-2
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user