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
-
Load the line and parent SO. Call
SalesOrders.getItemById. -
Block shipped orders. If the SO is at
Shippedor beyond, refuse; shipped items are immutable. -
Apply the patch. Call
SalesOrders.updateItem. -
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. -
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 pastShipped.