# UpdateAllocationCycle

## Overview

updateAllocationCycle modifies an existing allocation cycle. Updates are only permitted when the cycle is in DRAFT status. In the current implementation, only the cycle name can be updated while in DRAFT.

## Business Rules

- Allocation cycle must exist
- Allocation cycle must be in DRAFT status to be updated
- Updates to cycles in VALIDATED, EXECUTED, POSTED, or REVERSED status are rejected
- Only `name` can be updated
- Emits an audit event recording previous and new field values

## Process Flow

```mermaid
flowchart TD
    A[Receive update allocation cycle request] --> B{Allocation cycle exists?}
    B -->|No| C[Return error: ALLOCATION_CYCLE_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F[Apply updates to allocation cycle]
    F --> G[Emit audit event]
    G --> H[Return updated allocation cycle]
```

## External Dependencies

- None

## Error Scenarios

- **ALLOCATION_CYCLE_NOT_FOUND**: Allocation cycle with the specified ID does not exist
- **INVALID_STATE**: Allocation cycle is not in DRAFT status

## Test Cases

- updates name on a DRAFT allocation cycle
- returns error when allocation cycle does not exist
- returns error when allocation cycle is in VALIDATED status
- returns error when allocation cycle is in EXECUTED status
- returns error when allocation cycle is in POSTED status
- returns error when allocation cycle is in REVERSED status
- emits audit event recording previous and new field values
