Salary Slip overtime to be calculated based on the employee salary


I need to calculate the overtime (rate hour) for the salary slip time sheet based on the employee salary and not based on flat rate. The main question is: the custom script to do this task should be build based on which event (activity)? Is it based on refresh for example?
Actually, it should be executed when we need to create salary slip (from Payroll → Process Payroll, or from Project → timesheet, or from Payroll → Salary Slip).
Another question: if we said that the custom script to be executed based on Refresh event, then: do I have to create this custom script under the document Salary Slip or where?
I am trying to understand if creating salary slip from timesheet or from process payroll is same as creating salary slip (Payroll → Salary Slip)?

Any help?

Yes, it is all the same. Just that you should have overtime hours fetched from the Timesheet, and value for rest of the component will be fetched from “Salary Structure”. In the Salary Structure, you can update component for the overtime and flat hour rate. In the Salary Slip, when timesheet is pulled, it will calculated total time calculated, and based on the hour rate, value for the component of the overtime will be calculated.

1 Like

Actually I found a workaround solution, I have now two components: One is Flat rate overtime and one is overtime. When I do not need to calculate based on flat rate, I set the hour rate 0 and I depend on the total_hours value to calculate the overtime based on employee salary.
Thanks a lot for the kindly reply and help.

1 Like

the problem you will face if you have the overtime rate calculated based on working time if he worked night not the same rate if he do it in a weekend.


Here I can do a custom script to calculate the number of hours based on the time of the working. For example: if he worked in week end, then the hour is 2 hours and if he worked in the night, then the hour is 1.5 hour and so on.

What do u think?

1 Like

Hi Umair,

I’ve been trying to setup Overtime for my company. I’ve tried almost all possible solutions out there. But none of them seem to work.

Im just curious as to how other ERPNext customers are using the HR module to solve this scenario.

In the comment you have said use timesheet based payroll but we cannot arrive at a combined flat rate for all the employees.

Also If you have any solution to this or something that is planned and sitting there in the backlog we would love to take it up and build it and contribute to the system so that all users would be able to utilise this feature.

These are what I did to compute for different overtime rates:

  1. Customize Salary Slip to add Overtime hours fields
  2. Add Salary Components for each overtime rates.
  3. Add these in the Salary Structure.
  4. After generating the Salary Slips in Payroll Entry, I go to Salary Slip to enter the overtime hours. The overtime amounts are then automatically computed for different rates, also other related items like Income taxes are recomputed.
  5. I can then go back to Payroll Entry to Submit.

If there are many overtime records to manually edit in Step 4, I think these Salary slips can be exported to Excel (Data Recovery Export), update the Excel file with the Overtime Hours and import back (Data Import/ Update existing records).

1 Like

@bernealmazan you manually compute the overtime, late, undertime, and holidays on a separate excel then upload it to the salary slips?

But how about the tax? Is the formula not based on the basic salary less the overtime and late?

Until now, I still can’t setup the payroll because it does not compute the overtime, late and undertime, plus the holidays which has a different percentage based on the type of holiday.

Yes, I manually computed the overtime hours on separate slip.
This is for Philippine Payroll.

I customized Salary Slip to add the different overtime hours.
I defined different Salary Component for each overtime type. The computation is hourly salary x overtime hours x overtime rate.
These are then added in the Salary Structure.
After generating in Payroll Entry the Salary Slips, I then do Data Export of payroll slips where I update the overtime hours per type. Then I do Data Import to update the Salary Slips.

Withholding tax is based on the net taxable amount.

A customized program can be added to compute the hours for different overtime rates, that’s what I’m planning later. For our company though, manually computing the hours would be easier.