Loan Repayment deletion

I want to delete loan repayment and I get this error

App Versions

	"erpnext": "13.43.0",
	"frappe": "13.46.3"


Form/Loan Repayment/LM-REP-0002


Traceback (most recent call last):
  File "apps/frappe/frappe/", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 76, in execute_cmd
    return, **frappe.form_dict)
  File "apps/frappe/frappe/", line 1457, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/", line 39, in cancel
  File "apps/frappe/frappe/model/", line 1024, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/", line 1014, in _cancel
  File "apps/frappe/frappe/model/", line 311, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/", line 365, in _save
  File "apps/frappe/frappe/model/", line 1091, in run_post_save_methods
  File "apps/frappe/frappe/model/", line 942, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1263, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1245, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/", line 939, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/", line 43, in on_cancel
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/", line 268, in update_repayment_schedule
    regenerate_repayment_schedule(self.against_loan, cancel)
  File "apps/erpnext/erpnext/loan_management/doctype/loan_repayment/", 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/"

Response Data

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