# DeactivateWorkCenter

## Overview

DeactivateWorkCenter removes a work center from future routing and release selection. The command preserves historical work-order and cost records while blocking new execution use.

## Business Rules

- Target work center must exist.
- Only `ACTIVE` work centers can be deactivated.
- Deactivation may be blocked when future active routings or open released work still require the work center.
- Historical work orders and cost baselines remain intact after deactivation.

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Work center exists?}
    B -->|No| C[Return WORK_CENTER_NOT_FOUND]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return WORK_CENTER_NOT_DEACTIVATABLE]
    D -->|Yes| F{Open dependency check passes?}
    F -->|No| G[Return WORK_CENTER_IN_USE]
    F -->|Yes| H[Set status to INACTIVE]
    H --> I[Return inactive work center]
```

## External Dependencies

- [Routing](../models/Routing.md) - Future active routings may block deactivation.

## Error Scenarios

- **WORK_CENTER_NOT_FOUND**: Target work center does not exist.
- **WORK_CENTER_NOT_DEACTIVATABLE**: The work center is not in `ACTIVE`.
- **WORK_CENTER_IN_USE**: Future routings or open released work still require the work center.

## Test Cases

- deactivates an active work center with no blocking dependencies
- returns error when the work center does not exist
- returns error when the work center is not active
- returns error when open routing or released-work dependencies block deactivation
- returns error when open work orders block deactivation
- preserves historical work-order and cost data after deactivation
