Stage 2 · First Version · Chapter 19

How to Build a Point of Sale With Offline Mode and Receipt Printing

A cashier screen meets hardware, weak internet and real cash. Learn scanner-first flow, receipt printing, scale barcodes and offline queues.

Dr. Yahia Elkhouli · November 15, 2026 · 7 min read

In August 2026, a customer sent me photos of three paper receipts. Someone at the shop had written on them by hand: "not recorded on the system". The cashier had sold the goods, printed the receipts, handed them to the shoppers, and the sales were nowhere in KashBoss.

We checked the invoices around those times. There was a 13-minute gap in the shop's sales that afternoon, and all three receipts fell inside it. The internet had dropped, the cashier screen had switched to offline mode, saved the sales and printed them. That part worked. What never happened was the upload when the internet came back.

Then we ran one more query, and it was the one that hurt. Every invoice saved offline and uploaded later carries a small marker. Among that customer's invoices on the server, none had the marker. The offline upload had never worked for them, not once. One line of code had switched off the connection watcher on the web version. The cashier was saving sales, never uploading them, and telling nobody.

The short answer

To build a point of sale that does not lose sales, design for four hard facts: speed (scanner and Enter key only), hardware (print receipts as a black-and-white image at the printer's width), bad internet (queue offline sales with a unique request ID and never delete them on a temporary error) and real cash (update the invoice, stock, shift and cash box in one transaction). Then test on the device your cashiers really use.

Four ways a POS differs from the rest of your app

Speed beats beauty. A cashier serves one shopper after another for eight hours. Every extra click, every wrong cursor position, every popup that steals focus costs time in front of a queue.

Hardware. Receipt printers, label printers, scanners and scales each speak their own language, and a web browser is not allowed to talk to most of them directly. A thermal printer, which prints on heat-sensitive paper, wants a stream of printer commands (usually a standard called ESC/POS), not a formatted page.

Bad internet. Shops often have a weak connection that comes and goes. The cashier must keep selling, and every sale must reach the server exactly once.

Real cash. At shift end the cashier counts the drawer. If the system is wrong by a few cents, an honest cashier gets blamed.

Step 1: Find where the cashier really sits

In KashBoss, cashiers work on a Windows computer in a web browser; the mobile app is for owners, managers and field reps. I told the assistant this many times and it still forgot, once spending a long time in the mobile code path. The offline bug above lived exactly in a platform difference. Offline saving ran everywhere, but the connection watcher ran only on mobile. The rule in the assistant's memory now: for any cashier problem, assume the web version and check every "only on web" or "only on mobile" branch first.

Step 2: A cashier who never touches the mouse

One cashier used a scanner for items and the mouse for everything else. The owner said the cashier kept clicking the search box between items. The real bug was different: after each scan, the code cleared the text field but not the search filter behind it. The field looked empty, the product grid beneath was also empty, and the cashier thought something had broken. When a user complains about an extra step, look for what makes the screen lie to them.

The final flow: the scanner field has focus when the screen opens; Enter on an empty field goes to payment; Enter on the payment screen completes the sale, including the number-pad Enter; and in the success window the print button already has focus. Every popup returns focus to the scanner field, the keyboard runs the same checks as the mouse, and a guard ignores a fast second press so one sale cannot become two invoices.

THE PROMPT
Make the [CASHIER SCREEN NAME] usable with a barcode scanner and the keyboard only.
The flow: scan items, press Enter to go to payment, Enter to complete the sale, Enter to print.
After every scan, clear the field AND any search filter, and keep focus in the scanner field.
After every popup closes, return focus to the scanner field.
The keyboard must run exactly the same checks as the buttons, and a fast double press must never create two invoices.
List every place focus can be lost, then test the full flow with five sales in a row and tell me where it broke.

Receipts that look right

Our first receipts went through the browser's print dialog and failed three ways: the browser shrank the receipt into the middle of empty paper, our template used a font with no Arabic letters, and the thin decorative font and light gray lines turned into scattered dots on a thermal printer. The fix was to stop sending a document and send a picture: the receipt is drawn as an image exactly as wide as the printer's head (576 dots for 80 mm paper, 384 for 58 mm), converted to pure black and white, and sent as raw ESC/POS commands. The printer never has to understand any language. It prints dots.

The last step is hard because a web page cannot send raw data to a USB printer. We ended up with a small Windows helper that listens only on the cashier's computer and accepts requests only from our website.

THE MISTAKE WE MADE

If the helper is not running, or no printer has been chosen in that browser, printing falls back to the browser's print dialog. At first it did this silently. A customer told us their receipts "never come out right", even though they had installed the helper. They were seeing the browser dialog every time and adjusting the paper size by hand. Now the screen shows a clear message whenever it falls back, so the cashier knows something needs setting up.

Scale barcodes and offline queues

A shop selling cheese by weight uses a scale that prints a label whose barcode contains the weight, so the barcode differs for every piece. On our customer's scale the format was a leading 2, a five-digit item code, the weight in grams as five digits, then a check digit. Three lessons: support it in every search screen, not only the cashier; try exact barcode matches first, because 73 ordinary products had real barcodes that also start with 2 and have 13 digits; and "found" is not "priced correctly". Products stored in grams were priced as if the scale reported kilos, a thousand times too low, with no error message.

Offline is not one state. With the cable out the app knows it is offline. The common case is a weak connection: the app believes it is online, starts sending, and the connection dies mid-request. Every offline path needs a check before sending and a fallback to the queue when a network error happens during sending. Each queued sale carries a unique request number, and the database refuses the same number twice. After we fixed the connection watcher, the stuck invoices uploaded by themselves, with their original dates.

THE PROMPT
Audit the offline mode of [FEATURE NAME].
1. Does it handle a weak connection that drops in the middle of a request, not only "no internet"?
2. Does every queued operation carry a unique request ID, and does the database refuse duplicates? Show me the function code.
3. Which errors delete an item from the queue? A temporary server error must never delete the user's work.
4. Where is the failure reason saved, and can the user see it in the real app, not only in debug mode?
Test it by turning the network off and on in the middle of three sales, and show me the server records afterwards.

The drawer must match to the cent

In April, a cash sale appeared in the shift totals but never reached the cashier's cash box, because several separate calls ran in a row and the one that credited the cash box failed silently. We merged the steps into one database function that updates the shift and the cash box together and refuses to run twice for the same invoice. In July a cashier was charged a few cents of shortage because a 33.33% promotion produced a price like 100.005 in the app while the database stored 100.01. Round prices in one shared function.

Key takeaways

Chapter 19 of the book has the full checklist.

Frequently asked questions

How can a web POS print to a thermal receipt printer?

A browser cannot send raw commands to a USB printer on its own. The reliable route is a small helper program on the cashier's computer that receives the receipt from your web page and sends it to the printer. If that route is unavailable, fall back to the normal print dialog and tell the user why.

How should a POS handle losing the internet?

Save the sale on the device with a unique request ID, show it as pending, and upload it when the connection returns. The database must refuse a repeated request ID so a sale arrives exactly once, and a temporary server error must never delete a queued sale.

How do scale barcodes work?

The scale prints a label whose barcode holds an item code and a weight. The POS reads the code, looks up the price per unit and calculates the total from the weight. Try normal exact-match barcodes first so ordinary products are not mistaken for weighed ones.