Engagement · Logistics and supply chain
Order-to-cash integration across e-commerce, ERP and warehouse systems at an industrial distributor
An industrial distributor keeps web orders, the ERP and the warehouse in step using events, repeat-safe writes and alerts that identify the failing hop.
The situation
An industrial distributor sells fasteners, bearings, safety equipment and maintenance supplies to factories and contractors, taking orders through an e-commerce site, through EDI from its larger customers and by phone to inside sales. The ERP owns customers, contract pricing, credit limits, orders and invoices, while a warehouse management system handles picking, packing and shipping across several distribution centers. Over the years the three systems were connected with scheduled file exports, a few direct database links and a script that polls for new web orders.
The business has grown on top of those connections, and customers now expect the site to show their own contract price and real availability and to confirm a ship date at checkout. What actually happens is that stock on the site is several hours out of date, an order can exist on the web without reaching the ERP, and invoices wait for a nightly shipment file. The distributor has no wish to replace any of the three systems, so the work is to engineer the connections between them properly.
What was going wrong
Web orders created twice or never
The polling script submits each web order to the ERP, and when the ERP responds slowly the call can time out after the order has already been created, so the retry creates a second one. If the script crashes partway through a run, orders are skipped until a customer calls to ask about them.
Availability that is hours behind
The site reads a stock file that is exported a few times a day. A contractor can therefore order forty units of an item that was picked clean that morning, and the order is accepted and then short-shipped, leaving customer service to make the apology call.
Shipments confirmed out of order
When an order ships in three parcels from two distribution centers, the partial shipment confirmations reach the ERP late, sometimes after the remaining lines have been cancelled. Invoices then go out for the wrong quantities and have to be credited back by hand.
Failures discovered by customers
An order rejected because of an inactive ship-to address is written to a log file on a server, and no alert is raised. The distributor usually learns about it when a buyer asks where the delivery is, several days after a line has stopped at the customer's plant.
Our approach
In orderMap each flow and its owner
We would trace order capture, credit check, allocation, pick release, shipment, invoice and payment across the three systems and record which system is the authority for each field. The ERP owns price, credit and order status and the warehouse system owns physical stock and shipment facts, and any disagreement is settled with sales, finance and operations at this stage.
Measure limits and peaks
We collect the actual constraints, including ERP API throughput while its batch jobs are running, the interface options of the warehouse system, the arrival times of EDI batches, and order peaks on Monday mornings and at month-end. The design is sized against those figures and against the maintenance outage each system takes.
Design events and failure paths
Each business fact becomes an event with its own schema, covering order placed, order accepted, credit hold applied, lines allocated, shipment confirmed and invoice posted. For every consumer we document what happens on a timeout, a duplicate, an out-of-order arrival or a rejection, and where a message that cannot be processed ends up.
Test the failure cases before go-live
The flows run against production-shaped volumes while batch jobs are active, and we deliberately send the same order twice, deliver a shipment confirmation before its allocation, cut the connection in the middle of a write and take the ERP offline for an hour. The test passes when the systems reconcile afterwards without any manual repair.
Cut over one flow at a time
Stock availability moves first because the site only reads it, and web order submission follows, with shipment confirmation and invoicing after that. Each flow runs alongside its old file or script until the reconciliation report shows that the two agree, at which point the old path is removed.
The design
The parts and what each one doesEvent broker and schemas
A message broker carries order, stock and shipment events, with versioned schemas held in a registry and ordering guaranteed per order number, so that the events for any one order are processed in sequence.
Order submission service
The site writes the order and an outbound event in one transaction through an outbox table. A worker then submits the order to the ERP with an idempotency key derived from the web order number, so a retry returns the ERP order that already exists.
Availability service
The service consumes receipts, picks, adjustments and allocations from the warehouse system and the ERP and serves available-to-promise figures by item and distribution center to the site, marking any location that stops reporting as stale.
Fulfillment workflow
Each order has a durable workflow that holds its state through credit hold, allocation, partial shipments, backorders and cancellation. Because events are applied by version, a late confirmation cannot move an order back to an earlier state.
Review queue and replay
Messages that fail validation or run out of retries go to a queue with the reason attached, where an operator can fix the cause, such as an inactive address, and replay the message from a console.
Reconciliation and monitoring
An hourly job compares web orders, ERP orders, shipments and invoices and lists anything missing or mismatched. A correlation identifier follows each order through every hop, which lets alerts name the system involved and the likely cause.
Safeguards
What keeps a bad day smallEvery write safe to repeat
Order creation, shipment posting and invoice triggers all carry idempotency keys, and where the target system offers no deduplication we keep a store for it on our side. The duplicate test runs as part of every release.
Credit and price stay in the ERP
The integration does not calculate contract prices or override credit holds at any point. It asks the ERP and passes on the answer, and an order on hold waits in the workflow where the credit team can see it.
Degraded modes are designed
When the ERP is down, the site still accepts and queues orders and tells the customer that confirmation will follow. When stock data is stale, the site shows availability as unconfirmed and does not promise a ship date.
Rehearsed recovery
Before each flow goes live, the distributor's operations team uses the runbook to carry out one replay and one rollback to the old path on their own.
Timeline
Weeks 1 to 2
We build the flow inventory, agree field ownership, measure limits and peak volumes, draft the event schemas and write down the failure paths for each consumer.
Weeks 3 to 5
The broker, the schemas and the availability service are built and run alongside the stock file, and the site switches to the service once the two agree.
Weeks 6 to 8
We build the order submission service and the review queue and run load and failure tests with the ERP batch jobs active, after which web orders cut over.
Weeks 9 to 11
The fulfillment workflow, shipment confirmation and invoice trigger are built, and reconciliation runs hourly against the nightly file until that file is retired.
Week 12
Dashboards, alerts and runbooks are completed, and the operations team carries out a replay and a rollback without help before taking over the flows.
What it changes
What the build is designed to changeWhen a customer places an order on the site, exactly one order is created in the ERP regardless of what happens on the network in between. The availability shown at checkout reflects what the distribution centers hold at that moment, and a location that has stopped reporting is labeled as such so the site does not rely on its figures. Partial shipments post in the correct sequence, which means the invoice matches what left the dock and finance no longer has to issue corrections for integration faults.
The larger change concerns who finds problems first. A rejected order shows up in a queue with its reason within minutes, an hourly comparison lists anything on which the systems disagree, and operations staff can replay a message without calling a developer. New consumers such as a customer portal or a carrier integration can subscribe to events that already exist, and the measures below are how the distributor would judge whether the design has achieved these changes.
How success is measured
- Duplicate and missing orders found by the hourly reconciliation job
- Delay between a stock movement and the availability that the site shows
- Orders short-shipped because the availability shown at checkout was wrong
- Time between shipment confirmation and the invoice being posted in the ERP
- Share of integration faults that alerts detect before a customer reports them
What generalizes
Field ownership is settled before technology
Most disagreements between systems can be traced to two of them editing the same field. Deciding which system is the authority for price, stock and status removes a whole class of faults that a broker or a retry policy cannot fix on its own.
Out-of-order events are routine here
With several distribution centers and partial shipments, events will arrive late and in the wrong sequence. A design that keeps state for each order and applies events by version handles that as normal operation, whereas a design that assumes events arrive in order treats each one as an incident.
Reconciliation belongs in the integration
Retries and idempotency reduce drift between systems but cannot guarantee there is none. A scheduled comparison turns an unknown error rate into a short list of discrepancies that someone can work through each morning.
Related
If you have a similar problem, a two-week review is the usual place to start.
Tell us what you are trying to do and where it is stuck. A principal reads every message and replies within one working day.
