# DeactivateProfitCenter

## Overview

deactivateProfitCenter transitions a profit center from ACTIVE status to INACTIVE status. Once inactive, the profit center can no longer receive new transaction assignments. Historical transactions referencing this profit center remain intact. Only ACTIVE profit centers can be deactivated; deactivating a DRAFT profit center is not permitted.

## Business Rules

- Profit center must exist
- Profit center must be in ACTIVE status to be deactivated
- Deactivating a DRAFT profit center is rejected as an invalid state transition
- Deactivating an already INACTIVE profit center is rejected as an invalid state transition
- Existing historical transactions referencing this profit center are not affected
- Emits an audit event recording the status transition and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate profit center request] --> B{Profit center exists?}
    B -->|No| C[Return error: PROFIT_CENTER_NOT_FOUND]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F[Transition status from ACTIVE to INACTIVE]
    F --> G[Emit audit event]
    G --> H[Return deactivated profit center]
```

## External Dependencies

- None

## Error Scenarios

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

## Test Cases

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