[update]: Loan status

This commit is contained in:
VivianDee
2025-04-11 00:14:02 +01:00
parent 9f9512b060
commit 1d97304f4e
2 changed files with 21 additions and 3 deletions
+14
View File
@@ -99,6 +99,20 @@ class Loan(db.Model):
# Update loan status and the updated_at timestamp
loan.status = status
def to_dict(self):
"""
Convert the Loan object to a dictionary format for JSON serialization.
"""
return {
'id': self.id,
'customer_id': self.customer_id,
'account_id': self.account_id,
'offer_id': self.offer_id,
'principal_amount': self.principal_amount,
'status': self.status,
'created_at': self.created_at.isoformat() if self.created_at else None,
'updated_at': self.updated_at.isoformat() if self.updated_at else None
}
def __repr__(self):
return f'<Loan {self.id}>'