Override method of core doctype which is not class method or whitelisted method

Hi Everyone.

I want to override method which not whitelisted or not class method. I couldn’t get any solution for this till now.
In hooks.py we can override doctype class method and doctype whitelisted method with using override_doctype_class and override_whitelisted_methods. but we cannot override a method which is not any of this.

for example:
account_closing_balance.py —> make_closing_entries() method

import frappe
from frappe.model.document import Document
from frappe.utils import cint, cstr

from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
get_accounting_dimensions,
)

class AccountClosingBalance(Document):
pass

def make_closing_entries(closing_entries, voucher_name, company, closing_date):
accounting_dimensions = get_accounting_dimensions()

previous_closing_entries = get_previous_closing_entries(
	company, closing_date, accounting_dimensions
)
combined_entries = closing_entries + previous_closing_entries

merged_entries = aggregate_with_last_account_closing_balance(
	combined_entries, accounting_dimensions
)

for key, value in merged_entries.items():
	cle = frappe.new_doc("Account Closing Balance")
	cle.update(value)
	cle.update(value["dimensions"])
	cle.update(
		{
			"period_closing_voucher": voucher_name,
			"closing_date": closing_date,
		}
	)
	cle.flags.ignore_permissions = True
	cle.submit()

You can use monkey-patching to override non-class methods.