# ReactivateCostElement

## Permission Scope

accounting

## Overview

reactivateCostElement transitions a cost element from INACTIVE status back to ACTIVE status, making it available again for cost postings and allocations. Only cost elements currently in INACTIVE status can be reactivated.

## Business Rules

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

## Process Flow

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

## External Dependencies

- None

## Error Scenarios

- **COST_ELEMENT_NOT_FOUND**: Referenced cost element does not exist
- **INVALID_STATE**: Target entity is not in a valid status for this operation

## Test Cases

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