{
  "id": 20928534,
  "title": "What happens when an offline POS sale syncs twice?",
  "url": "https://urgent.news/2026/11/20/what-happens-when-an-offline-pos-sale-syncs-twice",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-20T17:50:15.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/programmings_360_091d4c5a/what-happens-when-an-offline-pos-sale-syncs-twice-338n"
  },
  "original_language": "en",
  "account": "When a Point of Sale (POS) transaction is completed while the internet connection is unavailable, there is a risk that the sale may be processed twice. The first sale is saved on the server, but the response is never received by the device. The app then retries the transaction, unaware that the previous attempt already occurred. This can result in two receipts being generated and inventory being deducted twice.\n\nTo prevent this issue, it is crucial to assign a unique client sale ID when checkout begins. This ID should be saved with the completed sale and the pending sync entry in a single local transaction. The same ID should be maintained throughout retries and app restarts. The server should also be able to handle retries safely by using a unique database constraint that is specific to the store and client sale ID. When the sale and its stock movements are committed together, the system can ensure that the same ID arriving with the same payload will display the existing receipt. If the payload differs, a conflict is returned, allowing the app to review the discrepancy.\n\nIt is essential to thoroughly test the lost acknowledgement feature. To complete a sale offline, the device should be disconnected, and the server should commit the transaction. Then, simulate a dropped response by disconnecting the device again. Restart the app and retry the pending sale. Verify that the receipt number remains unchanged, and inventory is moved exactly once. In the event of a timeout, treat it as an unknown outcome and handle it accordingly.\n\nBy implementing a stable ID system and ensuring that the server and client can handle retries reliably, retailers can avoid the complications of duplicate POS sales when offline. This approach not only simplifies the recovery process for customers but also maintains accurate inventory levels throughout the sales process.",
  "summary": "A cashier completes a sale while the connection is down. Later, the server saves it, but the response never reaches the device. The app retries. Without a way to recognize the original request, the second attempt can create a second receipt and deduct stock again. Give each sale a stable ID Generate a client sale ID when checkout starts. Save it with the completed sale and the pending sync entry…",
  "key_points": [
    "Unique client sale ID assigned to prevent duplicate transactions.",
    "Server handles retries safely with unique database constraint.",
    "Testing essential to verify receipt number and inventory accuracy."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}