# GetAccrualPlan

## Overview

Retrieves a single AccrualPlan generation by id — the effective-dated grant rule (eligibility delay, base grant days, tenure tiers, annual cap, expiration policy, employment-type applicability) that governs STATUTORY grants for a balance-backed leave type.

## Business Rules

- Returns the plan generation matching the given id regardless of whether it is the current generation (`effectiveEnd IS NULL`) or a closed historical generation
- Does not resolve "the plan effective on a date" — callers needing that use `listAccrualPlansByLeaveType` for the full history of a leave type
- Returns the full rule definition: `leaveTypeKey`, `eligibilityDelayMonths`, `baseGrantDays`, `tenureTiers`, `grantCondition`, `annualCapDays`, `expirationMonths`, `appliesToEmploymentTypeId`, `effectiveStart`/`effectiveEnd`, `versionOf`

## Process Flow

```mermaid
flowchart TD
    A[Caller requests AccrualPlan by id] --> B{Plan generation with matching id exists?}
    B -- No --> C[Reject: ACCRUAL_PLAN_NOT_FOUND]
    B -- Yes --> D[Return the plan generation]
```

## External Dependencies

- [leave-management::AccrualPlan](../model/AccrualPlan.md) model — entity being queried
- [leave-management::LeaveType](../model/LeaveType.md) model — referenced by the plan's `leaveTypeKey`

## Error Scenarios

- **ACCRUAL_PLAN_NOT_FOUND**: no AccrualPlan exists for the given id

## Test Cases

- returns the plan generation when found by id
- returns a closed (historical) generation, not only the current one
- returns ACCRUAL_PLAN_NOT_FOUND for a non-existent id
