Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
12221 Vistas

Hello, 


I am trying to set up the payroll app to make all the calculations automatically for employees whose salary is in a $/hour basis. problem is, I cant find the right python expressions for it to work (I am using the enterprise and I do not have access to the py file) therefore, I can only change in the payroll app and all I am giving is the following: 



                    # Available variables:

                    #----------------------

                    # payslip: object containing the payslips

                    # employee: hr.employee object

                    # contract: hr.contract object

                    # rules: object containing the rules code (previously computed)

                    # categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).

                    # worked_days: object containing the computed worked days.

                    # inputs: object containing the computed inputs.


                    # Note: returned value have to be set in the variable 'result'


                    result = ___________________________


What would need to be written in the blank above so the system can multiply the worked hours times the salary?


Thank you very much! 

Avatar
Descartar
Mejor respuesta

Hi Victor:

Try this.

result = contract.hourly_wage * worked_days.WORK100.number_of_hours

NOTE: WORK100 refers to the Attendance object.

You may also want to see how the Worker Pay Salary Rule is set up in the demo data. It provides an example of how to set up a payslip for an hourly worker.

Avatar
Descartar
Autor

Thank you very much! this was super helpful!

Autor

I have another question and after looking at the demo I couldn't find it anywhere.

If I have a contract with an employee where he earns 5$/hour up to 40 hours a week. But then, 7$/hour after the 40th hour. How could I make that command?

Ex.

the employee worked 46 hours this week

I'd like the command to perform the following equation = (46hrs - 40 hrs) 8 7$/ hr = 42$

Thank you!

There are different ways to do this.

If you are able to capture the hours separately as regular hours and extra hours, you could create a Work Entry type called "Extra Hours" that you could use in your calculations. However, you may need to do a customization to capture the additional rate for the extra hours in the Contract or use one of the input types to specify it in the Payslip.

The other way would be to adjust your formula to apply the extra rate in the formula itself. I wouldn't recommend this option since it would lead to hard coding unless you have a standard overtime rate like a percentage that applies to all hourly employees/contractors.

Autor

That is my problem precisely, I cant find a way to separate extra hours from regular hours. the contract is giving me only the option to add the base salary, nothing more. I was thinking about using "if functions" in python expressions but couldnt find the right command (if there is one)

Autor

I managed to add different Extra hours for my payroll by defining them as different work entries and using the same equation you showed me in your answer (thanks by the way) However, in my company, I have different kinds of Extra hour rates (night shift, Day shift, sunday shift and so on...) and I am adding them all to my payroll structure.

Since I have them as "Condition always true" when I run a payslip with no Extra hours gives me an error since that condition cant be met

How could I write a python expression that applies the Extra hours rules "IF" there is extra hours in the payslip?

is there a python expression I could use in the conditions to make this work?

Thank you very much!

Please post a screenshot of how you have currently defined the calculation for the extra hours. You can upload the screenshot to one of the image sharing sites like imgur and post the link here.

Autor

forgot to say in the previous comment. HED100 (Extra Hour for Daytime) is the name for a work entry which Im using to compute the extra hours!

Mejor respuesta

Just want to add that the Attendance object in version 14 seems to be "WORK" and not "WORK100"

Avatar
Descartar