Preview Chain Discrepancy
POST/api/v2/inventory/fifo-chain/preview-discrepancy
Preview the FIFO chain impact of proposed inbound lines BEFORE committing them. When a proposed entry is dated earlier than existing consumption in its product/warehouse pool, true chronological FIFO would have consumed the new stock first — this endpoint reports which later transactions would be re-anchored (and their cost changes) if the operator opts into rechain_affected on the commit.
inventory:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Advisory only — it never blocks a save, and a failure here should not block the commit flow.
Request fields:
warehouse_id(required) — destination warehouse of the proposed entryevent_date(required) — the date the entry's stock layers would carry (ISO date)lines[](required, min 1):product_id(required)quantity(required, > 0)condition(optional) — stock condition pool, omit for standard stockunit_cost(optional) — per-unit cost of the proposed stock; when omitted, it is estimated from the referenced purchase order line (ifpurchase_order_line_idis set) or the pool's most recent layerpurchase_order_line_id(optional) — resolve the unit cost from this purchase order lineevent_date(optional) — per-line date override when lines carry different effective dates
Response: one row per affected product/warehouse/condition pool. has_discrepancy=false rows mean the pool is clean. reassigned_usages counts the transactions a rechain would re-anchor; changes_preview lists up to 50 of them with before/after cost. locked_period_blocked / reallocatable=false rows cannot be rechained (the reason is included).
locked_period_until (date|null) — the accounting lock date when locked_period_blocked is true; the affected transactions carry accounting entries in the locked period and cannot be rechained until the lock date is moved earlier.
Each changes_preview row also carries in_locked_period (bool - the transaction's accounting entries fall inside the locked period), movement_id (the consuming inventory movement), movement_type, and parent_link_id/detail_link_id (the underlying document ids, e.g. the sales order for a sales order line) so clients can link each affected transaction to its source document.
Request
Responses
- 200
- 401
- 403
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Validation failed — the body is a field → messages map (Laravel shape) or the platform envelope with a stable machine-readable code. Fix the payload and resubmit.
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.