fix: Add method for loan closure
diff --git a/erpnext/loan_management/doctype/loan/loan.py b/erpnext/loan_management/doctype/loan/loan.py
index d1b7589..1fb0805 100644
--- a/erpnext/loan_management/doctype/loan/loan.py
+++ b/erpnext/loan_management/doctype/loan/loan.py
@@ -9,6 +9,7 @@
 from frappe.utils import flt, rounded, add_months, nowdate, getdate, now_datetime
 from erpnext.loan_management.doctype.loan_security_unpledge.loan_security_unpledge import get_pledged_security_qty
 from erpnext.controllers.accounts_controller import AccountsController
+from erpnext.loan_management.doctype.loan_repayment.loan_repayment import calculate_amounts
 
 class Loan(AccountsController):
 	def validate(self):
@@ -183,6 +184,19 @@
 	return monthly_repayment_amount
 
 @frappe.whitelist()
+def request_loan_closure(loan):
+	amounts = calculate_amounts(loan, getdate())
+
+	pending_amount = amounts['payable_amount'] + amounts['unaccrued_interest']
+
+	# checking greater than 0 as there may be some minor precision error
+	if pending_amount > 0:
+		frappe.throw(_("Cannot close loan as there is an outstanding of {0}").format(pending_amount))
+	else:
+		# update status as loan closure requested
+		frappe.db.set_value('Loan', loan, 'status', 'Loan Closure Requested')
+
+@frappe.whitelist()
 def get_loan_application(loan_application):
 	loan = frappe.get_doc("Loan Application", loan_application)
 	if loan: