# StartWorkOrder

## Permission Scope

workOrder

## Overview

StartWorkOrder begins execution on one released operation. It records the actual start signal and moves the work order into `IN_PROGRESS` so later reporting can accumulate quantities and time.

## Business Rules

- Target work order must exist.
- Work order must be in `PENDING`.
- Parent production order must be in an execution-capable state.
- Required predecessor operations must already satisfy sequencing policy.
- Starting the work order records the actual start timestamp.

## Process Flow

```mermaid
flowchart TD
    A[Receive start request] --> B{Work order exists?}
    B -->|No| C[Return WORK_ORDER_NOT_FOUND]
    B -->|Yes| D{Status is PENDING?}
    D -->|No| E[Return WORK_ORDER_NOT_STARTABLE]
    D -->|Yes| F{Parent order and sequence ready?}
    F -->|No| G[Return OPERATION_SEQUENCE_BLOCKED]
    F -->|Yes| H[Record actual start and set IN_PROGRESS]
    H --> I[Return started work order]
```

## External Dependencies

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

## Error Scenarios

- **WORK_ORDER_NOT_FOUND**: Referenced work order does not exist
- **WORK_ORDER_NOT_STARTABLE**: Work order is not in `PENDING`.
- **PARENT_ORDER_NOT_EXECUTABLE**: Parent production order does not allow execution.
- **OPERATION_SEQUENCE_BLOCKED**: Required predecessor work is not yet complete.

## Test Cases

- starts a pending work order
- returns error when the work order does not exist
- returns error when the work order is not pending
- returns error when the parent production order is not executable
- returns error when required predecessor work is incomplete
