without specific details on your case a perfect answer would be a miracle, but I would go this direction:
Make clear what overtime models you have
Create a salary component to calculate the overtime
Integrate that salary component to a salary structure
assign that salary structure to a employee
create a payroll entry
your salary structure will be auto-fetched and the overtime will be calculated according to your formula.
Depending on your employment model the salary component/s could contain
conditions on days with leave or days without leave
conditions on agreed attendance days *times hours so if more than agreed hours overtime will be calculated etc.
Creating working salary components are quite a headache, but overtime calculation compared to goverment employment tax components, which I guess you already have, should be a smooth task