Work orders authorize production of an assembly. Mike's expanding NS usage to track every assembly run end-to-end so actual cost, labor, and yield variance roll back into assembly_cost_rollup and feed pricing decisions. This diagram traces a WO from intake (manual or low-inventory trigger) through component pull, labor capture, build complete, WO close, and variance audit, terminating in finished goods on the shelf.
low_inventory proposed_action.workordertransactions (type='WorkOrd')inventory_balance.quantityavailable < reorder_pointassembly_bom · inventory_balanceinventory_balance.reserved_qtyGET /api/assemblies/{id}/bomtransactions (WO row update)POST /api/ns/workorder/release (via NS_PUSH_QUEUE)timebill linked to WOtransactions (type='TimeBill')inventory_balance decrements per BOM line for the WO.workorderissueinventory_balance · transactions (WkOrdIss)assemblybuild (build)inventory_balance · transactions (Build)workorderclosesum(workorderissue.amount) + sum(timebill.amount) + overhead_allocguardrails.wo_variance_pct)/proposed-actions.htmlproposed_actions · reflexion_logassembly_bom.estimated_costinventory_balance · assembliesget_assembly_inventory chat tool| kind | name | purpose |
|---|---|---|
| D1 table | assemblies | master record per assembly_id · mirrors NS assemblyitem |
| D1 table | assembly_bom | BOM lines per assembly · line_key, qty, uom, estimated_cost |
| D1 table | inventory_balance | on-hand · available · reserved · per item × location |
| D1 table | transactions | WorkOrd, WkOrdIss, WkOrdCls, Build, TimeBill rows |
| D1 table | proposed_actions | wo_variance_review rows when threshold breached |
| NS record | workorder | NetSuite system-of-record for the WO itself |
| NS record | workorderissue | component consumption event |
| NS record | workorderclose | WO finalization · actual-vs-estimated roll |
| NS record | assemblybuild | FG production event · credits inventory |
| Endpoint | POST /api/ns/workorder/release | flips status to In Progress via NS_PUSH_QUEUE |
| Endpoint | POST /api/ns/workorder/close | finalizes WO; triggers variance audit |
| Endpoint | GET /api/assemblies/{id}/bom | resolves current BOM with cost rollup |
| Code path | src/index.ts (sync engine) | WO + WO line tables sync from NS every 5 min |
| Code path | src/lib/workflow_runner.ts | variance audit fires the proposed_action |