I am working on implementing carry-forward leave and its expiry in Frappe HR. Here’s my scenario:
- Initial Leave Allocation:
- Period: 16-02-2024 to 17-02-2025
- Allocated Leaves: 20
- Leaves Taken: 4
- Balance at Period End: 16
- New Leave Allocation:
- Period: 18-02-2025 to 17-02-2026
- New Allocation: 20
- Carry-Forward Enabled:
(16 unused leaves added)
- Total Leaves in New Allocation: 36
- Leave Application in New Period:
- Leaves Taken: 6
- New Balance: 30
- 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?