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

W151: Update sales order item

Edits a single SO line. Triggered from Sales Order Detail items section. Quantity and SKU changes propagate to the FG ledger so DEMAND and ALLOCATE entries stay accurate.

Steps

  1. Load the line and parent SO. Call SalesOrders.getItemById.

  2. Block shipped orders. If the SO is at Shipped or beyond, refuse; shipped items are immutable.

  3. Apply the patch. Call SalesOrders.updateItem.

  4. Sync the ledger on quantity changes. If quantity changed, delete and re-insert the DEMAND entry for this line, plus the ALLOCATE entry if the SO is past Entered.

  5. Sync the ledger on SKU changes. Treat as remove plus add: delete all open ledger entries for the old line, then write new DEMAND (and ALLOCATE, if applicable) for the new SKU.

Returns

The updated line.

Business rules

  • Shipped lines are immutable. Editing after shipment would invent or destroy inventory.

Errors

  • NotFoundError. The line was not found.
  • InvalidTransitionError. The parent SO is past Shipped.