# createOutboundShipment

## Overview

Creates an outbound shipment (出庫) in DRAFT status against a confirmed sales order. Builds an `OutboundShipment` header + `OutboundShipmentLine` rows (erp-kit 0.45 `outbound-shipment` module); the source-document link lives on each line (`sourceDocumentType = SALES_ORDER`, `sourceDocumentId` = the sales order, `sourceLineId` = the sales order line). Nothing leaves stock until the outbound shipment is settled. Thin wrapper over the native `outbound-shipment` create command.

Input: `salesOrderId`, `storageLocationId` (issue-from location), `effectiveDate?` (default today), `lines?` — array of `{ salesOrderLineId, quantity }`. Omit `lines` to issue every line's open quantity (ordered − shipped).

## Modules Commands Used

- [outbound-shipment] CreateOutboundShipment

## Exception Handling

| Error Code | Description |
| --- | --- |
| OUTBOUND_SHIPMENT_EMPTY_SHIPMENT_LINES | No issue lines were provided (and no open quantity to default from) |
| OUTBOUND_SHIPMENT_INVALID_QUANTITY | A line quantity is zero or negative |
| OUTBOUND_SHIPMENT_ITEM_NOT_FOUND | A referenced item does not exist |
| OUTBOUND_SHIPMENT_STORAGE_LOCATION_NOT_FOUND | The specified storage location does not exist |
| OUTBOUND_SHIPMENT_PRIMARY_UNIT_MISMATCH | A line unit does not match the item's primary unit |
| OUTBOUND_SHIPMENT_INVALID_UNIT_CONVERSION_RATE | The unit conversion rate is invalid |
