Skip to Content
Menu
This question has been flagged
1 Reply
1741 Views

I want to add python code for salary rule ( overtime ).But it failed.This is the one I added.

((contract.wage/30)*worked_days."total_overtime",number_of_days)*0.015

But there was a error.

Wrong python condition defined for:: 
- Employee: Pradeep Nissanka 
- Contract: Pradeep Nissanka 
- Payslip: Salary Slip - Pradeep Nissanka - January 2023 
- Salary rule: Overtime (OT)
 - Error: invalid syntax (, line 14)

 What can i do to calculate Overtime in payroll?

Avatar
Discard
Best Answer

Hi Dilk ,

 contract.wage/30/contract.resource_calendar_id.hours_per_day to calculate the amount per hour

employee.total_overtime to get total overtime not within one month

to calculate overtime in payroll for a specific period, try this code:

overtime = 0
for line in employee.overtime_ids:
if payslip.date_from <= line.date <= payslip.date_to:
​overtime+= line.duration
result = (contract.wage/30/contract.resource_calendar_id.hours_per_day)*(overtime)

Hope this will help :)

Avatar
Discard
Author

Thank you....! Finally it's done.

Author

can i ask a solution code for unpaid leaves also?

Check this link for unpaid leaves
https://youtu.be/IAMkNYObbCE

Author

Sahar, I tried this unpaid leaves code. It didn't deduct from salary. There was no value for unpaid leaves, all leaves are 0 value.

Please check wage value, and unpaid leave hours in inputs tab.