Hello @pwatson92
Javascript is a case-sensitive language, the uppercase, and lowercase matter. The IF operation is not the if conditional statement.
The payment can be calculated with only one field. For example, assuming the fieldname1 is the currency field with the cost per hour, and fieldname2 is the number field for working hours.
The payment can be implemented as follows:
MIN(fieldname2,40)*fieldname1+MAX(0,fieldname1-40)*fieldname1*1.5
But if you want to implement the process with multiple fields as you did, the equations would be:
For overtime hours: fieldname2-40
For overtime payment: IF(0<fieldname3, fieldname1*fieldname3*1.5, 0)
You don’t need the function structure in any of these cases.
I prefer my first alternative because it reduces the number of fields.
Best regards.
Your equation wasn’t quite working right, so I simplified it to
(fieldname2-40)*fieldname1*1.5 and I got the right result.
-
This reply was modified 4 years, 4 months ago by
pwatson92.
-
This reply was modified 4 years, 4 months ago by
pwatson92.
Hello @pwatson92
Yes, I’m sorry. I’ve a typo in my equation, the correct is:
MIN(fieldname2,40)*fieldname1+MAX(0,fieldname2-40)*fieldname1*1.5
The first component in the sum MIN(fieldname2,40)*fieldname1 calculates the salary of the first 40 hours at the common hour-cost.
The second component in the sum determines the remaining hours MAX(0,fieldname2-40) (if the person worked less than 40 hours, the previous code returns zero) and multiply them by hour-cost increased 1.5 times: MAX(0,fieldname2-40)*fieldname1*1.5
So, the equation MIN(fieldname2,40)*fieldname1+MAX(0,fieldname2-40)*fieldname1*1.5 calculates the final salary.
Best regards.