How to Fix Negative Leave Balances in Frappe HR (The “Zero Allocation” Trick)
Have you ever tried to reset an employee’s negative leave balance to zero in Frappe HR or ERPNext, only to be stopped by the system?
The Scenario: An employee has a negative balance (e.g., -3 days). You want to allocate +3 days to bring the net balance to 0. However, when you try to save the Leave Allocation, the system throws an error:
“Total leaves allocated is mandatory for Leave Type…”
This happens because the system’s validation logic prevents saving a Leave Allocation where the total result is 0, unless it is a special leave type.
Here is a quick, code-free workaround to bypass this restriction in 3 simple steps.
Prerequisites
You must have HR Manager or System Manager permissions.
The employee currently has a negative leave balance.
Step 1: Temporarily Modify the Leave Type
First, we need to “trick” the system into thinking this leave type is allowed to have a zero balance.
Go to the Search Bar and type “Leave Type”.
Open the Leave Type List and click on the specific leave type (e.g., Annual Leave).
Scroll down to the settings section.
Check the box labeled
Is Compensatory.
Click Save.
Why? The system code explicitly allows specific leave types (like Compensatory Leave) to have a zero balance. By checking this, we bypass the validation rule.
Step 2: Create the “Zero” Allocation
Now that the door is open, you can perform the correction.
Go to Leave Allocation and click Add Leave Allocation.
Select the Employee.
Select the Leave Type (the one you just modified).
The system will show the Unused Leaves as negative (e.g., -3).
In the New Leaves Allocated field, enter the exact positive amount needed to zero it out (e.g., 3).
Ensure the Total Leaves Allocated field now shows 0.
Click Save and then Submit.
Result: The system will accept the document successfully because the “Is Compensatory” flag is active.
Step 3: Revert the Leave Type Settings (CRITICAL) 
You must return the system to its original state to prevent issues with future leave requests.
Go back to the Leave Type document (e.g., Annual Leave).
Uncheck the box
Is Compensatory.
Click Save.
Summary
By temporarily enabling the “Is Compensatory” flag, you successfully reset the negative balance to zero without manipulating the database or writing custom code. The employee’s record is now clean and accurate.