fix: Add test for loan repayment cancellation
diff --git a/erpnext/loan_management/doctype/loan/test_loan.py b/erpnext/loan_management/doctype/loan/test_loan.py
index b232b87..1676c21 100644
--- a/erpnext/loan_management/doctype/loan/test_loan.py
+++ b/erpnext/loan_management/doctype/loan/test_loan.py
@@ -218,6 +218,14 @@
self.assertEqual(flt(loan.total_principal_paid, 0), flt(repayment_entry.amount_paid -
penalty_amount - total_interest_paid, 0))
+ # Check Repayment Entry cancel
+ repayment_entry.load_from_db()
+ repayment_entry.cancel()
+
+ loan.load_from_db()
+ self.assertEqual(loan.total_principal_paid, 0)
+ self.assertEqual(loan.total_principal_paid, 0)
+
def test_loan_closure(self):
pledge = [{
"loan_security": "Test Security 1",
diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
index f7d9e66..2abb395 100644
--- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
+++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
@@ -134,7 +134,7 @@
})
pending_principal_amount = get_pending_principal_amount(loan)
- if not loan.is_secured_loan and pending_principal_amount < 0:
+ if not loan.is_secured_loan and pending_principal_amount <= 0:
loan.update({'status': 'Loan Closure Requested'})
for payment in self.repayment_details: