W069: Delete material
Removes a material if nothing references it. Triggered from Material Detail. PO items, BOM input rows, and the materials ledger all block deletion. Archiving via PATCH isActive=false (W068) is the routine path.
Steps
-
Load the material. Call
Materials.getMaterialById. -
Run in-use checks. PO items via
PurchaseOrders.listAllItems({ materialId }), BOM input rows referencing this material, and materials ledger entries. -
Refuse if any reference exists. Return per-domain counts in the error payload.
-
Delete the material. Call
Materials.deleteMaterial.
Returns
Nothing.
Business rules
- Archive is the routine path. Hard delete is reserved for materials that exist by mistake and never moved.
Errors
NotFoundError. The material was not found.InUseError. The material is referenced by one or more downstream domains.