# GetAllocationCycle

## Overview

GetAllocationCycle retrieves a single allocation cycle record by id, returning all header fields (name, type, status, company reference, accounting period reference) along with all associated allocation rules (sender cost center, receiver cost objects, percentages) and allocation results (sender, receiver, allocated amount, cost element). This is the primary query for reviewing allocation cycle configuration, verifying test run results, and auditing posted allocations.

## Business Rules

- Accepts a single lookup parameter: `{ id }`
- Returns the full allocation cycle record including all header fields
- Includes all associated allocation rules with sender, receiver, and percentage details
- Includes all allocation results if the cycle has been executed (EXECUTED, POSTED, or REVERSED status)
- Allocation results are immutable records created during execution
- Returns null if no matching allocation cycle is found
- Lookup is an exact match on id

## Process Flow

```mermaid
flowchart TD
    A[Receive input with id] --> B[SELECT from AllocationCycle where id = input.id]
    B --> C{Allocation cycle found?}
    C -->|Yes| D[Load all associated allocation rules]
    D --> E[Load all associated allocation results]
    E --> F[Return allocation cycle with rules and results]
    C -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **ALLOCATION_CYCLE_NOT_FOUND**: No allocation cycle matches the given id — caller receives null

## Test Cases

- returns allocation cycle with all fields and allocation rules when found by id
- returns allocation cycle with allocation results when cycle has been executed
- returns allocation cycle with empty results when cycle is in DRAFT or VALIDATED status
- returns allocation rules with sender, receiver, and percentage details
- returns null when no allocation cycle matches the given id
