# ActivateCostElement

## Overview

activateCostElement transitions a cost element from DRAFT status to ACTIVE status, making it available for use in cost postings and allocation processes. Only cost elements currently in DRAFT status can be activated.

## Business Rules

- Cost element must exist
- Cost element must be in DRAFT status to be activated
- Activating an already ACTIVE or INACTIVE cost element is rejected as an invalid state transition
- Upon activation, the cost element becomes available for cost postings and allocations
- Emits an audit event recording the status transition and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive activate cost element request] --> B{Cost element exists?}
    B -->|No| C[Return error: COST_ELEMENT_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F[Transition status from DRAFT to ACTIVE]
    F --> G[Emit audit event]
    G --> H[Return activated cost element]
```

## External Dependencies

- None

## Error Scenarios

- **COST_ELEMENT_NOT_FOUND**: Cost element with the specified ID does not exist
- **INVALID_STATE**: Cost element is not in DRAFT status (e.g., already ACTIVE or INACTIVE)

## Test Cases

- activates a DRAFT cost element transitioning it to ACTIVE status
- returns error when cost element does not exist
- returns error when cost element is already ACTIVE
- returns error when cost element is INACTIVE
- emits audit event recording the status transition and acting user
