# ListLeaveConsumptionByGrant

## Overview

Lists every LeaveConsumption line recorded against a given LeaveGrant — every request that drew days from it, including restored draws — so the grant's ledger can be reconciled end to end without a separate audit module.

## Business Rules

- Returns every consumption row for the given `leaveGrantId`, including rows already restored (`restoredAt` set)
- The sum of `days` across non-restored rows for the grant equals `grantedDays` minus the grant's current `remainingDays` (ledger consistency)
- Rows are permanent — a restored row is never deleted, only stamped, so this query is the mechanism for reconciling a grant's full history of draws and give-backs

## Process Flow

```mermaid
flowchart TD
    A[Caller requests consumption lines for a leaveGrantId] --> B{LeaveGrant exists?}
    B -- No --> C[Reject: LEAVE_GRANT_NOT_FOUND]
    B -- Yes --> D[Load all LeaveConsumption rows referencing the grant]
    D --> E[Return rows including restored ones, each showing the drawing request and days]
```

## External Dependencies

- [leave-management::LeaveConsumption](../model/LeaveConsumption.md) model — entity being queried
- [leave-management::LeaveGrant](../model/LeaveGrant.md) model — referenced by `leaveGrantId`

## Error Scenarios

- **LEAVE_GRANT_NOT_FOUND**: no LeaveGrant exists with the given id

## Test Cases

- returns all consumption lines drawn against a grant, including restored ones
- the sum of non-restored days matches grantedDays minus remainingDays
- returns an empty list for a grant never drawn from
- returns LEAVE_GRANT_NOT_FOUND for a non-existent grant id
