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

Materials

Raw materials (inputs to work orders, purchased on materials POs) and their type classification.

Tables owned

TablePurpose
org.materialsMaterial records (code, name, type, notes, active flag).
org.material_typesMaterial classifications (e.g., Substrate, Ink, Packaging).

Operations

Writes — Materials

  • createMaterial(conn, input)Material. input: { code, name, typeId?, notes? }.
  • updateMaterial(conn, materialId, patch)Material. Partial update.
  • setMaterialActive(conn, materialId, isActive)Material. Archive / reactivate.
  • deleteMaterial(conn, materialId)void. Hard-delete. L3 enforces "not referenced by orders or BOMs".

Writes — Material types

  • createMaterialType(conn, { name })MaterialType.
  • updateMaterialType(conn, typeId, patch)MaterialType. Rename.
  • deleteMaterialType(conn, typeId)void. L3 enforces "no material uses it".

Reads

  • listMaterials(conn, filters?)Material[]. Filters: { typeId?, isActive? }.
  • getMaterialById(conn, materialId)Material | null.
  • getMaterialsByIds(conn, materialIds)Material[]. Batch hydration.
  • listMaterialTypes(conn)MaterialType[].
  • getMaterialTypeById(conn, typeId)MaterialType | null.
  • isMaterialTypeInUse(conn, typeId){ inUse: boolean, materialCount: number }. Gates deletion.