Merge branch 'loan_schedule_fix' of DigiFi/digifi-BankToProductCore into master
This commit is contained in:
@@ -71,7 +71,7 @@ class ProvideLoanService(BaseService):
|
||||
upfront_fee = charges["upfront_payment"]
|
||||
repayment_amount = charges["repayment_amount"]
|
||||
#installment_amount = charges["installment_amount"]
|
||||
tenor = offer.tenor // 30 # Convert to months
|
||||
num_schedules = offer.schedule
|
||||
|
||||
upfront_payment = charges["upfront_payment"]
|
||||
total_amount = charges["total_amount"]
|
||||
@@ -107,7 +107,7 @@ class ProvideLoanService(BaseService):
|
||||
|
||||
db.session.flush()
|
||||
|
||||
schedule = LoanRepaymentSchedule.add_repayment_schedule(loan = loan, tenor = tenor, transaction_id = transaction_id)
|
||||
schedule = LoanRepaymentSchedule.add_repayment_schedule(loan = loan, num_schedules = num_schedules, transaction_id = transaction_id)
|
||||
|
||||
|
||||
if not schedule:
|
||||
|
||||
@@ -29,14 +29,14 @@ class LoanRepaymentSchedule(db.Model):
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_repayment_schedule(cls, loan, tenor, transaction_id):
|
||||
def add_repayment_schedule(cls, loan, num_schedules, transaction_id):
|
||||
"""
|
||||
Add repayment schedules for a given loan.
|
||||
"""
|
||||
now = datetime.now(timezone.utc)
|
||||
schedules = []
|
||||
|
||||
for i in range(tenor):
|
||||
for i in range(num_schedules):
|
||||
due_date = now + relativedelta(months=i + 1)
|
||||
schedule = LoanRepaymentSchedule(
|
||||
loan_id=loan.id,
|
||||
|
||||
Reference in New Issue
Block a user