Loan Repayment deletion

I want to delete loan repayment and I get this error

App Versions

{
	"erpnext": "13.43.0",
	"frappe": "13.46.3"
}

Route

Form/Loan Repayment/LM-REP-0002

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1457, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 39, in cancel
    doc.cancel()
  File "apps/frappe/frappe/model/document.py", line 1024, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/document.py", line 1014, in _cancel
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 311, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 365, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1091, in run_post_save_methods
    self.run_method("on_cancel")
  File "apps/frappe/frappe/model/document.py", line 942, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1263, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1245, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 939, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py", line 43, in on_cancel
    self.update_repayment_schedule(cancel=1)
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py", line 268, in update_repayment_schedule
    regenerate_repayment_schedule(self.against_loan, cancel)
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py", line 614, in regenerate_repayment_schedule
    while balance_amount > 0:
TypeError: '>' not supported between instances of 'NoneType' and 'int'

Request Data

{
	"type": "POST",
	"args": {
		"doctype": "Loan Repayment",
		"name": "LM-REP-0001"
	},
	"btn": {
		"jQuery224075715974759388651": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 1575,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.cancel"
}

Response Data

{
	"exception": "TypeError: '>' not supported between instances of 'NoneType' and 'int'"
}

Following for answers on this. I am experiencing the same error.

mr wael, you can contact me to solve your problem

+201063166888
9050nasser@gmail.com

Same happens to me. is there any solution ?

I experienced this too recently and was able to delete from the loan type.

I cancelled and deleted the loan type which deleted all the loan transactions connected to it.