Skip to main content

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.

Required scope: inventory:write

Grant 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 entry
  • event_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 stock
    • unit_cost (optional) — per-unit cost of the proposed stock; when omitted, it is estimated from the referenced purchase order line (if purchase_order_line_id is set) or the pool's most recent layer
    • purchase_order_line_id (optional) — resolve the unit cost from this purchase order line
    • event_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

OK

Response Headers
    Content-Type