Hi, I’m facing an issue with Salary Components in ERPNext.
I have created several Salary Components where the Amount is calculated using a formula. The formulas depend on fields from the Employee and Salary Slip doctypes.
For example:
1. Boon Component
Formula:
(ctc / 360) * custom_boon_days
-
ctc→ field in Employee doctype -
custom_boon_days→ field in Salary Slip doctype
When I create the Salary Slip, the formula should calculate the amount, but the component amount is showing 0.
2. Late Day Deduction Component
I have another component for late attendance deduction.
I calculate the total late days between the Salary Slip’s:
-
start_date -
end_date
The total late days are calculated from Attendance records and stored in the Salary Slip field:
custom_total_late_day
The Salary Component formula is:
custom_total_late_day * 10
So, if the employee has 3 late days, the deduction should be 30.
However, when the Salary Slip is created, the component amount still shows 0, even though custom_total_late_day has been calculated and contains the correct value.
I have many other Salary Components with similar formulas that depend on Salary Slip custom fields, and all of them are showing 0.
It seems that the Salary Component formula is being calculated before the Salary Slip custom fields are populated/calculated, or the Salary Component formula is not able to access the Salary Slip custom fields.
I need help identifying why the formula-based Salary Components are showing 0 and how to make them calculate using the Salary Slip fields correctly.