W080: Delete SKU
Removes a SKU if nothing references it anywhere. Triggered from SKU Detail. The in-use check is broad: PO items, WO items, SO items, BOMs (as output or input SKU), and the FG ledger all block deletion.
Steps
-
Load the SKU. Call
Products.getSkuById. -
Run in-use checks across every domain that references SKUs. PO items via
PurchaseOrders.listAllItems({ skuId }), WO items, SO items, BOM as output SKU or input SKU, and FG ledger entries. -
Refuse if any reference exists. Return the affected domain counts in the error payload.
-
Delete the SKU. Call
Products.deleteSku.
Returns
Nothing.
Business rules
- Hard delete is rare. Archive (via
PATCH isActive=false, W079) is the routine path; hard delete is reserved for SKUs that exist by mistake and never moved.
Errors
NotFoundError. The SKU was not found.InUseError. The SKU is referenced by one or more downstream domains.