# ApproveBudget

## Overview

approveBudget transitions a budget from SUBMITTED status to APPROVED status. The approver must be a different user from the budget creator to enforce segregation of duties. Only SUBMITTED budgets can be approved.

## Business Rules

- Budget must exist
- Budget must be in SUBMITTED status to be approved
- Approver must be a different user from the budget creator (segregation of duties)
- Transitions status from SUBMITTED to APPROVED
- Emits an audit event recording the status transition, approver, and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive approve budget request] --> B{Budget exists?}
    B -->|No| C[Return error: BUDGET_NOT_FOUND]
    B -->|Yes| D{Status is SUBMITTED?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F{Approver different from creator?}
    F -->|No| G[Return error: SELF_APPROVAL_NOT_ALLOWED]
    F -->|Yes| H[Transition status from SUBMITTED to APPROVED]
    H --> I[Emit audit event]
    I --> J[Return approved budget]
```

## External Dependencies

- None

## Error Scenarios

- **BUDGET_NOT_FOUND**: Budget with the specified ID does not exist
- **INVALID_STATE**: Budget is not in SUBMITTED status
- **SELF_APPROVAL_NOT_ALLOWED**: Approver is the same user who created the budget (segregation of duties violation)

## Test Cases

- approves a SUBMITTED budget transitioning it to APPROVED status
- returns error when budget does not exist
- returns error when budget is not in SUBMITTED status
- returns error when approver is the same as the budget creator
- emits audit event recording the status transition and approver
