Přejít na obsah
Menu
You need to be registered to interact with the community.
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
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Autor

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.

Nejlepší odpověď

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
Zrušit

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

Autor

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 ?

Autor

@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

Nejlepší odpověď

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
Zrušit
Autor

can you please write the code .

Related Posts Odpovědi Zobrazení Aktivita
0
lis 23
1529
1
dub 17
4826
1
kvě 24
1386
1
zář 23
12752
1
čvc 23
2112