Repayment updates

This commit is contained in:
CHIEFSOFT\ameye
2025-06-20 15:18:04 -04:00
parent 190cd6611a
commit 7b21140b39
5 changed files with 64 additions and 3 deletions
+19 -1
View File
@@ -237,4 +237,22 @@ class Loan(db.Model):
logger.info(f"Found {len(customer_loans)} loans for customer ID: {customer_id} with total amount: {total_amount}")
return customer_loans, total_amount
return customer_loans, total_amount
@classmethod
def update_status(cls, loan_id, status):
"""
Update the status of the loan with the given loan_id.
"""
# Retrieve loan
loan = cls.query.get(loan_id)
if not loan:
raise ValueError(f"Loan with ID {loan_id} does not exist.")
if loan.status == status:
return
# Update loan status and the updated_at timestamp
loan.status = status