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

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

  1. List the WOs. Call WorkOrders.listWos(filters). The L2 op returns each header plus per-WO aggregates: itemCount, totalExpected (sum of output quantities), and totalReceived (sum of received quantities across all receipts).

  2. Batch-hydrate work-site location names. Single Locations.listByIds call.

  3. Derive materialStatus per 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) return null for material status. The computation reuses WorkOrders.listMaterialRequirements and 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.
  • materialStatus is the row-level health indicator. Used by the UI to surface WOs at risk of starvation before they hit production.

Errors

None.