A warehouse inventory export is easier to verify when it has a known starting point and a clear boundary for subsequent movements. A snapshot taken at 08:00 cannot be compared with a report that includes the 08:15 dispatch unless you account for that dispatch.

Define the reconciliation key

Use a key that matches the question. For a physical inventory check, a useful key is SKU, lot, location and unit of measure. Include stock status when you need to distinguish available, reserved or quarantined stock. Agree on units before comparing quantities: a case and a piece are different quantities even if both exports say 12.

Give each movement a stable ID

A retry should not create extra inventory. Assign the movement an ID and keep that ID when it is delivered again. A repeated ID with different data needs investigation. A transfer has a debit and a credit in the same operation. Apply both together so a partial failure does not make stock appear to vanish.

Here is an illustrative fold for a single key. The caller supplies a snapshot and a complete set of movement events after that snapshot through a common cutoff. The sequence is a logical order assigned by the source, not the time a message arrived.

type Movement = { id: string; sequence: number; delta: number }; function reconcile(opening: number, after: number, through: number, events: Movement[]) { const seen = new Map<string, Movement>(); let quantity = opening; for (const event of events) { if (event.sequence <= after || event.sequence > through) continue; const previous = seen.get(event.id); if (previous) { if (previous.sequence !== event.sequence || previous.delta !== event.delta) { throw new Error('Conflicting duplicate: ' + event.id); } continue; } seen.set(event.id, event); quantity += event.delta; } return quantity; } 

An opening balance of 80 pieces plus a receipt of 12 and a dispatch of 5 gives 87. Replaying the receipt with the same ID leaves the result at 87. In production, validate the feed has reached the cutoff, retain source references for mismatches, and use integer quantities in a declared base unit. The example assumes one reconciliation key and does not check feed completeness.

Tie the export to a real workflow

Before building an integration, ask the warehouse which operations generate records and what customers can export. As an example of the operations on the other side of the integration, SAPA Logistics describes address-based storage and warehouse management records for its Astana facility. The code above is a generic example. It does not describe the operator's internal software.

Disclosure: SAPA Logistics is an SEO client.