W149: Add item to sales order
Appends a new line to an existing SO. Triggered from Sales Order Detail items section.
Steps
-
Load the SO. Call
SalesOrders.getSoByIdto confirm existence. -
Validate the SKU. Call
Products.getSkuByIdto confirm it exists. -
Insert the line. Call
SalesOrders.addItemwith quantity and unit price. A unique violation on the L1UNIQUE (sales_order_id, sku_id)constraint (detected viaisUniqueViolation) is mapped toConflictError— one line per SKU per order.
Returns
The new line.
Business rules
- One line per SKU per order. Duplicate SKUs on the same SO are rejected with a 409 conflict, enforced at L1.
- No ledger side effects in v1. FG-ledger DEMAND / ALLOCATE entries for item changes after create are deferred; the initial entries are written by W144.
Errors
NotFoundError. The SO or SKU was not found.ConflictError. The SKU is already on this sales order.