fix: calc monthly_repayment_amount correctly in regenerate_repayment_schedule (#38636)
This commit is contained in:
@@ -599,6 +599,8 @@ def regenerate_repayment_schedule(loan, cancel=0):
|
|||||||
last_repayment_amount = None
|
last_repayment_amount = None
|
||||||
last_balance_amount = None
|
last_balance_amount = None
|
||||||
|
|
||||||
|
original_repayment_schedule_len = len(loan_doc.get("repayment_schedule"))
|
||||||
|
|
||||||
for term in reversed(loan_doc.get("repayment_schedule")):
|
for term in reversed(loan_doc.get("repayment_schedule")):
|
||||||
if not term.is_accrued:
|
if not term.is_accrued:
|
||||||
next_accrual_date = term.payment_date
|
next_accrual_date = term.payment_date
|
||||||
@@ -616,7 +618,7 @@ def regenerate_repayment_schedule(loan, cancel=0):
|
|||||||
|
|
||||||
if loan_doc.repayment_method == "Repay Fixed Amount per Period":
|
if loan_doc.repayment_method == "Repay Fixed Amount per Period":
|
||||||
monthly_repayment_amount = flt(
|
monthly_repayment_amount = flt(
|
||||||
balance_amount / len(loan_doc.get("repayment_schedule")) - accrued_entries
|
balance_amount / (original_repayment_schedule_len - accrued_entries)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
repayment_period = loan_doc.repayment_periods - accrued_entries
|
repayment_period = loan_doc.repayment_periods - accrued_entries
|
||||||
|
|||||||
Reference in New Issue
Block a user