# DeactivateSite

## Permission Scope

organizationUnit

## Overview

DeactivateSite transitions a site from ACTIVE to INACTIVE status. Inactive sites prevent new inventory movements and order references while preserving all historical data. This supports facility closure scenarios.

## Business Rules

- Site must exist
- Site must be in ACTIVE status
- Deactivation does not delete or modify historical transactions referencing the site

## Process Flow

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

## External Dependencies

- None

## Error Scenarios

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

## Test Cases

- deactivates ACTIVE site
- throws when site does not exist
- throws when site is already INACTIVE
