Product
A Product is a specific item that can be produced at stations. Products belong to a Product Family and carry all the production parameters used for efficiency calculations, job defaults, and cost tracking.
Database Table: ops_products
| Column | Type | Description |
|---|---|---|
id | UUID (PK) | Auto-generated |
family_id | UUID (FK) | References Product Family (ops_product_families.id) |
product_code | VARCHAR(50) | Short identifier, unique within family |
product_name | VARCHAR(255) | Display name |
description | TEXT | Optional description |
standard_hours | NUMERIC(10,2) | Target labor hours to produce one unit |
default_quantity | INTEGER | Default job size when posting a job for this product |
target_scrap_rate | NUMERIC(5,2) | Acceptable scrap percentage |
unit_value | NUMERIC(12,2) | Sale value per unit |
is_active | BOOLEAN | Whether product is currently available (default TRUE) |
sort_order | INTEGER | Display ordering (default 0) |
created_at | TIMESTAMPTZ | Auto-set on creation |
updated_at | TIMESTAMPTZ | Auto-set on update |
Unique constraint: (family_id, product_code) — each product code is unique within its family.
Index: family_id
Production Fields
All production parameters live on the product, not on the family:
standard_hours— drives efficiency calculations. Efficiency = Standard Hours / Actual Hours x 100%.default_quantity— pre-fills the quantity field when an operator posts a job for this product.target_scrap_rate— the expected scrap percentage. Used for quality tracking and reporting.unit_value— what the product sells for. Enables revenue and profitability analysis alongside machine-hours and person-hours from Job Time Tracking.
Referenced By
oee_batch_details.product_id— every batch requires a product. When starting a batch, the operator must select a product from the product dropdown in the Start Batch modal (required field).- When a product is selected, its
default_quantityauto-populates thetarget_quantityfield on the batch.
Deletion Guard
A product cannot be deleted if it is referenced by any batches. Attempting to delete a referenced product raises an exception with the message: “Cannot delete product — it is referenced by existing batches. Consider marking it inactive instead.”
To remove a product from future use without deleting it, set is_active = FALSE. Inactive products do not appear in the product dropdown when starting new batches.
Relationships
- Belongs to a Product Family (
ops_product_families) - Referenced by jobs (
ops_jobs.product_id) - Referenced by batches (
oee_batch_details.product_id) - Has per-station standard hours via Station Product Standards (
ops_station_product_standards)
Equipment Standards
Products can have per-equipment overrides for standard_hours and target_scrap_rate via the Equipment Product Standards junction table (oee_product_equipment_config). This allows different production expectations for the same product on different equipment.
CRUD Operations
Managed via the OEE Settings modal (Product Families tab). Products appear as expandable cards within their family’s detail panel, with inline editing.
| Operation | Endpoint | SQL Function |
|---|---|---|
| List | GET /api/v1/ops/products | get_ops_products() |
| Create | POST /api/v1/ops/product | create_ops_product() |
| Update | PUT /api/v1/ops/product/:productId | update_ops_product() |
| Delete | DELETE /api/v1/ops/product/:productId | delete_ops_product() |
Codebase Paths
- Table:
database/sql_scripts/tables/ops_products.sql - Functions:
database/sql_scripts/functions/ops/ops_product_functions.sql - Backend:
backend/endpoints/ops.ts(handlers:handleGetProducts,handleCreateProduct,handleUpdateProduct,handleDeleteProduct)