# DeleteContactPerson

## Permission Scope

contactPerson

## Overview

deleteContactPerson permanently removes a contact person from the system. Contact persons who currently hold the primary designation cannot be deleted — the primary designation must be removed or transferred first. This safeguard prevents accidental loss of the primary contact designation; once removed or transferred, the organization may have no primary contact until one is explicitly set.

## Business Rules

- Contact person must exist in the system
- Contact person must be in ACTIVE status — only active contact persons can be deleted
- Contact person must not be the primary contact — primary contacts cannot be deleted
- Deletion is permanent and cannot be undone

## Process Flow

```mermaid
flowchart TD
    A[Receive delete request] --> B{Contact person exists?}
    B -->|No| C[Return error: contact person not found]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: contact not active]
    D -->|Yes| F{Is primary contact?}
    F -->|Yes| G[Return error: contact is primary]
    F -->|No| H[Delete contact person record]
    H --> I[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **CONTACT_PERSON_NOT_FOUND**: Specified contact person ID does not exist
- **CONTACT_NOT_ACTIVE**: Contact person is not in ACTIVE status and cannot be deleted
- **CONTACT_IS_PRIMARY**: Contact person is currently the primary contact and cannot be deleted

## Test Cases

- deletes a non-primary active contact person
- returns error when contact not found
- returns error when contact is not active
- returns error when contact is primary
