Retail · Case Study

Stop Selling Stock You Don't Have

The final unit sells at the till while the online store still shows one available. A synchronization service cannot make two disconnected systems update at the same instant. It needs a reservation policy, a stock authority and an honest limit on how stale availability can become.

Explore Retail automation →

How can a retailer synchronize inventory across systems?

Process stock changes through a durable queue and apply them to a versioned inventory ledger. Decide which system owns on-hand quantities, reservations and stock adjustments before publishing availability. Consumers must tolerate repeated or late events and reconcile periodically against source snapshots. Temporary disagreement is expected in an eventually consistent system. Safety stock, feed-lag warnings and a manual exception queue can limit exposure while stores and warehouses catch up.

Technical details

Stock changes need a recovery route

A successful update advances the stock ledger. A failed message enters a controlled replay route without losing its original event identity.

Azure FunctionsValidate source ID and version

Validate stock events and update read models.

SKU-location event
Azure Service BusDurable queue and ordered sessions

Buffer stock changes and isolate failed messages.

deduplicate and apply
SQL ServerVersioned stock ledger

Maintain versioned stock and reconciliation history.

Transient failureBounded retry with the original event ID.
Dead-letter reviewInventory owner investigates failed messages.
Controlled replayCheck versions again. Do not recount the sale.
Power BIRead-only conflict and feed-lag reporting

Report stock conflicts and lag by location.

Broker duplicate detection has a finite window. Ledger deduplication remains necessary.
Simplified implementation architecture. Open a technology to inspect its responsibility.

Version ownership and replay permissions

Broker duplicate detection has a configured time window and does not replace database deduplication. Limit stock-write credentials to the sync service. Monitor source lag, version gaps and dead-letter age. Record original and corrected quantities with reason and approver; restrict dashboards by store responsibilities.

Disconnect a store, then reconcile its history

Simulate offline tills, duplicate sales, returns, stock transfers and stale snapshots. Pilot a limited SKU range with conservative availability rules. Verify restore and replay from the ledger before expanding to every store.

Technical references: Azure Service Bus duplicate detection limits.

consistency field notes

Two systems can disagree without either event being lost

A till can record a sale while the online store still shows the previous balance. The question is how long that disagreement may last, which source owns the quantity and what happens when an older snapshot arrives later.

Stock ownership is a business rule. Transporting updates faster cannot resolve two systems that both claim authority over the same field.

Three decisions behind a balance that can be reconciled
DecisionWhat the record must preserve
Who owns the field?

Agree ownership by stock field

The warehouse may own physical stock while the commerce system owns reservations. Define available-to-sell as an approved calculation, including allocations and safety stock. Never add two absolute stock snapshots as if they were movement events.

Which change is newer?

Order changes within a stock key

Publish events with source event ID, SKU, location and source version. Use Service Bus sessions where ordered processing is needed for a SKU-location key. In SQL Server, deduplicate events and atomically update the ledger with optimistic version checks. Older snapshots cannot overwrite newer accepted state.

How does the ledger recover?

Reconcile after disruption

Publish versioned availability to each destination and record its acknowledgement. Retry transient failures within limits, then move poison messages to a dead-letter queue. A reviewed replay preserves the event ID. Compare periodic source snapshots and record who approved any corrective adjustment.

Interactive demo

A sale moves faster than the old stock snapshot

Follow a stock change between the till, the ledger and the online store. Compare source versions before deciding which update belongs in the current balance.

Local interactive demo

Stock version sandbox

Fictional records
STORE 01 / SKU-2086Demo on-hand units
v17Accepted source version
LATE WAREHOUSE SNAPSHOT6Source version 17
    Send the events in different orders. A repeated sale and an older absolute snapshot must not increase the current quantity.
    Reference records for this demo
    Stock movement ledger
    SKU / locationIncoming eventVersionDecision
    SKU-208 / Store 01Sale: one unitVersion 18Apply
    SKU-208 / Store 01Late stock snapshotVersion 17Hold
    SKU-510 / Store 03Transfer receivedVersion 32Apply
    Interactive reconstruction using fictional records. All actions stay in this browser session. No client system, message, purchase, approval or invoice is changed.

    Related implementation: explore another BytePilot workflow.

    Watch agreement and delay together

    A synchronized stock service needs two views: whether balances reconcile and how long changes take to reach their destinations. The following definitions guide that review without implying achieved stock accuracy.

    Does the quantity agree?

    Inventory discrepancy rate

    SKU-location balances outside agreed reconciliation rules divided by checked balances.

    Overselling cancellations

    Orders canceled for unavailable stock divided by accepted orders, using reviewed cancellation reasons.

    How long does disagreement last?

    Stock update lag

    Source change time to destination acknowledgement, reported with clock-quality limitations.

    Recovery time

    Time from connection restoration to a fully reconciled location ledger.

    Offline stores, stale versions and reconciliation

    Will synchronization eliminate overselling?

    No such guarantee follows from this design. Concurrent sales and offline stores create exposure; reservations, safety stock and source freshness rules must be agreed.

    What does eventual consistency mean for a store?

    A sale may take time to reach every connected system. The design makes that delay measurable and defines how availability behaves while updates are pending.

    Who decides a conflicting stock quantity?

    Field-level source ownership handles routine conflicts. An authorized inventory owner reviews unexplained differences and corrective adjustments.

    Can failed messages be replayed safely?

    Only if original event identifiers and version checks are retained. Replaying must not count the same sale or transfer twice.

    Related case studies

    T◉▤!
    STORE 01 / MORNING BRIEFSample briefing

    Before you open.

    Two operational checks. One data warning.

    01
    Check SKU-208 availabilityInventory · below threshold
    ↗
    02
    Confirm transfer TR-81Receiving · receipt pending
    ↗
    !
    Warehouse feed is lateDo not infer stock from missing data
    ↗
    Sample data · Interactive demo inside
    Retail

    The Store Manager's Daily AI Briefing

    Store managers open multiple reports and message threads to find the issues needing action.

    • Microsoft Teams
    • Azure OpenAI
    • Power Automate
    • Dataverse
    View case study
    RECONCILIATION / PAY-801Fee explained
    POINT OF SALERM 100.00Transaction recorded

    Reference
    PAY-801

    =98 + 2
    PROCESSOR SETTLEMENTRM 98.00Net after documented fee

    Processor fee
    RM 2.00

    Source fee matched
    PAY-801 · inspect fee bridge
    PAY-802 · inspect missing settlement
    Sample data · Interactive demo inside
    Retail

    Catch Payment and Refund Discrepancies Before Month-End

    Finance manually matches POS transactions with settlements and refund records.

    • Python
    • DuckDB
    • Prefect
    • PostgreSQL
    • Metabase
    View case study

    Discuss your stock records

    Follow one SKU through a sale and a stock transfer

    An inventory owner and a store manager can usually expose the important conflicts quickly. We can use that journey to agree quantity ownership, reservation behavior and the rules for reviewing an adjustment.

    Discuss your stock records →

    Workflow Automation · Choosing a workflow to automate

    The stock record
    A SKU history with conflicting versions
    The availability rule
    The policy for reservations and offline sales