Manufacturing Orders
List Manufacturing Orders
Paginated list of Manufacturing Orders. Supports Spatie QueryBuilder filters, sorts, and pagination.
Create Manufacturing Order
Create a draft MO from a BOM. Hydrates component + output + operation snapshot lines from the BOM.
Show Manufacturing Order
Return the full Manufacturing Order with its BOM, component/output lines, operations, warehouses, and events.
Update Manufacturing Order
Update Manufacturing Order
Delete Manufacturing Order
Only draft MOs may be deleted.
Confirm MO
Draft -> Confirmed. Reserves components. Optionally lock in FIFO layer picks keyed by mo_component_line_id.
Start MO
Confirmed -> In Progress.
Record Production
Record actual component consumption, output produced, and operation actuals for an in-progress MO. Posts inventory movements (consumption + receipts) and creates FIFO layers for outputs.
Complete MO
In Progress -> Completed. Finalizes variance calculations.
Cancel MO
Cancel a manufacturing order. Transitions any non-closed status → Cancelled and releases any inventory reservations. **Required body fields:** - `reason_code` (string, required) — must be one of the 5 allowed values: - `plan_changed` — Plan changed - `materials_unavailable` — Materials unavailable - `customer_cancellation` — Customer cancellation - `equipment_issue` — Equipment issue - `other` — Other **Optional body fields:** - `notes` (string, nullable, max 2000) — Free-text reason explanation - `reason_notes` (string, nullable, max 2000) — **Alias for `notes`** — accepted for API consistency. If `notes` is absent and `reason_notes` is provided, it is copied into `notes` during validation. Sending both means `notes` wins. **Returns 422 if `reason_code` is missing or not in the allowed list.** **Authentication:** Bearer token required.
Close MO
Completed -> Closed. Locks the MO from further changes.
Reopen MO
Closed -> Partially Completed (or Completed if completed_quantity >= planned_quantity). Required reason (string, max 2000) is captured in the Reopened event payload.
Generate Accounting Transaction (MO)
Generate (or rebuild) the WIP-routed GL journals for this MO — ONE journal per production iteration, each dated to that iteration's production date (so multi-day / multi-period production is period-accurate). Conversion costs (labor + overhead + outsourced service) are capitalized into finished goods through Work In Process:
MO Events (Audit Log)
Returns audit log of every status transition and significant action on the MO.
List MO Inventory Movements
Paginated list of inventory movements created by this Manufacturing Order. Includes movements linked to the MO itself, to any of its component lines (consumption + scrap) and to any of its output lines (production output).
List MO FIFO Layers
Paginated list of FIFO layers CREATED by this Manufacturing Order (production output layers). Layers consumed by this MO are surfaced on each layer's own detail view.
Show MO Output Line
Show a single Manufacturing Output line — the canonical detail view used by the standalone Manufacturing Output page.
Show MO Component Line
Show a single Manufacturing Consumption (component) line — the detail view used by the standalone Manufacturing Consumption page.
List Output Line Inventory Movements
Paginated inventory movements scoped to a single MO output line — every movement that touches the FIFO layer this output produced. Includes the production-output movement itself and any downstream consumption of the batch (sales, transfers, further manufacturing). Backs the Movements tab on the Manufacturing Output detail page.
List Output Line FIFO Layers
Paginated FIFO layers scoped to a single MO output line. Always returns at most one row — the layer this output produced — but shapes the response as a paginated collection so the frontend can reuse the same datatable contract as the MO-scoped equivalent.
List MO Production Iterations
Paginated list of production iterations for this Manufacturing Order. Each iteration is one call to Record Production; includes restore-cost information and a reversibility flag.
Show Production Iteration
Returns a single production iteration with all relations eagerly loaded (manufacturing order, created_by user, reversed_by user) plus the output FIFO layer expanded. Backs the standalone Production Iteration detail page.
List Production Iteration Inventory Movements
Paginated inventory movements scoped to a single production iteration — every movement created by the underlying Record Production call (component consumption, scrap, and output). Scope is `inventory_movements.production_iteration_id = {iteration.id}`. Backs the Movements tab on the Production Iteration detail page.
List Production Iteration FIFO Layers
Paginated FIFO layers scoped to a single production iteration — every layer (output + any auxiliary) created by the underlying Record Production call. Scope is `fifo_layers.production_iteration_id = {iteration.id}`. Mirrors the MO-output-line FIFO-layers endpoint so the frontend datatable can reuse the same contract.
Reverse Production Iteration
Reverses a production iteration: restores input FIFO layers, deletes the output layer (if not yet drawn from), rolls back actuals on the component/output lines, decrements `completed_quantity` on the MO, and writes a `production_reversed` audit event. Refuses with 422 if already reversed, mismatched MO, or downstream-drawn.