# DeactivateCompany

## Permission Scope

company

## Overview

DeactivateCompany transitions a company from ACTIVE to INACTIVE status. Inactive companies stop accepting new transactions while preserving all historical data. This supports scenarios where a legal entity ceases operations but records must be retained for audit and compliance.

## Business Rules

- Company must exist
- Company must be in ACTIVE status
- Deactivation does not affect existing historical transactions
- The company record is preserved (not deleted)

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Company exists?}
    B -->|No| C[Return error: COMPANY_NOT_FOUND]
    B -->|Yes| D{Company in ACTIVE?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F[Set status: INACTIVE]
    F --> G[Return deactivated company]
```

## External Dependencies

- None

## Error Scenarios

- **COMPANY_NOT_FOUND**: Specified company ID does not exist
- **INVALID_STATE**: Target entity is not in a valid status for this operation

## Test Cases

- deactivates ACTIVE company
- throws when company does not exist
- throws when company is in DRAFT status
- throws when company is already INACTIVE
