Skip to Content
Menu
This question has been flagged

Overtime is usually double the per hour rate of any employee and its calculated in hours.
means, Contract Wage (Fix) / total number of days in a month = Per Day Wage
Per day wage / Total number of Working Hours in a day = Per hour Contract Wage

Overtime = Per hour Contract Wage x 2

so what will be the code?
thanks in advance

Avatar
Discard
Best Answer

I am also working on overtime salary rule. Can you plz share the python code 


Avatar
Discard
Author

regular_hours_per_month = 23 * 8
regular_hourly_rate = contract.wage / regular_hours_per_month

result = 0
for line in payslip.worked_days_line_ids:
if line.code != 'LEAVE90':
if line.number_of_hours <= regular_hours_per_month:
result += line.number_of_hours * regular_hourly_rate
else:
regular_payment = regular_hours_per_month * regular_hourly_rate
extra_hours = line.number_of_hours - regular_hours_per_month
extra_payment = extra_hours * (regular_hourly_rate * 2)
result += regular_payment + extra_payment

result = result

hope it will help you.

Best Answer

Hi

Create a new rule named "OverTime" in the payslip. In the computation part, select "Amount Type" as "Python code" and use the following code:
result = contract_wage * 2 / (total_number_of_days_in_a_month * total_number_of_working_hours_in_a_day)
Please ensure that you replace "total_number_of_days_in_a_month" with the actual total number of days in a month and "total_number_of_working_hours_in_a_day" with the total number of working hours in a day as per your specific context.


Hope it helps

Avatar
Discard

Standard working hours=208
worked hours(Attendance)=221
Overtime=221-208=13
Attendance pora ho toh 1500 basic ana chahiye aur jo overtime ho wo khud he 13hr show kr kay 8 sey multiply krey
Thank You

Author

Thanks @Cybrosys Techno Solutions Pvt.Ltd for your answer i have solved this problem .In your answer after defining the new rule ''overtime" it will not take the overtime hours own its own. so i had to use the bit different approch before the calculation.

@zahra naveed , what's the approach that you used ?

Author

@kenny Hi , i know it might be too late but if you still want this is what i did
hour_per_day = 8
days_in_month = 30
regular_hours_per_month = days_in_month * hour_per_day
regular_hourly_rate = contract.wage / regular_hours_per_month

result = 0
for line in payslip.worked_days_line_ids:
if line.code not in ['LEAVE90', 'OVERTIME']:
if line.number_of_hours <= regular_hours_per_month:
result += line.number_of_hours * regular_hourly_rate
else:
regular_payment = regular_hours_per_month * regular_hourly_rate
result += regular_payment

result = result

Best Answer

Try to create a new rule in the hr.payslip model - where define a new field called overtime as a float type, and we use the @api.depends decorator to compute its value based on the worked_hours and the employee's contract information.

Avatar
Discard
Author

can you please write the code .

Related Posts Replies Views Activity
0
Nov 23
1434
1
Apr 17
4786
1
May 24
1314
1
Sep 23
12690
1
Jul 23
2081