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 Equipment Product Standards (
oee_product_equipment_config, withequipment_idpointing at a station row)
Equipment Standards
Products can have per-equipment and per-station overrides for standard_hours via the Equipment Product Standards junction table (oee_product_equipment_config). This allows different production expectations for the same product on different equipment or stations.
Product Comparison
The Products page supports side-by-side comparison from /oee/products. Users select products with the row checkboxes; checkbox clicks do not open the product detail panel. The compare action appears after at least one product is selected and is enabled when two or more products are selected. The header checkbox selects or clears the visible filtered products, and the header count shows how many products are visible after filtering.
The comparison view is shareable at /oee/products/compare?ids=.... It compares product-level counts, turnaround, average touch time, rework, job activity, station performance, and standard-hour coverage for the selected products. The comparison keeps the Products page controls that change interpretation: date range, completed-only, and include-rework. Station metrics remain product-first: each station row summarizes average touch, efficiency, dwell, rework, total jobs, and configured standard coverage across the selected products; expanding the row shows the per-product station values. Station rows follow the configured station display order from Station Configuration, with name order as the fallback for stations without a configured order.
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)