# ActivateWorkCenter

## Permission Scope

manufacturingMaster

## Overview

ActivateWorkCenter validates that a draft or inactive work center has the execution data required by planning and costing, then marks it available for routing and work-order use.

## Business Rules

- Target work center must exist.
- Only `DRAFT` or `INACTIVE` work centers can be activated.
- Required calendar or availability context must be present.
- Capacity must be positive.
- Any configured rates and overhead settings must be internally valid.
- Activation makes the work center eligible for active routing operations.

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B{Work center exists?}
    B -->|No| C[Return WORK_CENTER_NOT_FOUND]
    B -->|Yes| D{Status activatable?}
    D -->|No| E[Return WORK_CENTER_NOT_ACTIVATABLE]
    D -->|Yes| F[Validate calendar, capacity, and rates]
    F --> G[Set status to ACTIVE]
    G --> H[Return active work center]
```

## External Dependencies

- [Site](../../../organization/docs/model/Site.md) - Site-scoped activation requires a valid site context.

## Error Scenarios

- **WORK_CENTER_NOT_FOUND**: Referenced work center does not exist
- **WORK_CENTER_NOT_ACTIVATABLE**: The current status does not allow activation.
- **MISSING_CALENDAR_CONTEXT**: Required calendar or availability data is missing.
- **INVALID_CAPACITY**: Capacity is zero or negative.
- **INVALID_RATE**: Labor or machine rate is negative.
- **OVERHEAD_CURRENCY_REQUIRED**: Fixed-amount overhead requires a currency.

## Test Cases

- activates a valid draft work center
- reactivates a valid inactive work center
- returns error when the work center does not exist
- returns error when the status does not allow activation
- returns error when required calendar context is missing
- returns error when capacity is not positive
- returns error when a configured rate is negative
- returns error when fixed overhead is missing its currency
