ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Salary Component Formula


Hi everyone, I am not a programmer. I am still trying to figure out phyton coding… How can I set the formula in Salary Component like below:

When wages exceed RM800 but not exceed RM900, contribution amount is RM1.70
When wages exceed RM900 but not exceed RM1,000, contribution amount is RM1.90
When wages exceed RM1,000 but not exceed RM1,100, contribution amount is RM2.10
When wages exceed RM4,000, contribution amount is RM7.90

Above mentioned wages is the total of basic salary, overtime pay, allowance, incentive and bonuses.



So you do not need any python coding for this. You can simply add a condition and formula in the salary components itself. Just check the box “Amount based on formula”. Screenshot attached:



Hi @Reema_Mehta, thank you for your reply. Do you mind guiding me in the formula? I have tried multiple formula but I get “Syntax Error”


Hi, you can fill in your salary components (basic salary, overtime pay, allowance, incentive and bonuses) in the “earning” table and apply formulae as required (make sure the “amount based on formula” checkbox is checked). Since contribution is a deduction, it should be written in the “deduction” table and then write the amount in the “amount” column. You can then type the following “condition” for “when wages exceed RM800 but not exceed RM900, contribution amount is RM1.70”
Condition: B>=800 and B<=900
(assuming the contribution is based on the Basic (B) component)
Similarly for other conditions…
Please check the attached screenshots for further clarification.



Thank you @Michelle_Alva for your help but unfortunately, I have tried but it does not work. I still receive syntax error. Below is the screenshot


uncheck amount based on formula and try it.


Hi @Raymond_Liew, Please find the attached screenshot and try the formula… I think this should work.

Tried it on three different conditions and it worked. You can modify the conditions as per your requirement.



@Raymond_Liew Check this screenshot too…

B = Basic
HRA = House Rent Allowance
BO = Bonus

So in the formula, you change the salary components accordingly.