# DeleteProfitCenter

## Overview

deleteProfitCenter permanently removes a profit center that is in DRAFT status. ACTIVE and INACTIVE profit centers cannot be deleted. Deletion also removes any hierarchy assignment associated with the profit center.

## Business Rules

- Profit center must exist
- Only DRAFT profit centers can be deleted
- ACTIVE profit centers cannot be deleted; they must be deactivated first
- INACTIVE profit centers cannot be deleted
- Deletion removes the profit center and its hierarchy assignment
- Emits an audit event recording the deletion and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive delete 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[Remove hierarchy assignment]
    F --> G[Delete profit center]
    G --> H[Emit audit event]
    H --> I[Return success]
```

## 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 DRAFT status (ACTIVE or INACTIVE profit centers cannot be deleted)

## Test Cases

- deletes a DRAFT profit center successfully
- deletes a DRAFT profit center and removes its hierarchy assignment
- returns error when profit center does not exist
- returns error when profit center is in ACTIVE status
- returns error when profit center is in INACTIVE status
- emits audit event recording the deletion and acting user
