Skip to main content

Barcode scanner — manual testing

How to exercise the v4 barcode flow locally: device configuration, editor assignment, and cart scanning. EAN/UPC values are stored in barcode, not in the quick-search code field.

Prerequisites​

  1. A place with at least one product.
  2. A connected TPV service (RASPPI) with a CODESCAN row (Place → Devices → service → add barcode scanner).
  3. POS front open on the cart tab or a product/shortcut editor.

Without a configured CODESCAN, barcode UI and cart HID listening stay hidden (service?.codescans.length === 0).

HID simulator (host)​

Location: tools/barcode-hid-simulator/

cd tools/barcode-hid-simulator
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python simulate_barcode.py

Stdin workflow (recommended on macOS):

  1. Run the script in Terminal.
  2. Type a digit 0–9 and Enter.
  3. During the countdown, focus Chrome on the POS (editor or cart).
  4. The script injects the mapped barcode + Enter at keyboard speed.

Default mappings in barcodes.json are real EAN-13 barcodes for common soft drinks (refrescos), suitable for discovery (barcode/discover) and manual cart/editor tests:

KeyEAN-13Typical product
05449000000996Coca-Cola Original Taste 33 cl
15449000004840Fanta Naranja
25449000000729Sprite slim 25 cl
35449000205520Sprite
45449000054227Coca-Cola 500 ml
55449000120960Fanta Zero Sugar
65449000104885Sprite Zero lima-limón
78712561730034Pepsi Cola 330 ml
89002490100071Red Bull Energy Drink 250 ml
95449000120984Fanta Orange Zero 2 L

Copy those values into PRODUCT.barcode or PRESELECT.barcode in the editor — not into code.

macOS: grant Accessibility to the Python binary printed at startup if injection does nothing.

Scenarios​

Assign barcode in editor​

  1. Open product or shortcut edit (with scanner configured).
  2. Tap Assign barcode → listening overlay.
  3. Run simulator digit 1 → value 5449000004840 (Fanta Naranja) should appear with preview.
  4. Accept the editor → sync persists barcode.

Cart — single match​

  1. Assign 5449000004840 to a purchasable product.
  2. Open cart select tab.
  3. Scan/simulate the same barcode → product added to ticket.

Cart — multiple matches​

  1. Assign the same barcode to two products or shortcuts.
  2. Scan once → product match modal opens (barcode prefilled).
  3. Pick one row → added to ticket.
  1. Enable Product codes in place settings (optionProductCodes).
  2. At catalog root, tap the By number thumb (PRDNO).
  3. Enter a product code prefix on the numpad → same modal in code mode (doPrdCode).

Field reference​

FieldTableUsed for
barcodePRODUCT, PRESELECTHID scanner, editor assignment, doBarCode
codePRODUCT, PRESELECTManual keypad search when optionProductCodes

Unit tests​

  • upp-data: barcode.spec.ts, productcode.spec.ts
  • upp-base: barcode.spec.ts
  • upp-wdgt: upp-barcode-display.spec.ts
  • feature/ticket: upp-cart-select.spec.ts; feature/place: upp-product-match-modal.spec.ts

Run in nx-dev:

npx nx test upp-data --testPathPattern='barcode|productcode'
npx nx test upp-base --testPathPattern=barcode
npx nx test upp-wdgt --testPathPattern=upp-barcode
npx nx test feature-place --testPathPattern='tab-select|product-match|codescan'