# PauseWorkOrder

## Permission Scope

workOrder

## Overview

PauseWorkOrder temporarily halts an in-progress operation and records the reason for the interruption. The command preserves accumulated execution history so the work order can later resume.

## Business Rules

- Target work order must exist.
- Work order must be in `IN_PROGRESS`.
- Pause reason is required.
- Pausing preserves previously reported quantity, scrap, and time.

## Process Flow

```mermaid
flowchart TD
    A[Receive pause request] --> B{Work order exists?}
    B -->|No| C[Return WORK_ORDER_NOT_FOUND]
    B -->|Yes| D{Status is IN_PROGRESS?}
    D -->|No| E[Return WORK_ORDER_NOT_PAUSABLE]
    D -->|Yes| F{Pause reason provided?}
    F -->|No| G[Return PAUSE_REASON_REQUIRED]
    F -->|Yes| H[Record pause event and set PAUSED]
    H --> I[Return paused work order]
```

## External Dependencies

- None

## Error Scenarios

- **WORK_ORDER_NOT_FOUND**: Referenced work order does not exist
- **WORK_ORDER_NOT_PAUSABLE**: Work order is not in `IN_PROGRESS`.
- **PAUSE_REASON_REQUIRED**: No pause reason was provided.

## Test Cases

- pauses an in-progress work order
- returns error when the work order does not exist
- returns error when the work order is not in progress
- returns error when no pause reason is provided
- preserves prior execution quantities and time after pause
