W130: List work orders
Returns WO header rows for the Work Orders page, hydrated with work-site location names, item count, expected and received totals, and the derived material status. Filters are supplied by the caller.
Steps
-
List the WOs. Call
WorkOrders.listWos(filters). The L2 op returns each header plus per-WO aggregates:itemCount,totalExpected(sum of output quantities), andtotalReceived(sum of received quantities across all receipts). -
Batch-hydrate work-site location names. Single
Locations.listByIdscall. -
Derive
materialStatusper WO. For each WO, walk its recipe-snapshot rows, compare total required vs. consumed and on-hand at the work-site location, and pick the worst-case status across all inputs:Insufficient(some input cannot be covered by on-hand + on-order + in-transit),Incoming(covered only with ORDER / in-transit),In-Stock(covered by on-hand),Allocated(WO is at production status and inputs are reserved),Consumed(all consumed via receipts). WOs with no requirements (empty recipe) returnnullfor material status. The computation reusesWorkOrders.listMaterialRequirementsand the materials inventory summary.
Returns
WO header rows with work-site location name, itemCount, totalExpected, totalReceived, and materialStatus attached.
Business rules
- Tenant scoping is automatic.
materialStatusis the row-level health indicator. Used by the UI to surface WOs at risk of starvation before they hit production.
Errors
None.