# ResumeWorkOrder

## Permission Scope

workOrder

## Overview

ResumeWorkOrder restarts a paused operation without losing the accumulated execution history recorded before the interruption.

## Business Rules

- Target work order must exist.
- Work order must be in `PAUSED`.
- Parent production order must still be execution-capable.
- Resuming preserves previously reported quantity, scrap, and time.

## Process Flow

```mermaid
flowchart TD
    A[Receive resume request] --> B{Work order exists?}
    B -->|No| C[Return WORK_ORDER_NOT_FOUND]
    B -->|Yes| D{Status is PAUSED?}
    D -->|No| E[Return WORK_ORDER_NOT_RESUMABLE]
    D -->|Yes| F{Parent order executable?}
    F -->|No| G[Return PARENT_ORDER_NOT_EXECUTABLE]
    F -->|Yes| H[Record resume event and set IN_PROGRESS]
    H --> I[Return resumed work order]
```

## External Dependencies

- [ProductionOrder](../models/ProductionOrder.md) - Parent production order must still allow execution.

## Error Scenarios

- **WORK_ORDER_NOT_FOUND**: Referenced work order does not exist
- **WORK_ORDER_NOT_RESUMABLE**: Work order is not in `PAUSED`.
- **PARENT_ORDER_NOT_EXECUTABLE**: Parent production order does not allow execution.

## Test Cases

- resumes a paused work order
- returns error when the work order does not exist
- returns error when the work order is not paused
- returns error when the parent production order no longer allows execution
- preserves prior execution history after resume
