# SubmitPurchaseRequisition

## Permission Scope

purchaseRequisition

## Overview

SubmitPurchaseRequisition validates that a draft purchase requisition is complete and moves `status` to `SUBMITTED` for approval review.

## Business Rules

- Target purchase requisition must exist
- Only requisitions with `status` = `DRAFT` can be submitted
- Submitted requisitions must contain at least one line
- Every line must have a description, quantity greater than zero, and a non-negative estimated unit price

## Process Flow

```mermaid
flowchart TD
    A[Receive submit request] --> B{Purchase requisition exists and is DRAFT?}
    B -->|No| C[Return not found or invalid status]
    B -->|Yes| D{At least one valid line?}
    D -->|No| E[Return line validation error]
    D -->|Yes| F["Set status to SUBMITTED"]
    F --> G[Return submitted requisition]
```

## External Dependencies

- None

## Error Scenarios

- **PURCHASE_REQUISITION_NOT_FOUND**: Referenced purchase requisition does not exist
- **PURCHASE_REQUISITION_NOT_DRAFT**: Purchase requisition is not in `DRAFT` status
- **EMPTY_PURCHASE_REQUISITION_LINES**: Purchase requisition has no lines
- **DESCRIPTION_REQUIRED**: A line is missing a description
- **INVALID_QUANTITY**: Quantity is zero or negative
- **INVALID_ESTIMATED_UNIT_PRICE**: Estimated unit price is negative

## Test Cases

- submits a valid draft purchase requisition
- returns error when purchase requisition does not exist
- returns error when purchase requisition is not in draft
- returns error when purchase requisition has no lines
- returns error when a line is missing a description
- returns error when quantity is zero or negative
- returns error when estimated unit price is negative
