# ReleaseCommitment

## Overview

releaseCommitment releases a commitment back to available budget when a purchase order is cancelled. This restores budget availability by removing the reserved commitment amount. The full remaining commitment amount is released.

## Business Rules

- Commitment must exist for the specified cost element, cost object, and period
- Releases the full remaining commitment amount back to available budget
- Budget availability increases by the released amount
- Commitment is associated with a purchase order cancellation event
- Emits an audit event recording the release and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive release commitment request] --> B{Commitment exists?}
    B -->|No| C[Return error: COMMITMENT_NOT_FOUND]
    B -->|Yes| D{Remaining commitment amount > 0?}
    D -->|No| E[Return error: NO_COMMITMENT_TO_RELEASE]
    D -->|Yes| F[Release remaining commitment amount]
    F --> G[Increase budget availability]
    G --> H[Emit audit event]
    H --> I[Return released commitment]
```

## External Dependencies

- None

## Error Scenarios

- **COMMITMENT_NOT_FOUND**: No commitment exists for the specified cost element, cost object, and period
- **NO_COMMITMENT_TO_RELEASE**: Commitment has already been fully consumed or released (remaining amount is zero)

## Test Cases

- releases remaining commitment amount back to available budget
- increases budget availability by the released amount
- returns error when commitment does not exist
- returns error when commitment has already been fully consumed
- releases a partially consumed commitment (only remaining portion)
- emits audit event recording the release and acting user
