[fix]: Offer schedules
This commit is contained in:
@@ -71,7 +71,7 @@ class ProvideLoanService(BaseService):
|
|||||||
upfront_fee = charges["upfront_payment"]
|
upfront_fee = charges["upfront_payment"]
|
||||||
repayment_amount = charges["repayment_amount"]
|
repayment_amount = charges["repayment_amount"]
|
||||||
#installment_amount = charges["installment_amount"]
|
#installment_amount = charges["installment_amount"]
|
||||||
tenor = offer.tenor // 30 # Convert to months
|
schedule = offer.schedule
|
||||||
|
|
||||||
upfront_payment = charges["upfront_payment"]
|
upfront_payment = charges["upfront_payment"]
|
||||||
total_amount = charges["total_amount"]
|
total_amount = charges["total_amount"]
|
||||||
@@ -107,7 +107,7 @@ class ProvideLoanService(BaseService):
|
|||||||
|
|
||||||
db.session.flush()
|
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:
|
if not schedule:
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ class LoanRepaymentSchedule(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@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.
|
Add repayment schedules for a given loan.
|
||||||
"""
|
"""
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
schedules = []
|
schedules = []
|
||||||
|
|
||||||
for i in range(tenor):
|
for i in range(num_schedules):
|
||||||
due_date = now + relativedelta(months=i + 1)
|
due_date = now + relativedelta(months=i + 1)
|
||||||
schedule = LoanRepaymentSchedule(
|
schedule = LoanRepaymentSchedule(
|
||||||
loan_id=loan.id,
|
loan_id=loan.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user