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

W087: Create BOM

Creates the recipe linking input materials and input SKUs to an output SKU. Triggered from the BOM page or from BOM Detail for a SKU that doesn't yet have a recipe. The header and items are inserted atomically.

Steps

  1. Validate the output SKU. Confirm it exists, is active, and does not already have a BOM (BOM.getBomForSku must return null).

  2. Validate input rows. For each input row, confirm the referenced material or input SKU exists and is active. Enforce the materialId XOR inputSkuId invariant per row (exactly one of the two must be set).

  3. Create the BOM header. Call BOM.createBom({ outputSkuId }).

  4. Insert the composition atomically. Call BOM.replaceBomItems(bomId, items).

Returns

The BOM header plus its items.

Business rules

  • One BOM per output SKU. A second BOM for the same output SKU is rejected.
  • Multi-level BOMs are allowed. An input SKU may itself have a BOM; the cost rollup at WO creation handles recursion via weighted averages.
  • No cycle detection in v1. A pathological chain like SKU A to SKU B to SKU A is not prevented by the workflow today. Cycle detection is a future concern; for v1 the team relies on data hygiene.

Errors

  • NotFoundError. The output SKU, an input material, or an input SKU was missing.
  • ValidationError. A BOM already exists for this SKU, or an input row violates the XOR invariant.