# DeleteCompany

## Overview

DeleteCompany permanently removes a company record from the system. Only companies in DRAFT status can be deleted — ACTIVE and INACTIVE companies are preserved for audit and legal compliance. This supports cleanup of incomplete company records that are no longer needed.

## Business Rules

- Company must exist
- Company must be in DRAFT status
- ACTIVE and INACTIVE companies cannot be deleted
- Company must not have any existing departments
- Company must not have any existing sites
- Deletion is permanent (hard delete)

## Process Flow

```mermaid
flowchart TD
    A[Receive delete request] --> B{Company exists?}
    B -->|No| C[Return error: COMPANY_NOT_FOUND]
    B -->|Yes| D{Company in DRAFT?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F{Has departments?}
    F -->|Yes| G[Return error: HAS_DEPARTMENTS]
    F -->|No| H{Has sites?}
    H -->|Yes| I[Return error: HAS_SITES]
    H -->|No| J[Delete company record]
    J --> K[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **COMPANY_NOT_FOUND**: Specified company ID does not exist
- **INVALID_STATE**: Company is not in DRAFT status (ACTIVE or INACTIVE companies cannot be deleted)
- **HAS_DEPARTMENTS**: Company has existing departments that must be removed first
- **HAS_SITES**: Company has existing sites that must be removed first

## Test Cases

- deletes DRAFT company
- throws when company does not exist
- throws when company is ACTIVE
- throws when company is INACTIVE
- throws when company has existing departments
- throws when company has existing sites
