WFDASH-WEBAPP/public/pos
Dave a499265b26 feat(pos): raise a system delivery note on an account sale
An account sale at the till used to produce a delivery-note-shaped slip that
was rendered entirely on the device and printed on the 80mm thermal printer.
Nothing reached the server, so the paperwork the client signed had no record
behind it. Cash / card / EFT are untouched and still get the thermal slip.

An account sale now creates a real `delivery_notes` record. The DN is raised
server-side INSIDE `checkoutSale` rather than by a follow-up call from the
till, because the offline queue (`flushQueue`) re-posts `/checkout` and
nothing else — a client-side second call would be silently dropped for every
sale taken while the network was down, which is exactly when a till is
flakiest.

`pos_sales.delivery_note` is the idempotency anchor that makes it
exactly-once: on a replay it hands back the existing DN instead of making a
second one, and a sale whose first attempt left the field blank retries. It
self-heals.

Deliberately non-fatal: if the DN can't be created the sale still succeeds.
The money and the stock movement are real by then; failing the checkout would
leave the drawer disagreeing with the stock ledger. The till is told instead.

Also in here:
  - DN number collision retry. The generator reads the highest existing number
    and adds one, which is not atomic, while PB holds a unique index on it. The
    POS adds a second concurrent writer, so two creates could collide and 500
    on a benign condition.
  - GET /api/v1/pos/sales now expands customer, customer.company and
    delivery_note so history.html can rebuild the DN card on a reprint. The
    nested customer.company matters — customer.company is itself a relation,
    so without it the card printed a raw PB id where the name belongs.
  - "Print slip" is hidden for account sales; that tender produces a delivery
    note, not a slip.

New GET /api/v1/pos/delivery-note/[number]/pdf streams the A4 original behind
assertPosAuth, so the till's bearer key stays its only credential. It does not
point at the CRM's unauthenticated invoicing route.

Verified end to end against a live note: DN26100401, correct company, both
lines with pricing, PDF attached, stock decremented once, and a replay of the
same client_ref returned the same DN without a duplicate.
2026-10-04 13:15:29 +02:00
..
fa fix(pos): correct Font Awesome webfont URL in bundled CSS 2026-08-31 18:04:14 +02:00
cashup.html fix(pos): point the cash-up printer errors at the right screen 2026-09-19 07:46:57 +02:00
epos-print.js fix(pos): print the letterhead's own logo, and match delivery note to the sale slip 2026-09-06 23:03:24 +02:00
history.html feat(pos): raise a system delivery note on an account sale 2026-10-04 13:15:29 +02:00
index.html feat(pos): letterhead service + 2 API endpoints + vat_percent on Letterhead type 2026-09-04 09:13:53 +02:00
letterhead-config.js feat(pos): letterhead service + 2 API endpoints + vat_percent on Letterhead type 2026-09-04 09:13:53 +02:00
manifest.json chore(pos): bump SW cache to v13, skip /api/ caching, scope manifest to /pos/ 2026-08-31 01:48:49 +02:00
pos-app.js feat(pos): raise a system delivery note on an account sale 2026-10-04 13:15:29 +02:00
pos-config.js feat(pos): enhance POS configuration to handle missing API key prompts gracefully and add slip preview functionality in settings 2026-09-04 11:55:38 +02:00
pos.html feat(pos): letterhead service + 2 API endpoints + vat_percent on Letterhead type 2026-09-04 09:13:53 +02:00
receipt.html feat(pos): raise a system delivery note on an account sale 2026-10-04 13:15:29 +02:00
settings.html feat(pos): add slip-layout.html block editor, move preview out of settings.html 2026-09-04 13:42:01 +02:00
slip-layout.html fix(pos): print the letterhead's own logo, and match delivery note to the sale slip 2026-09-06 23:03:24 +02:00
slip-layout.js fix(pos): print the letterhead's own logo, and match delivery note to the sale slip 2026-09-06 23:03:24 +02:00
sw.js feat(pos): raise a system delivery note on an account sale 2026-10-04 13:15:29 +02:00
test-longpress.html feat(pos): enhance POS configuration to handle missing API key prompts gracefully and add slip preview functionality in settings 2026-09-04 11:55:38 +02:00
theme.js chore(pos): copy WFSALES POS mockup into public/pos/ (unwired) 2026-08-31 01:41:54 +02:00