# ConfirmStockMovement

## Overview

confirmStockMovement transitions a stock movement from DRAFT to CONFIRMED status. All move lines are revalidated before confirmation to ensure data integrity. A confirmed movement is ready for execution.

## Business Rules

- Stock movement must exist
- Stock movement must be in DRAFT status
- All move lines must pass validation (items active, locations valid, quantities valid)

## Process Flow

```mermaid
flowchart TD
    A[Receive confirm request] --> B{Movement exists?}
    B -->|No| C[Return error: STOCK_MOVEMENT_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: STOCK_MOVEMENT_NOT_DRAFT]
    D -->|Yes| F{All lines valid?}
    F -->|No| G[Return validation error]
    F -->|Yes| H[Update status to CONFIRMED]
    H --> I[Return confirmed movement]
```

## External Dependencies

- None

## Error Scenarios

- **STOCK_MOVEMENT_NOT_FOUND**: Referenced stock movement does not exist
- **STOCK_MOVEMENT_NOT_DRAFT**: Stock movement is not in DRAFT status

## Test Cases

- returns error when not found
- returns error when not DRAFT
- returns error when no move lines
- returns error when item not active
- returns error when destination location not found
- confirms valid movement
