Since ERPNext does not support multiple Tax Slabs per employee, U.S based payroll is not really possible. From what I can gather, Salary Components are the only way to circumvent this. I’ve created multiple Salary Components for Federal and State tax which deduct from the employee’s total monthly pay. I then created a separate account “taxes withheld” to keep track of all the deductions.

Unfortunately, I haven’t been able to get the Salary Components to actually deduct anything. I made sure to check off “amount based on formula” and “Variable Based On Taxable Salary” is unchecked.

When adding them as deductions in the Salary Component structure or even after the fact when creating the Salary Slip, the deduction amount is just 0. I’ve tried even setting the amount to a static number without any formula and still the deduction remains at 0. I’m obviously doing something wrong but after spending hours on this I figured I need some expertise.

Below is the formula I’m using for U.S Federal Tax. Like I said even using a static amount doesn’t work so I’m not sure its the formula that’s even the problem.

0 if base <= 916.67 else int((base-916.67)/500)*10 + 281.03 if base <= 3727.08 else int((base-3727.08)/500)*12 + 932.57 if base <= 7947.92 else int((base-7947.92)/500)*22 + 2071.85 if base <= 15175.00 else int((base-15175.00)/500)*24 + 3762.05 if base <= 19270.83 else int((base-19270.83)/500)*32 + 12558.69 if base <= 48177.08 else int((base-48177.08)/500)*35 + 16206.64

Thanks mangroliya, I was not defining any base in the salary structure assignment. This was in part because the salary is based of a timesheet, so there is no “base” salary since it’s based off the amount of hours the employee worked.

After defining a base, I see the deductions are now working. However, if I manually change the employees gross pay on the pay slip to match their hours worked, the deductions don’t update but stay the same for the amount I defined as the base.

Does ERPNext have any way of dynamically updating the salary component deductions based of the employees gross pay and not the base defined in the Salary Structure Assignment?

You can define the hourly rate in base amount and later use the formula to calculate salary base * hours worked from timesheet to dynamically calculate the salaries.

Thanks for the reply. I think I understand now, since the formula I’m using specifies base that’s why it’s only effecting the base salary and not the Basic Salary component.

I’ve modified my formula to specify Basic Salary (BS) instead of base, however the formulas don’t seem to be having any effect when creating the pay slip and choosing the timesheet. I see the BS and gross pay as the right amount but the deductions remain at 0. I’ve tried this as well with gross_pay but to no success.

Yes the deductions are the only formulas I have in place. Do I need to create any additional formulas? Unfortunately, I can only embed on screenshot per post due to being a new member

Thank you Hamza for the suggestion. I’m happy to report I was able to successfully get the deductions to work with a timesheet based salary.

The first issue, I was not clicking update formula after changing the deduction formulas while troubleshooting. This lead to me trying code that was actually never being applied since I did not update it manually. The second issue was that I was not saving the salary slip when troubleshooting either, I assumed the calculations would take place while unsaved but I was wrong. After learning those two things, I was able to figure it out on my own. Thank you for all your suggestions!

The only other question I have is regarding payroll entries for timesheet based salary. When creating a payroll entry, I’m clicking “Salary Slip Based on Timesheet”. However, when trying to add an employee under the employees tab, I’m met with the error:

Mandatory fields required in Payroll Entry

Payroll Frequency

I don’t receive that error if I a choose a monthly frequency, however I’m then unable to select the employee as their salary structure is based off a timesheet and not monthly. I’ve confirmed a timesheet exists for the dates I’m using. Any idea what I may be doing wrong?