Leave management
Leave management defines how an employee receives leave, requests time away, and has the resulting balance recorded. It joins leave rules with attendance, approval, payroll, and employee views. See Workforce management for the wider HR domain. Related context is in Employee lifecycle and HR records, Attendance and shift management, Recruitment and staffing, Performance, skills, and learning, and Employee expenses and travel.
Leave configuration
Leave configuration turns company policy into the periods and rules used by leave operations. A leave type defines how leave behaves. A leave period defines the company date window. A leave policy groups annual entitlements by leave type.
| Concept | Purpose | Used by |
|---|---|---|
| Leave type | Defines pay, balance, holiday, carry-forward, earned-leave, and encashment rules. | Allocations, applications, adjustments, and ledger history. |
| Leave period | Defines an active company period and optional holiday source. | Policy assignment, allocation, and optional leave. |
| Leave policy | Defines annual leave amounts by type. | Employee assignment and allocation creation. |
| Leave block list | Marks dates when leave needs special approval. | Calendar display and approval checks. |
Leave types cover paid, unpaid, partially paid, optional holiday, compensatory, and earned leave. Their limits can control negative balances, consecutive days, total allocation, carry-forward, expiry, and encashment. The configuration also prevents incompatible pay choices.
References: hrms/…/leave_type.json• L48-236 hrms/…/leave_period.json• L20-57 hrms/…/leave_policy.json• L19-47 hrms/…/leave_block_list.json• L23-88
Policy assignment and allocation
A leave policy assignment gives one employee a policy for an effective range. Submission creates the employee's leave allocations for the policy's eligible types. A leave allocation is the dated entitlement from which the employee can consume leave.
The allocation flow connects policy decisions to a usable balance and its history:
flowchart LR
Rules[Leave types and policy] --> Assignment[Employee policy assignment]
Period[Leave period or joining-date range] --> Assignment
Assignment --> Allocation[Leave allocation]
Allocation --> Balance[Available balance]
Allocation --> Ledger[Leave ledger]
HR[HR bulk control] --> Assignment
HR --> Allocation
HR can use the Leave Control Panel to assign a policy or a fixed amount to selected employees. It supports leave-period, joining-date, and custom date bases. Filters narrow the employee set by company and workforce fields. The bulk operation handles employees separately, so a failed employee does not hide successful allocations for others.
Allocations cannot overlap for the same employee and leave type. Carry-forward moves eligible unused leave from the prior allocation and applies its cap or expiry. Earned leave uses scheduled credits and can catch up credits that became due before an assignment. The annual policy amount and leave-type maximum remain limits on those credits. Failed credits stay visible for an HR retry, and a retry does not add the same credit twice.
References: hrms/…/leave_policy_assignment.json• L23-115 hrms/…/test_leave_policy_assignment.py• L25-110 hrms/…/leave_allocation.py• L75-150 hrms/…/leave_allocation.py• L169-359 hrms/…/leave_allocation.py• L360-489 hrms/…/leave_allocation.js• L31-127 hrms/…/leave_allocation.js• L175-235 hrms/…/leave_control_panel.json• L33-185 hrms/…/leave_control_panel.js• L61-233 hrms/…/test_earned_leaves.py• L54-92 hrms/…/test_earned_leaves.py• L195-339 hrms/…/test_leave_policy_assignment.py• L200-254
Leave application and approval
A leave application is an employee's request for a leave type over a date range. The system calculates chargeable days from holidays and half-day choices, then moves the request through open, approved, rejected, or cancelled states. Approval turns the request into attendance and balance changes.
The request flow links employee input to policy checks and downstream records:
sequenceDiagram
participant E as Employee or HR user
participant A as Leave application
participant R as Leave rules
participant P as Approver
participant O as Attendance and ledger
E->>A: Enter type, dates, and half-day choice
A->>R: Check balance, dates, holidays, and conflicts
R-->>A: Valid request or failure
A->>P: Request review
P-->>A: Approve or reject
A->>O: Record approved leave
E->>A: Cancel approved leave when needed
A->>O: Reverse attendance and balance effects
Before approval, the system checks employee status, overlapping requests, allocation coverage, balance, joining-date eligibility, consecutive-day limits, attendance conflicts, blocked dates, and salary periods for leave without pay. A request that crosses allocations is rejected when negative balance is not allowed. The application can warn instead when the leave type permits a negative balance.
An approved request creates a negative leave ledger entry and marks working dates as On Leave or Half Day. Holidays do not count unless the leave type includes them. Cancellation removes the ledger effect and cancels the related leave attendance. The assigned approver can receive a notification with the employee, leave type, dates, and status, and the employee-facing view is refreshed after changes.
Access follows the relationship to the request. Employees can use their own leave data. An assigned approver can review the request even without general Employee read access. Access to one shared application does not expose another employee's balance.
References: hrms/…/leave_application.json• L43-257 hrms/…/leave_application.py• L104-178 hrms/…/leave_application.py• L180-298 hrms/…/leave_application.py• L300-432 hrms/…/leave_application.py• L434-702 hrms/…/leave_application.py• L702-884 hrms/…/leave_application.js• L4-116 hrms/…/leave_application.js• L206-315 hrms/…/leave_application_email_template.html• L1-35 hrms/…/test_leave_application.py• L127-228 hrms/…/test_leave_application.py• L230-375 hrms/…/test_leave_application.py• L1486-1541
Leave balance and ledger
The leave balance is the current result of entitlement and use. A Leave Ledger Entry is the dated source record for each change, so reports can explain how a balance was granted, consumed, adjusted, encashed, or expired.
| Ledger effect | Meaning |
|---|---|
| Positive leaves | Adds entitlement from an allocation or adjustment. |
| Negative leaves | Consumes leave through an application or removes entitlement. |
| Expired entry | Makes unused entitlement unavailable after its valid date. |
| Carry-forward flag | Separates transferred entitlement from the new period's amount. |
Balance views distinguish the full balance from the amount that can be consumed before an expiry date. This matters when carried leave expires before newer leave. Leave use inside a report range uses its stored ledger amount. A request that crosses the range is recalculated only for the part inside the range and uses the holiday context stored with that ledger entry.
A Leave Adjustment changes one allocation through a controlled Allocate or Reduce action. Submission writes the matching ledger change. A reduction cannot exceed the available balance, and a new allocation cannot exceed the configured maximum. The adjustment record keeps the reason and posting date with the allocation it changes.
References: hrms/…/leave_ledger_entry.json• L24-124 hrms/…/leave_adjustment.json• L31-161 hrms/…/leave_allocation.py• L112-150 hrms/…/leave_application.py• L1027-1155 hrms/…/leave_application.py• L1174-1352 hrms/…/test_leave_allocation.py• L497-616 hrms/…/test_leave_application.py• L785-860
Carry-forward and earned leave
Carry-forward transfers eligible unused leave from an earlier allocation into a later one. The leave type sets the transfer limit and expiry window. Scheduled expiry records the loss in the ledger so balance checks do not keep expired leave available.
Earned leave spreads the annual policy amount over monthly, quarterly, half-yearly, or yearly credit dates. The schedule can use a period boundary or the employee's joining date. Assignment can apply due credits at once, including a pro-rated first period, while scheduled processing adds later credits.
The annual policy amount limits earned credits. Rounding and a leave-type maximum can reduce a credit but cannot raise the annual quota. Failed scheduled credits are logged and can be retried by HR when capacity becomes available. The retry path is idempotent, so it does not duplicate a prior credit.
References: hrms/…/leave_type.json• L84-182 hrms/…/leave_allocation.py• L249-358 hrms/…/leave_allocation.py• L463-489 hrms/…/test_earned_leaves.py• L54-339 hrms/…/test_earned_leaves.py• L400-535 hrms/…/test_earned_leaves.py• L1025-1146 hrms/…/test_leave_policy_assignment.py• L327-528
Leave encashment
Leave encashment converts eligible unused leave into a payment. The leave type controls whether encashment is allowed and how many days remain protected or may be encashed. The encashment record links the employee, period, leave type, allocation, eligible days, selected days, and amount.
The amount uses the employee's salary structure and configured earning component. Submission consumes the selected leave through the ledger. The result can flow to payroll as an Additional Salary or to accounting through a separate Payment Entry. Cancellation reverses the leave and payment effects.
References: hrms/…/leave_encashment.json• L44-259 hrms/…/leave_type.json• L133-150 hrms/…/leave_type.json• L224-236
Holiday assignment and optional leave
Holiday lists supply the non-working dates used for leave-day counts and attendance. An employee or company holiday assignment determines which list applies to a date range. The same holiday context is retained with leave-use ledger entries so later balance reports preserve the original count.
Optional leave uses a separate holiday list attached to the active leave period. Every date in an optional leave request must appear in that list. This keeps optional company holidays distinct from ordinary non-working days.
References: hrms/…/leave_period.json• L19-57 hrms/…/leave_application.py• L949-977 hrms/…/leave_application.py• L674-693 hrms/…/leave_ledger_entry.json• L79-123 hrms/…/holiday_list_assignment.py• L12-66
Blocked leave dates
A Leave Block List marks dates when leave normally needs special approval. A list can apply to a company or to departments and can target one leave type or all leave types. Each date has a reason, and an allow list identifies users who may approve requests on that date.
The calendar shows blocked dates as warnings during planning. Approval enforces the rule: an applicable blocked date prevents approval by a user who is not on the allow list. This separates early notice from the final approval guard.
References: hrms/…/leave_block_list.json• L23-88 hrms/…/leave_application.py• L411-432 hrms/…/leave_application.py• L1375-1470 hrms/…/test_leave_application.py• L353-375
Employee and HR views
HR users manage leave setup, allocation, adjustment, encashment, and reports. Employees submit and track requests and view balances. Approvers review assigned requests and use calendar views to understand leave activity.
The HR form and employee-facing flow use the same leave rules for day counts, balance display, and request state. A saved or changed application refreshes the employee's leave view and the team calendar, keeping those views aligned with the submitted record.
References: hrms/…/leave_application.js• L54-89 hrms/…/leave_application.py• L175-178 hrms/…/leave_application.py• L1375-1485 hrms/…/leave_application.json• L276-357
Change checklist
When these files or sections are changed, remember to consider these:
- When a Leave Type rule changes, check allocation limits, application day counts, balance consumption, carry-forward expiry, earned credits, and encashment eligibility together.
- When a Leave Period changes, check policy assignment dates, allocation dates, active-period lookup, and the optional holiday list.
- When a policy assignment basis changes, check pro-rating, due earned credits, carry-forward, and the allocation dates created for the employee.
- When bulk allocation changes, check employee filtering and per-employee failure handling so partial success remains visible.
- When an allocation action changes, check its links to ledger entries, adjustments, expiry, earned-credit retry, encashment, and compensatory leave.
- When earned-leave timing, rounding, or quota rules change, check assignment catch-up and scheduled credits. Check that retries cannot duplicate credits.
- When a ledger source changes, check submission and cancellation for allocations, applications, adjustments, encashment, and expiry. Balance totals can remain plausible while source history is wrong.
- When holiday rules change, check leave-day counts, attendance dates, and the holiday list saved on leave-use entries.
- When blocked-date scope changes, check both calendar warnings and approval-time enforcement.
- When approval, backdated leave, self-approval, or notification settings change, check HR and employee request flows together.
- When access rules change, check employee access, assigned-approver access, workflow review, and application-level data boundaries.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A submitted allocation overlaps another allocation for the same employee and leave type. | The new allocation cannot be submitted. | Allocation overlap validation. |
| A bulk allocation fails for one employee. | That employee receives no new record while other employees may succeed. | Per-employee processing and visible failure results. |
| A request falls outside its allocation or crosses non-consecutive allocations. | The request is rejected when negative balance is not allowed. | Allocation coverage and boundary checks. |
| A request exceeds usable balance for a type that disallows negative balance. | The request cannot proceed. | Consumption balance validation. |
| A requested date has Present or Work From Home attendance. | The request is rejected. | Attendance conflict validation. |
| An unapproved user approves leave on an applicable blocked date. | Approval fails. | Block-date scope and allow-list check. |
| A request is made for an employee without a valid leave relationship or permission. | Leave details or balance access is denied. | Employee, approver, and application-scoped access checks. |
| A second adjustment targets the same allocation. | The new adjustment is rejected. | One submitted adjustment per allocation. |
| Earned leave reaches an annual or type limit. | The credit is capped or marked failed. | Quota and maximum-leave checks with retry handling. |
| An earned-credit retry is repeated. | The same credit is not added twice. | Attempt tracking and idempotent retry. |
| Encashment has no usable salary structure or earning component. | The amount cannot be prepared or submitted. | Salary and earning-component validation. |
| A leave application overlaps a processed salary period for unpaid leave. | The request is rejected. | Processed salary-period check. |
Key files
| File | Why to read it |
|---|---|
| hrms/…/leave_type.json | The rules that shape leave pay, limits, carry-forward, earned credits, and encashment. |
| hrms/…/leave_period.json | The company date boundary and optional holiday source. |
| hrms/…/leave_policy.json | The annual entitlement grouped by leave type. |
| hrms/…/leave_policy_assignment.json and test_leave_policy_assignment.py | The employee-to-policy link and its period, joining-date, pro-rating, and earned-leave behavior. |
| hrms/…/leave_control_panel.js and leave_control_panel.json | The HR bulk allocation flow and employee selection rules. |
| hrms/…/leave_allocation.py and leave_allocation.json | The entitlement lifecycle, carry-forward, earned schedule, limits, adjustment, and expiry links. |
| hrms/…/test_earned_leaves.py | The earned-credit timing, quota, rounding, failure, retry, and permission guarantees. |
| hrms/…/leave_application.py and leave_application.json | The request checks, approval effects, attendance link, balance services, and access rules. |
| hrms/…/leave_application.js and leave_application_email_template.html | The request form, balance display, approver behavior, and status notice. |
| hrms/…/test_leave_application.py | The application, attendance, holiday, block-date, balance, approval, and access guarantees. |
| hrms/…/leave_adjustment.json | The controlled allocation change and its link to one allocation. |
| hrms/…/leave_ledger_entry.json | The source history for balance changes and expiry. |
| hrms/…/leave_encashment.json | The leave-to-payroll or accounting boundary. |
| hrms/…/holiday_list_assignment.py | The employee or company holiday source used by leave counting. |
| hrms/…/leave_block_list.json | The blocked-date scope and approver exceptions. |