Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Penalty for Late Entry or Early Exit

Hi,

I have implemented the biometric auto attendance system and it is working well. I am wondering if we can somehow punish those that have Late Entry or Early Exit with something like a partial leave. I.E.

1 Late Entry = 1/6 Day cut.

Currently the system only mentions Late Entry or Early exit but having an automatic counter would be a great addition. I am a novice coder so some guidance on where to do what would be appreciated.

1 Like

Hi

I had achieved something similar using a custom app approach to make use of custom hook for salary slip to perform a count of all the late entry and early exit and add the total deduction for that employee in the salary slip.

@bibinqcs It would be a great help if you could share it(GitHub or something else).

I had done the work on a clients system, I couldn’t get to keep a copy of it.

I built a custom python function using

frappe.db.count(doctype, filters)

it was something like this

frappe.db.count('Attendance', { 
               'employee': employee, 
               'status': 'Present', 
               'late_entry': 1
})

@bibinqcs Thanks, that’s really helpful, but I am much more lost in setting up the web hooks, how does it add a parameter to the salary slip. If you could shed some more light in that part of logic, it would be a lot of help.

You can look at the hook file in erpnext for reference

Document Events
---------------
Hook on document methods and events

doc_events = {
	"*": {
		"on_update": "method",
		"on_cancel": "method",
		"on_trash": "method"
    }
}

You can add one pointing to your custom function for eg

"Salary Slip": {
		"validate": "custom_app.custom.penalty_function"
	}

This will trigger on every save.

You could trigger to make an Additional Salary document which creates the new deduction for an employee with the penalty for Late Entry

@bibinqcs thanks a lot, that info really helped.

I have implemented most of the required components, but whenever I try to update the slip, it triggers the validate function which bypasses all my changes. How did you bypass this? Thanks.

@niteya Are you using the additional salary doctype to add the deductions or are you trying to insert the deductions directly into the salary slip

Thank you so much, that fixed it. I was trying to work with salary components instead of additional salary.

1 Like