Expiring Only a Partial Balance of Unused Leaves in Leave Allocation

I am working on implementing carry-forward leave and its expiry in Frappe HR. Here’s my scenario:

  1. Initial Leave Allocation:
  • Period: 16-02-2024 to 17-02-2025
  • Allocated Leaves: 20
  • Leaves Taken: 4
  • Balance at Period End: 16
  1. New Leave Allocation:
  • Period: 18-02-2025 to 17-02-2026
  • New Allocation: 20
  • Carry-Forward Enabled: :white_check_mark: (16 unused leaves added)
  • Total Leaves in New Allocation: 36
  1. Leave Application in New Period:
  • Leaves Taken: 6
  • New Balance: 30
  1. Processing Leave Expiry:
  • I manually called hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry.process_expired_allocation.
  • The function expired all 16 carried-forward leaves.

Requirement:

Instead of expiring all 16 carried-forward leaves, I want to expire only 10, since 6 leaves from the new period should be deducted from the carried-forward balance first.
So, after expiry, the final leave balance should be 30, not 36 - 16 = 20.

Question:

Is it possible to modify the expiry logic so that leaves taken in the new period are first deducted from the carry-forwarded balance before expiring? If so, what would be the best approach to achieve this in Frappe HR?

Hi Team,

It was my mistake—I had set Expire Carry Forwarded Leaves (Days) to 1. After changing it to a reasonable testable value like 30, a new Leave Ledger Entry was created with the correct number of carry-forwarded leave days and the proper expiry date.

Now, when an employee takes leave during this period, the system applies the leave deduction from the previous allocation first, ensuring that only the remaining carry-forwarded leaves expire.