Scheduler events to cancel

Hi ERPNext Community

I want to use scheduler events to cancel transaction
by if condition to cancel doc

time_now = datetime.now()
time_between =  date_diff(time_now,self.request_date)+1
if time_between > 5

my code to schedule :

frappe.whitelist()
def delete_leave_balance():
	date_difference = self.no_of_days
	leave_allocation = frappe.get_doc("Leave Allocation", self.leave_allocation)
	if leave_allocation:
		leave_allocation.new_leaves_allocated -= date_difference
		if leave_allocation.new_leaves_allocated - date_difference <= 0:
			leave_allocation.new_leaves_allocated = 0
		leave_allocation.validate()
		leave_allocation.db_set("new_leaves_allocated", leave_allocation.total_leaves_allocated)
		leave_allocation.db_set("total_leaves_allocated", leave_allocation.total_leaves_allocated)
		create_additional_leave_ledger_entry(
			leave_allocation, self.no_of_days * -1,self.request_date

my scheduler events

"daily": ['request_for_leave_extension.request_for_leave_extension.delete_leave_balance',],