# PostShipment

## Permission Scope

shipment

## Overview

PostShipment turns a draft shipment into immutable fulfillment evidence. It updates sales-order shipped progress.

## Business Rules

- Only DRAFT shipments may be posted.
- Posted quantities cannot exceed the remaining shippable quantity on each referenced order line unless a future override flow is introduced.
- Posting a shipment must not mutate inventory stock state.

## Process Flow

```mermaid
flowchart TD
    A[Receive post request] --> B[Load draft shipment]
    B --> C[Validate posted quantities and order status]
    C --> D[Update sales-order shipped progress]
    D --> E[Set shipment status to POSTED]
    E --> F[Return posted shipment]
```

## External Dependencies

- [getShipment](../query/GetShipment.md) - Load shipment details and referenced lines.

## Error Scenarios

- **SHIPMENT_NOT_FOUND**: Referenced shipment does not exist.
- **INVALID_SHIPMENT_STATUS**: Only DRAFT shipments may be posted.
- **OVER_SHIPMENT_NOT_ALLOWED**: Posted quantity exceeds remaining open quantity.

## Test Cases

- posts a shipment and updates order shipped progress
- throws when shipment quantity exceeds remaining order quantity
- throws when posting a non-draft shipment
