Lot Genealogy
Trace Lot Genealogy
Returns a genealogy tree for a batch/lot. `batch_number` is required; `product_id` is optional and auto-resolved from the batch number when it uniquely identifies a FIFO layer. When the same batch number is used across multiple products, the API responds 409 with a `candidates` array so a UI can prompt for product disambiguation. Direction `backward` traces from finished good back to raw material inputs (recall use case); `forward` traces from raw material to all downstream produced lots (recall impact analysis).
Search Batch Numbers (Typeahead)
Typeahead for the 'Trace a Lot' batch-number field. Returns up to 25 distinct FIFO-layer batch numbers matching the `search` term, each with single-product context. Authentication: requires a Bearer token (PAT).
Trace by Sales Orders
Recall (reverse) — backward 'made-from' forest for one or more sales orders. For every finished-good batch shipped on each order, traces upstream to the raw-ingredient lots (and their vendors) that went into it. Drives the genealogy page's 'trace by sales order(s)' mode and the Sales Orders list view's 'Trace Genealogy (Backward)' bulk action. Authentication: requires a Bearer token (PAT).
Resolve Sales Order Numbers
Resolve selected order ids -> their numbers + customers via a direct whereIn (the SO list filter[id] coerces '3,4' to a single id and can't resolve multiple). Lets the 'trace by sales order(s)' chips show real 'SO-…' labels before the slower trace returns. Authentication: requires a Bearer token (PAT).
Bulk Resolve Sales Order Numbers
Bulk-resolve pasted / imported sales-order NUMBERS into ids, so a recall can be seeded from a spreadsheet column or CSV instead of typing each order. Body: `numbers` (array, max 2000, each <= 64 chars). Returns `matched` (id + number + customer) and `unmatched` (numbers that matched no order). Authentication: requires a Bearer token (PAT).
List Affected Lots and Suppliers
Recall (reverse) — the implicated lots + suppliers behind a set of sales orders: every raw-ingredient / finished-good lot that fed the orders' shipped goods, deduplicated, with supplier and a count of how many of the orders each lot touches. Authentication: requires a Bearer token (PAT).
Export Affected Lots and Suppliers (CSV)
Recall (reverse) — streams the implicated lots + suppliers for a set of sales orders as a CSV download for the recall paper trail. Same resolution + 422 semantics as `GET /api/manufacturing/lot-genealogy/affected-lots-by-sales-orders`. Authentication: requires a Bearer token (PAT).
List Affected Sales Orders
Recall workflow — the sales orders / customers that consumed the traced batch (or a finished good produced from it). Forward trace only; backward traces (sources) have no customers. Authentication: requires a Bearer token (PAT).
Export Affected Sales Orders (CSV)
Recall workflow — streams the affected sales-order / customer rows as a CSV download for the recall paper trail. Same batch resolution + 404/409 semantics as `GET /api/manufacturing/lot-genealogy/affected-sales-orders`. Authentication: requires a Bearer token (PAT).