# CreateContactPerson

## Overview

createContactPerson adds a contact person to an organization-type business partner. Contact persons represent individuals within an organization who serve as points of contact for business communications. At least one communication channel (email or phone) is required. Contact persons are created in ACTIVE status.

## Business Rules

- Partner must exist in the system
- Partner must be of type ORGANIZATION — contact persons cannot be added to INDIVIDUAL partners
- First name and last name are required and must be non-empty
- At least one of email or phone must be provided
- Email, if provided, must be in a valid format
- Contact person is created in ACTIVE status

## Process Flow

```mermaid
flowchart TD
    A[Receive create request] --> B{Partner exists?}
    B -->|No| C[Return error: partner not found]
    B -->|Yes| D{Partner is ORGANIZATION?}
    D -->|No| E[Return error: partner not organization]
    D -->|Yes| F1{firstName and lastName non-empty?}
    F1 -->|No| F2[Return error: invalid name]
    F1 -->|Yes| F{Email or phone provided?}
    F -->|No| G[Return error: missing communication channel]
    F -->|Yes| H{Email provided?}
    H -->|Yes| I{Email format valid?}
    I -->|No| J[Return error: invalid email format]
    I -->|Yes| K[Create contact person in ACTIVE status]
    H -->|No| K
    K --> L[Return created contact person]
```

## External Dependencies

- None

## Error Scenarios

- **PARTNER_NOT_FOUND**: Specified partner ID does not exist
- **PARTNER_NOT_ORGANIZATION**: Partner is of type INDIVIDUAL, not ORGANIZATION
- **INVALID_FIRST_NAME**: First name is empty or not provided
- **INVALID_LAST_NAME**: Last name is empty or not provided
- **MISSING_COMMUNICATION_CHANNEL**: Neither email nor phone was provided
- **INVALID_EMAIL_FORMAT**: Provided email is not in a valid format

## Test Cases

- creates contact person
- returns error when partner not found
- returns error when partner is INDIVIDUAL
- returns error when firstName is empty
- returns error when lastName is empty
- returns error when neither email nor phone provided
- returns error for invalid email format
- returns error when whitespace-only channels provided as only communication
- creates with ACTIVE status
