Exception in Opening invoice tool

I get the following error when I open Opening Invoice Tool.

ERPNext: v11.1.50 (version-11)
Frappe Framework: v11.1.46 (version-11)

Traceback (most recent call last):
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/load.py", line 33, in getdoc
    run_onload(doc)
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/load.py", line 203, in run_onload
    doc.run_method("onload")
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 15, in onload
    summary, max_count = self.get_opening_invoice_summary()
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 58, in get_opening_invoice_summary
    prepare_invoice_summary(doctype, invoices)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 40, in prepare_invoice_summary
    "max_paid": max(paid_amount) if paid_amount else 0.0,
TypeError: '>' not supported between instances of 'NoneType' and 'NoneType'

Traceback (most recent call last):
  File "/opt/bench/erpnext/apps/frappe/frappe/app.py", line 61, in application
    response = frappe.handler.handle()
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/opt/bench/erpnext/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/load.py", line 33, in getdoc
    run_onload(doc)
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/load.py", line 203, in run_onload
    doc.run_method("onload")
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 15, in onload
    summary, max_count = self.get_opening_invoice_summary()
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 58, in get_opening_invoice_summary
    prepare_invoice_summary(doctype, invoices)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py", line 40, in prepare_invoice_summary
    "max_paid": max(paid_amount) if paid_amount else 0.0,
TypeError: '>' not supported between instances of 'NoneType' and 'NoneType'