Files
mcp-wms-wiki/wiki/concepts/stock-assignment.md
T
arthur 9ce6ae37be lint(standard): corrections completes mode standard
- Em dashes: 1712 remplaces par tirets simples (86 fichiers + _index.md,
  en-tete section Limagrain conserve)
- Checklists: 24 '- [ ]' -> '- ☐' (3 pages operations, plus de todos Obsidian)
- Ancres: 33 reparees (slugs GitHub + ancres HTML <a id> reconnues),
  1 reciblee (manuel de reten)
- related: tenseflow -> tense-flow, pie -> mechanical-elements,
  group.md retire (doublon shipping)
- Registre: compteur global 122 -> 131 pages
- Rapport racine _lint_report.md mis a jour (scan v2 + re-scan final: 0 anomalie)
- Aucun fichier limagrain/ modifie (cloisonnement)
2026-07-20 13:01:21 +02:00

118 lines
7.7 KiB
Markdown

---
title: "Stock Assignment"
type: concept
sources:
- sources/archives/24_Process_assignation_stock.md
related:
- concepts/stock.md
- concepts/order-outbound.md
- concepts/picking.md
- concepts/replenishment.md
- concepts/kits.md
- concepts/crossdocking.md
- concepts/cutting-stock.md
- concepts/task.md
- concepts/tense-flow.md
last_compiled: "2026-04-17"
---
# Stock Assignment
## Overview
**Stock assignment** is the engine that binds concrete stock to outbound work. Given an outbound order line (and its `OutboundOrderLineDetails`), it decides **which stock lines** will fulfil the demand and **what type of task** will be created to physically move them (picking, container shipping, replenishment, virtual picking).
Every line detail is assigned independently - a line can have several details either because the requested item is a **non-assembled kit** (one detail per component) or because **alternative items** have been configured (if the main item is short, the WMS adds an extra detail with the substitute item and zeroes the main item's quantity).
The assignment engine is a chain of workflows all prefixed `StockAssignProcess_*`. The main entry point is `StockAssignProcess_AssignOutboundLine_PR`, which loops over the line's details through `StockAssignProcess_AssignOutboundOrderLineDetails_PR`.
## Engine pipeline
### 1. Fetch and lock the detail
Workflow: `StockAssignProcess_GetLockAndUpdateDetail_PR`
Loads the outbound line detail, locks it for the assignment run, and reads the minimum data needed for stock search. To expose additional detail fields to downstream steps, extend the `Select` of the query in this workflow.
### 2. Search candidate stock
Workflow: `StockAssignProcess_GetAvailableStockForOutboundOrderLineDetails_PR`
Calls the query **`Stocks_AssignableForProductOutboundOrderLineDetailsAndStockAssignStrategy`**. Additional filters on assignable stock (e.g., custom-attribute filtering, reservations, supplier constraints) are added as extra `where` clauses on this query - once they are in place, SmartUI surfaces them under the **"Trace d'assignations de stock"** button for auditability.
### 3. Apply assignment strategy
Two branches:
- **Kits, manufacturing orders, TenseFlow** - the WMS prioritises stock already sitting in the dedicated consumption zone (assembly zone, production supply zone, TenseFlow supply zone) through `StockAssignProcess_CalculateByAssignmentManufacturingAndKits_PR`. This avoids pulling stock across zones when an in-zone alternative exists.
- **Standard details** - applies the outbound priorities (preferred status, preferred UoM…) and then:
- `Stocks_ApplyOutboundLogic_PR` - applies the shipping logic of the item (FIFO, FEFO, LIFO, custom).
- `StockAssignProcess_CalculateEfficiencyMode_PR` - applies the efficiency mode (see [concepts/replenishment.md](replenishment.md#efficiency-modes) and the outbound efficiency settings on the shipping profile).
The candidate list is narrowed and finally validated by `StockAssignProcess_ValidateStockList_PR`.
### 4. Persist assignments and build tasks
Two sibling workflows:
- `StockAssignProcess_CreateAssignments_PR` - writes the assignment rows (visible in SmartUI under **Allocations de stock**).
- `Outbound_StockAssignCreateOrderLineDetailsTasks_PR` - translates each assignment into a task of the appropriate type (see below).
## Assignment types
| Type | Description |
|---|---|
| **PickingLocations** | Classical picking task on a location flagged as picking. The stock is already at a pickable place. |
| **ReplenishmentAssignment** | The candidate location permits replenishment but the on-hand quantity is insufficient. The engine creates a **picking task and a parallel replenishment task** - covers both static (PDL-driven) and dynamic replenishment scenarios. |
| **ShippingContainer** | The full container (mono-reference) is needed and the location allows container shipping. A container-shipping task is created instead of a picking task. |
| **PickingContainer** | Specific to **TenseFlow**. A `BufferReplenishment` task is created first, moving the container to the supply zone ; during virtual picking, virtual picking tasks are generated against the buffered stock. |
## Interactions with other features
### Kits
If **any component** of a non-assembled kit cannot be assigned, **no component is assigned** - the engine rolls back and leaves the line short so the operator does not start half-kits. The matching behaviour for assembled kits (ready-made component) is standard.
### Crossdocking
When the item allows crossdocking, an inbound expected to arrive shortly will block the engine from re-assigning the outbound line to existing stock - it will wait for the crossdocking candidate. Customers who do not want this behaviour comment out the crossdocking branch in the stock search query.
### Alternatives
When the main item cannot cover the line quantity, the engine inserts a new detail with the alternative item and sets the main item's remaining quantity to zero. The alternative detail goes through the same pipeline - it may itself fall back to another alternative if further shortage occurs.
## Customisation points
| Need | Workflow / query to touch |
|---|---|
| Expose more line-detail fields to the engine | Extend `Select` in `StockAssignProcess_GetLockAndUpdateDetail_PR` |
| Filter candidate stock on a new criterion | Add `where` clauses in `Stocks_AssignableForProductOutboundOrderLineDetailsAndStockAssignStrategy` (visible in SmartUI "Trace d'assignations de stock") |
| Generate **only picking tasks** (e.g., for waves - wave mode only consumes picking tasks) | Modify `StockAssignProcess_GetStockToAssignForStrategy_PR` ; if the WMS version has the assignment-merge feature, also modify `Outbound_CreatePickingLocationsTasks_PR` |
| Disable crossdocking blocking | Comment out the crossdocking predicate in the stock search query |
## Observability
- **SmartUI → Allocations de stock** - shows which stock line is reserved for which outbound line detail, with the assignment type.
- **"Trace d'assignations de stock"** button - exposes the extra filters added to `Stocks_AssignableForProductOutboundOrderLineDetailsAndStockAssignStrategy` so support can see why a candidate was rejected.
## Common issues
| Symptom | Likely cause |
|---|---|
| Outbound line stays in `StockFailure` despite visible stock | Filter on the assignment query (custom clause), preferred status rejecting everything, or logistic attribute mismatch |
| Kit line assigned with some components but not all | Should not happen - rollback rule is absolute. Check if components were split across two details by an alternative cascade |
| Expected replenishment-plus-picking not generated | Picking location does not actually permit replenishment, or all candidate reserves are locked |
| Container shipping task created when picking was expected | Line quantity equals full container quantity **and** location allows container shipping - disable the container-shipping branch on the location if not desired |
## Related
- [[stock]] - the data model assignment writes against
- [[order-outbound]] - outbound lines and their `OutboundOrderLineDetails` are the inputs of the engine
- [[picking]] - most assignment outputs are consumed as picking tasks
- [[replenishment]] - `ReplenishmentAssignment` type materialises the replenishment-plus-picking pairing
- [[kits]] - kit handling special case (all-or-nothing rollback, dedicated assembly-zone preference)
- [[crossdocking]] - assignment waits for inbound crossdocking candidates unless disabled
- [[cutting-stock]] - cutting items use the same pipeline with cut-specific post-processing
- [[task]] - tasks are the tangible output of each assignment
- [[tenseflow]] - the PickingContainer assignment type is the TenseFlow-specific path