Try ERPNext Buy Support Partners Foundation

What is the condition/formula coding language for Salary Component?

Which syntax should I follow while writing a condition/formula for Salary Component on the ErpNext interface on a live/testing system?
We have multiple nested conditionals but it is not clear where to code these. Turkey has a very very complex Payroll structure and is additionally intrigued with the addition of incentives. I am mostly stuck with date comparison and differences, calculating ages, incentive start/end dates, etc. which are all custom fields.

Any guiding light will help. Thank you.

Hi! Learning happens when folks share their work and experiments Salary Structure Multiple Condition on Earning

1 Like

Maybe get specific and offer a challenge - that may spur interest and response.

Give folks your ‘hardest’ case examples, one or two that work and that don’t.

“which are all custom fields”

Is this the basic problem or what?

You are right on that sense.
Some components of the incentive we are implementing depends on the following:

  • number of months last worked date before joining. We defined a custom field for employee which is the last working day before joining. We need to determine if this is 6 months before joining or not.
  • age of the employee. That can be determined from the date_of_birth intrinsic employee field but to calculate the age in salary component is a bit tricky. There are different incentive lengths for different age groups.
  • number of months that the incentive is applied. The number of months calculated must be added to the date_of_joining and yet again date operations need to be known. Which language shall we use? Python?

CORRECT MULTICONDITION IN SALARY COMPONENT ENTERED IN FORMULA SECTION

SINGLE LINE ONLY:
400 if base>19749.99 else int((base+500-2249.99)/500)*10+40 if base>2249.99 else 40

or

MULTIPLE LINES:
400 if base>19749.99 else
int((base+500-2249.99)/500)*10+40 if base>2249.99 else
40

VERY IMPORTANT NOTES:

  1. In multiple lines, there is space character after else. This is the error that took me days to check.
  2. There is no IF on the last line.
  3. Multiple conditions does not work on the Conditions box, I don’t actually use it anymore. I put everything in the Formula box.

The image shows the correct way of doing this and it’s working perfectly for me. The example is for the Philippines, where I simplified a very long table to a 3-line formula.

…and how is that related?

Thanks for contributing @bernealmazan it’s all good! More notes here as well Multiple conditions on Salary Structure with a single formula