# DeactivatePartner

## Permission Scope

partner

## Overview

deactivatePartner transitions a business partner from ACTIVE to INACTIVE status. Deactivation is used when a business relationship is suspended or terminated. Only partners in ACTIVE status can be deactivated. Inactive partners cannot participate in new transactions but their historical data is preserved.

## Business Rules

- Partner must exist in the system
- Partner must be in ACTIVE status
- After deactivation, the partner cannot participate in new transactions

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Partner exists?}
    B -->|No| C[Return error: not found]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: invalid state transition]
    D -->|Yes| F[Update status to INACTIVE]
    F --> G[Return deactivated partner]
```

## External Dependencies

- None

## Error Scenarios

- **PARTNER_NOT_FOUND**: Specified partner ID does not exist
- **INVALID_STATE_TRANSITION**: Requested state transition is not allowed from the current status

## Test Cases

- deactivates an ACTIVE partner
- returns error when partner not found
- returns error when partner is DRAFT
- returns error when partner is INACTIVE
