Skip to content

fix(printers): align receipt and KOT semantic parity - #620

Merged
khaira777 merged 7 commits into
mainfrom
fm/flocafe-receipt-kot-semantic-parity-r1
Sep 3, 2026
Merged

khaira777 merged 7 commits into
mainfrom
fm/flocafe-receipt-kot-semantic-parity-r1

Conversation

@khaira777

@khaira777 khaira777 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Implement Phase 5 of the FloCafe internationalization and printing remediation plan: align non-financial semantic content across intended-equivalent receipt and KOT paths.

Inspect the existing printing architecture and parity fixtures before editing. Render add-ons and special instructions in compact WebUSB receipts. Align served/ready item filtering across backend, WebUSB, and browser KOT paths. Preserve add-on quantities in KOT output. Align order numbers, special-instruction markers, table/customer fields, and loyalty display where the existing print contract intends equivalence.

Acceptance criteria:

  • Compact WebUSB receipts retain the intended add-on and special-instruction semantics.
  • Backend, WebUSB, and browser KOT paths apply the same served/ready filtering contract.
  • KOT output preserves add-on quantities.
  • Intended-equivalent order numbers, special-instruction markers, table/customer fields, and loyalty display are represented consistently.
  • Normalized semantic parity fixtures compare content rather than only selected labels or item names.
  • Existing financial values, timezone behavior, locale behavior, and intentional layout or transport differences remain unchanged.

Keep this as a semantic-parity-only change. Do not alter financial policy or amounts, locale bootstrap or translation quality, timezone behavior, country-pack templates, currency precision, printer capability architecture, raster output, broad routing, or unrelated UI. Start from the current FloCafe default branch after merged PR #619. Phase 5A country-pack charge-row parity remains separately deferred until its output-contract compatibility decision is settled. Use the full no-mistakes delivery path; after this phase lands, continue only with the next planned phase and preserve the one-worker-at-a-time sequence.

What Changed

  • Unified KOT served/ready filtering and aligned order, table, customer, add-on quantity, and special-instruction rendering across backend, WebUSB, and browser paths.
  • Added compact WebUSB receipt add-on and instruction rendering, plus consistent loyalty earned, redeemed, and balance display across receipt surfaces.
  • Expanded normalized semantic parity fixtures and regression coverage for cross-renderer content parity.

Risk Assessment

✅ Low: The change is bounded to semantic print-content normalization and read-side hydration, with no additional source-verifiable defects found.

Testing

Installed locked dependencies temporarily, ran the focused print parity, KOT regression, document, bills API, and tax hydration tests successfully, and captured direct rendered output plus browser HTML evidence. Browser screenshot capture was unavailable because no browser connection was exposed. Linters and the full repository suite were not run per the targeted-test boundary.

Evidence: Direct print surfaces
PHASE 5 DIRECT PRINT SURFACES

COMPACT WEBUSB RECEIPT
               .Phase 5 Cafe
Invoice #: PHASE5-INV- 3/9/2026 4:00:00 pm
Table: T7
Customer: Asha Kumar
Latte                              ?290.00
+ Oat milk x2                     ?80.00
Note: Less sugar
TOTAL                              ?290.00
Cash                               ?290.00
                Thank you!
                   Powered by FloPOS
                   https://flopos.com

BACKEND THERMAL KOT
KITCHEN ORDER TICKET
Station: Main Kitchen
Order #PHASE5-KOT-001
Table: T7
Type: Dine in
Customer: Asha Kumar
Time: 10:30:00 AM
==========================================
1x  Pending latte
  + Oat milk x3
  >> Less sugar
==========================================

WEBUSB KOT
 .!KITCHEN ORDER TICKET!
Station: Main Kitchen
Order #PHASE5-KOT-001
Table: T7
Type: Dine in
Customer: Asha Kumar
Time: 10:30 AM
1x Pending latte
+ Oat milk x3
>> Less sugar
               --- END ---

BROWSER KOT SEMANTIC CONTENT
KITCHEN ORDER TICKET Station: Main Kitchen Order #PHASE5-KOT-001 Table: T7 Type: Dine in Customer: Asha Kumar Time: 10:30 AM 1x Pending latte + Oat milk x3 >>>> Less sugar --- END ---
Evidence: Browser KOT HTML

    <div class="kot-container" dir="ltr" style="text-align:start;padding:4px;font-family:'Courier New',monospace;font-size:10px;">
      <h2 style="margin:0 0 4px 0;font-size:14px;text-align:center;">KITCHEN ORDER TICKET</h2>
      <p style="margin:2px 0;">Station: Main Kitchen</p>
      <p style="margin:2px 0;font-weight:bold;">Order #PHASE5-KOT-001</p>
      <p style="margin:2px 0;">Table: T7</p>
      <p style="margin:2px 0;">Type: Dine in</p>
      <p style="margin:2px 0;">Customer: Asha Kumar</p>
      <p style="margin:2px 0;">Time: 10:30 AM</p>
      <hr style="border:1px dashed #000;margin:4px 0;">
      
        <div style="margin:4px 0;">
          <div style="font-weight:bold;">1x Pending latte</div>
          <div style="padding-inline-start:1em;">+ Oat milk x3</div>
          <div style="padding-inline-start:1em;font-style:italic;">&gt;&gt; Less sugar</div>
        </div>
      
      <hr style="border:1px dashed #000;margin:4px 0;">
      <p style="margin:2px 0;text-align:center;">--- END ---</p>
    </div>
  
Evidence: Print parity results

> [email protected] test:print-parity
> ts-node --transpile-only -P tests/tsconfig.json tests/print-parity.test.ts


▶ Backend classic @ 32 cols
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ Backend classic @ 32 cols — reprint
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ Backend classic @ 42 cols
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ Backend classic @ 42 cols — reprint
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ Backend classic @ 48 cols
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ Backend classic @ 48 cols — reprint
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ Backend compact @ 32 cols
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ Backend compact @ 32 cols — reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ Backend compact @ 42 cols
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ Backend compact @ 42 cols — reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ Backend compact @ 48 cols
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ Backend compact @ 48 cols — reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ WebUSB classic @ 58mm

▶ WebUSB classic @ 80mm

▶ WebUSB compact @ 58mm

▶ WebUSB compact @ 80mm

▶ WebUSB reprint banner

▶ Add-on quantity and charge parity
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-FINANCIAL-PARITY bill: INV-FINANCIAL-PARITY
[Printer] formatReceipt - items count: 1 cols: 48
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-FINANCIAL-PARITY bill: INV-FINANCIAL-PARITY
[Printer] formatReceipt - items count: 1 cols: 48

▶ Classic receipt loyalty content parity
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ Browser HTML @ thermal58

▶ Browser HTML @ thermal80

▶ Browser HTML reprint banner

▶ Browser HTML uses semantic catalog labels and fallback

▶ PrintDocument vs legacy classic

▶ document/32

▶ document/32/reprint

▶ document/42

▶ document/42/reprint

▶ document/48

▶ document/48/reprint

▶ PrintDocument vs legacy compact

▶ compact-document/32
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ compact-document/32/reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 32

▶ compact-document/42
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ compact-document/42/reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ compact-document/48
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ compact-document/48/reprint
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 48

▶ PrintDocument vs legacy KOT

▶ kot-document/32

▶ kot-document/42

▶ kot-document/48

▶ Localized receipt labels end-to-end
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42
[Printer] formatReceipt - template: classic
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42
[Printer] formatReceipt - template: compact
[Printer] formatReceipt - order: ORD-PARITY-001 bill: INV-PARITY-001
[Printer] formatReceipt - items count: 3 cols: 42

▶ KOT language policy independence

▶ Merchant-template mode (golden fixture = identity)

========================================================
Parity contract: 492 assertions passed, 0 failed
Evidence: KOT regression results
Phase 3 print regressions: 8 locales covered across browser, backend thermal-safe, and WebUSB KOT paths.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • npm run test:print-parity
  • npm exec -- ts-node --transpile-only -P tests/tsconfig.json tests/phase3-print-regressions.test.ts
  • npm run test:print-document
  • npm run test:bills-print-api
  • npm run test:tax-components
  • Direct production-renderer harness for compact WebUSB receipt, backend KOT, WebUSB KOT, and browser KOT HTML
  • Browser availability check via agent.browsers.list()
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Comment thread tests/print-parity.test.ts Fixed
@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR aligns semantic content across backend, WebUSB, and browser receipt/KOT renderers.

  • Centralizes pending-item filtering and aligns KOT order, customer, add-on quantity, and instruction output.
  • Hydrates receipt loyalty information and missing table/customer relations.
  • Expands semantic parity tests while retaining layout-specific rendering behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
frontend/src/lib/printer/tax-components.ts The updated merge preserves the bill-scoped order while filling missing table and customer relations from the relation-complete fallback order, resolving the prior finding.
frontend/src/lib/printer/print-document.ts Receipt document construction now propagates hydrated redeemed-points and balance fields.
shared/print/document.ts Shared KOT semantics now include pending-item filtering, customer metadata, and add-on quantities.
main/printers/document-kot.ts Backend KOT rendering adopts the shared filtering and aligned metadata, quantity, and instruction conventions.
main/routes/bills.ts Bill detail endpoints now hydrate earned, redeemed, and current loyalty point values.
tests/tax-components.test.ts Focused coverage verifies that fallback relations are merged without replacing the child-scoped order payload.

Reviews (4): Last reviewed commit: "fix: hydrate receipt relations from fall..." | Re-trigger Greptile

… updated the stale KOT assertion to the consistent `>>` marker. Passed printer, print-parity, print-document, tax-components, lint, backend build, frontend typecheck, and frontend production build checks. CodeQL’s workflow run was already successful
…int-parity.test.ts by canonicalizing ampersands to an internal marker. npm run test:print-parity passed: 492 assertions, 0 failures; git diff --check passed
@khaira777
khaira777 merged commit c6e76c7 into main Sep 3, 2026
15 checks passed
@khaira777
khaira777 deleted the fm/flocafe-receipt-kot-semantic-parity-r1 branch September 3, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants