Try ERPNext Buy Support Partners Foundation

Salary Structure Multiple Condition on Earning

I want to make Earning calculation base on the employment type
(using python)
if (employment_type == ‘Adjunct’):
base * 4/100
else:
base = 100000
How do i implement this using erp salary structure Earning:
Thanks

u

Try adding 2 rows for the same component, one with the condition employment_type == ‘Adjunct’ and the other with employment_type != ‘Adjunct’

Tanks for ur reply…But I don’t understand what u mean. U said I should type the two condition == and != With the adjunct condition. do u mean just put it on the condition block… How do I differentiate the amount they earn.
I mean
employment.type==‘adjunct’ base *40/100 then employment.type !=‘adjunct’ base

Tanks

I was suggesting to add 2 rows in Earnings table for the same earning component.

For example, I want to add a earning component “HRA” based on employment_type. Then I will add 2 rows for “HRA”.
In the 1st row, add condition employment_type == ‘Adjunct’ and formula base*40/100
In the 2nd row, add condition employment_type != ‘Adjunct’ and formula base*20/100

1 Like

Tanks very much. I understand now…But is there no way to do some complex calculation base on some condition .

Tanks

I think you can also write the formula like base*40/100 if employment_type == ‘Adjunct’ else base*20/100 and no condition needed in this case.

2 Likes

Tanks alot, I will try that out

That will require 2 Salary Components to be defined. One with condition employment_type == “Adjunct” and the other with the negation of this condition. Otherwise the second salary component will be applied no matter what. That will be a logical error.

It works better to think of the components are calculation steps and make use of Statistical Components as much as possible for complex calculation structures. I am on v11 right now and successfully implemented the Turkish salary calculation and a few of the incentives.

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.

1 Like