added repayment_schedule

This commit is contained in:
Chinenye Nmoh
2025-08-25 10:06:35 +01:00
parent ecd488fb79
commit cd754e5b15
4 changed files with 131 additions and 55 deletions
+21 -1
View File
@@ -55,8 +55,28 @@ class LoanRepaymentSchedule(db.Model):
except Exception as e:
logger.error(f"Error fetching repayment schedule for loan_id={loan_id}: {e}")
return []
@classmethod
def get_repayment_schedule_by_id_and_transaction_id(cls, id, transaction_id):
"""
Get repayment schedule by ID and transaction ID
"""
try:
return cls.query.filter_by(id=id, transaction_id=transaction_id).first()
except Exception as e:
logger.error(f"Error fetching repayment schedule for id={id}, transaction_id={transaction_id}: {e}")
return None
@classmethod
def get_overdue_repayment_schedule(cls):
"""
Get all overdue repayment schedules.
"""
try:
return cls.query.filter(cls.due_date < datetime.now(timezone.utc), cls.paid == False).all()
except Exception as e:
logger.error(f"Error fetching overdue repayment schedules: {e}")
return []
@classmethod
def get_repayment_schedule_by_transaction_id(cls, transaction_id):
"""