fix: Unaccrued interest from last accrual date instead of disbursement date
diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
index b973cd6..c1e83d9 100644
--- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
+++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
@@ -310,6 +310,7 @@
payable_principal_amount - paid_principal_amount > 0)
AND
docstatus = 1
+ ORDER BY posting_date
""", (against_loan), as_dict=1)
return unpaid_accrued_entries
@@ -366,7 +367,8 @@
if due_date:
pending_days = date_diff(posting_date, due_date) + 1
else:
- pending_days = date_diff(posting_date, against_loan_doc.disbursement_date) + 1
+ last_accrual_date = get_last_accural_date(against_loan_doc.name)
+ pending_days = date_diff(posting_date, last_accrual_date) + 1
if pending_days > 0:
principal_amount = flt(pending_principal_amount, precision)