Working offline: how data stays in sync
A look at the sync engine that keeps reps productive even with no coverage.

In Egypt and across the region, a distribution rep passes through weak-coverage spots every day: a basement warehouse, a village on the edge of the governorate, a crowded market where the network drops. Any field sales system that stops when the internet drops will stop often, and reps will go back to paper.
That is why the VanSalesHub rep app is built on a simple principle: the phone records first, the server checks later. This article explains how that works, and what ensures no invoice is lost or duplicated.
1. The data a rep needs is on the phone
At first sign-in, the app downloads in one go everything the rep needs to work: products, units, price lists, customers, routes, warehouses, return reasons and the rep's van stock. After that, each sync brings down only the changes since the last one.
Van stock, however, is replaced in full at every sync rather than merged, except while the phone still holds stock movements for that van that have not been uploaded. A van balance is a sensitive number, and merging two versions of it could produce a figure that matches neither.
2. Every action goes into an outbox
When a rep issues an invoice, records a collection or loads stock, the action is saved on the phone immediately and joins a queue for upload. The rep can finish the whole day without waiting for the network.
When the connection returns, the app uploads what is in the queue, and retries at growing intervals if it fails, from a few seconds up to half an hour. After five failed attempts a document is set aside as failed, and the rep can retry it from the sync badge.
3. Upload before download
The order of sync matters: the app uploads what it has first, then downloads updates from the office.
Take an example: a rep sells in the morning with no internet, and at noon the office changes a product's price. If the app pulled the new price first, things could get mixed up. But the invoice goes up first, and the server does not price it at today's price; it uses the price in force at the moment of sale, because every change to a price list is kept as a new version without erasing the old one.
4. No duplicates, however many retries
The most dangerous thing about weak networks is a request that reaches the server while the reply gets lost. The phone thinks the upload failed and sends it again. Without protection, the invoice would be recorded twice.
So every document on the phone carries a fixed identifier sent with every attempt. If the server receives the same document a second time, it recognises it and does not record it again, and the phone treats the upload as successful.
5. The server is the reference
The phone calculates the total and tax to show the rep and the customer, but that calculation is indicative. On upload, the server recalculates and checks the rules:
- Is there enough van stock?
- Is there a price for the product in that unit on the customer's list?
- Does the credit invoice stay within the customer's credit limit?
If the rules hold, the invoice is issued with its official number, INV-…, or RET-… for a return. If not, it is refused, and the refusal usually reveals a data gap for the office to fix.
That is also why an invoice printed before upload carries only a temporary number from the phone and shows its sync status: the official number and final total are only known once the server accepts it.
6. The right time for every action
When an invoice is uploaded hours after the sale, what time does it get? The phone records the actual moment of sale and sends it, and the server checks that it falls within the rep's journey. Visit times are likewise kept within the journey's bounds. So the day's report matches what happened, not when the network came back.
What this means in practice
- For the rep: once the journey is started (which needs a connection), work as if the network were always there. The one piece of advice is not to uninstall the app while the phone holds unsent documents. Signing out keeps them on the phone until the rep signs back in.
- For the office: some invoices may appear late, until the rep finds coverage, but they arrive with the right time and the right price.
- For the owner: no lost invoices, no duplicates, and no numbers the phone calculated without review.
In short
Working offline is not an extra in field sales; it is a basic requirement. The real challenge is not saving on the phone but making sure every action reaches the right place exactly once, at the right price and time. That is what sync in VanSalesHub is designed to guarantee.