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

1 Like

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.

5 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.

2 Likes

@Tufan_Kaynak2 hello, for the condition line employment_type == “Adjunct”, what can I do if I want to reference holidays (as in Table) in DocType “holiday_list”? I have one holiday list in Holiday_List, and I want to check if the Timesheet start_date and end_date can be found in the holidays.

Mind sharing some pointers?

Holidays should be handled automatically if the salary depends on working days. Did you check that? In terms of checking any value, that is surely possible in such a platform bu is it necessary?

Thank you for your reply @Tufan_Kaynak2.

Our requirement is this:

  • country holiday and every Sunday is a holiday
  • during holidays the wage is higher, at 1.25 times the weekday wage

So we want to calculate weekday wage (no problem now as formula is working in ERPNext), and our next step is to check, within Salary Structure, the Timesheet’s start_date and end_date falls into a date within the holiday_list. If yes, then formula will do the 1.25x basic weekday wage.

Currently I have no luck in retrieving Timesheet’s start_date, end_date, and Holiday List’s holidays…

Do you have other advice?

That really depends on how you have engineered your salary structure and the laws%regulations behind such overtime calculation as there may be a legal upper limit which needs to be checked as well. I would advise different paths considering the scenarios which may be different daily rates for regular and holidays, flat rate calculation and addition of hoiday extra payments. There are many ways to skin this cat.

@charleslcso
In payroll Settings: Calculate Payroll Working Days Based On: Attendance
And make sure this ‘Include holidays in Total no. of Working Days’ is unchecked.
(Mark attendance for an employee in days he has worked)

So, if on Sundays or holidays, an employee is present on his salary slip he will have overtime
The basic salary is 15,000 INR for 26 days(Sunday not included) if he has worked for 1 Sunday, his basic salary would be showing 15,577 INR (15,000/26 = 576.9, 15,000 + 576.9)

I don’t know how to incorporate the formula 1.25x basic weekday wage.

The above setting already exists in ERPNext.