# ActivateProfitCenter

## Permission Scope

accounting

## Overview

activateProfitCenter transitions a profit center from DRAFT status to ACTIVE status, making it available for transaction tagging and profitability reporting. Only profit centers currently in DRAFT status can be activated.

## Business Rules

- Profit center must exist
- Profit center must be in DRAFT status to be activated
- Activating an already ACTIVE or INACTIVE profit center is rejected as an invalid state transition
- Upon activation, the profit center becomes available for revenue and cost transaction assignments
- Emits an audit event recording the status transition and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive activate profit center request] --> B{Profit center exists?}
    B -->|No| C[Return error: PROFIT_CENTER_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 profit center]
```

## External Dependencies

- None

## Error Scenarios

- **PROFIT_CENTER_NOT_FOUND**: Profit center with the specified ID does not exist
- **INVALID_STATE**: Target entity is not in a valid status for this operation

## Test Cases

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