overdue loans

This commit was merged in pull request #45.
This commit is contained in:
Chinenye Nmoh
2025-08-27 15:49:17 +01:00
parent fb460471fb
commit a174340b2f
4 changed files with 42 additions and 44 deletions
+7 -2
View File
@@ -1,6 +1,7 @@
from app.models.loan_repayment_schedule import LoanRepaymentSchedule
from app.utils.logger import logger
from app.enums.loan_status import LoanStatus
from decimal import Decimal, ROUND_HALF_UP
class LoanRepaymentScheduleService:
@@ -40,6 +41,7 @@ class LoanRepaymentScheduleService:
"""
return LoanRepaymentSchedule.update_repayment_schedule_description(schedule_id, description)
@staticmethod
def handle_schedule_updates(updated_loan, data, amount_collected, message, loan_data):
"""
@@ -68,12 +70,12 @@ class LoanRepaymentScheduleService:
logger.error(f"Failed to update installment {installment.id}: {e}")
logger.info('All installments processed')
# Case 2: Partial repayment without overdueLoanScheduleId
# Case 2: Partial repayment made on a full loan without overdueLoanScheduleId
elif updated_loan and updated_loan.get('status') == LoanStatus.ACTIVE_PARTIAL and not data.get('overdueLoanScheduleId'):
logger.info("Partial repayment detected, but no overdue schedule ID provided.")
# TODO: implement proportional installment updates
# Case 3: Overdue schedule repayment → update balance & description
# Case 3: when we are processing Overdue schedule repayment → update balance & description
elif data.get('overdueLoanScheduleId') is not None:
logger.info(f"Overdue loan schedule ID: {data['overdueLoanScheduleId']}")
try:
@@ -102,4 +104,7 @@ class LoanRepaymentScheduleService:
except Exception as e:
logger.error(f"Unexpected error while handling schedule updates: {e}")