Leave Allocation cannot be saved when total is 0

An employee currently has -3 leave balance (negative). In the new month, I want to grant 3 days of leave to offset this, so the net result becomes 0.
However, ERPNext/HRMS does not allow saving the Leave Allocation document when Total Leaves Allocated = 0, even though this total is the correct outcome of the allocation.

This prevents HR from bringing an employee’s negative balance back to zero via a normal monthly allocation.

Steps to Reproduce

  1. Ensure an employee has a -3 leave balance for a leave type.

  2. Create a new Leave Allocation for the new month.

  3. Set New Leaves Allocated to 3.

  4. Enable Add unused leaves from previous allocations (so the negative balance is included).

  5. The form calculates Total Leaves Allocated as 0.

  6. Click Save.

Actual Result

The system blocks saving because Total Leaves Allocated is 0.

Anyhelp would be appreciated.

As a messy workaround are you ready to allocate 3.001?

Hello,

That is the workaround we are currently using. We need to clear things up.

That is a very basic thing. There is a huge HRM module. How can this bug still exist?
I still want to think, we do something wrong.

Why dont you join Telegram: View @frappehr maybe the team can respond
or raise a github issue on GitHub · Where software is built

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.

:hammer_and_wrench: 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 :white_check_mark: 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) :warning:
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 :cross_mark: Is Compensatory.
Click Save.
:white_check_mark: 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.

1 Like

Thanks for help @Sharif101

Even though it is a workaround; what if I use that leave type always compensatory?

Scenario Where This Approach Is Wrong if Used Permanently

Here is a realistic scenario that explains why permanently marking a regular leave type as Compensatory is a serious design mistake.


Company Context

  • A mid-sized tech company (≈60 employees)
  • Leave types:
    • Annual Leave (earned monthly)
    • Compensatory Leave (earned only after overtime)
  • HR decides to permanently mark Annual Leave as Is Compensatory to avoid the “Total Leaves Allocated = 0” restriction.

Employee Story: Khalid

Initial State

  • Khalid has:
    • Annual Leave balance: 0
    • No approved overtime records
  • Everything is correct and compliant.

What Goes Wrong

1. Leave Requests Without Real Entitlement

  • Khalid submits a request for 5 days of Annual Leave
  • The system allows it because:
    • Compensatory leave does not strictly enforce pre-earned balance
  • Result:
    • Khalid takes leave without having earned it
    • No overtime justification exists

2. Corrupted HR Reports

  • At year end, HR generates reports:
    • “Annual Leave consumed per employee”
  • Because Annual Leave is marked as Compensatory:
    • Data is mixed with overtime-based leave
    • Totals become misleading and inaccurate

3. Audit and Compliance Failure

  • During internal or external audit:
    • Auditors ask: “Why were employees allowed to take paid leave without entitlement?”
  • HR cannot provide:
    • Overtime records
    • Policy justification
  • This is flagged as a policy violation, not a system issue.

4. System Upgrade Risk

  • After upgrading ERPNext / HRMS:
    • New logic may reset or restrict Compensatory leave automatically
  • Consequences:
    • Historical balances become inconsistent
    • Past leave usage can no longer be justified
    • Manual data correction becomes necessary

Final Outcome

  • Long-term data corruption
  • Loss of trust in HR metrics
  • Increased operational and audit risk
  • Costly cleanup (manual fixes or custom scripts)

Key Takeaway

Compensatory Leave is not a workaround for negative leave balances.
It is a fundamentally different leave concept with different business rules.


Correct Usage

  • :white_check_mark: Temporarily enable Is Compensatory only to correct a negative balance
  • :cross_mark: Never use it as a permanent configuration
  • :white_check_mark: For recurring cases, implement:
    • A small customization, or
    • A clear HR policy with proper system support
1 Like

Thanks for informative reply.

We will do as you said. Do you think current situation has a logic? Why total allocated balance are not allowed to be 0?