From 194605823e6ab0db8509b08095067edfc768d093 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 4 Apr 2022 13:25:35 +0530 Subject: [PATCH] fix: Issues on loan repayment --- .../loan_management/doctype/loan_repayment/loan_repayment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index 8cffe88f32..460a514baa 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -584,9 +584,10 @@ def regenerate_repayment_schedule(loan, cancel=0): balance_amount / len(loan_doc.get("repayment_schedule")) - accrued_entries ) else: - if not cancel: + repayment_period = loan_doc.repayment_periods - accrued_entries + if not cancel and repayment_period > 0: monthly_repayment_amount = get_monthly_repayment_amount( - balance_amount, loan_doc.rate_of_interest, loan_doc.repayment_periods - accrued_entries + balance_amount, loan_doc.rate_of_interest, repayment_period ) else: monthly_repayment_amount = last_repayment_amount