Skip to main content
Version: v1.0.0(int)

W149: Add item to sales order

Appends a new line to an existing SO. Triggered from Sales Order Detail items section.

Steps​

  1. Load the SO. Call SalesOrders.getSoById to confirm existence.

  2. Validate the SKU. Call Products.getSkuById to confirm it exists.

  3. Insert the line. Call SalesOrders.addItem with quantity and unit price. A unique violation on the L1 UNIQUE (sales_order_id, sku_id) constraint (detected via isUniqueViolation) is mapped to ConflictError — 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.