Skip to content

fix: remediate KOT and tax-bill printing regressions - #615

Merged
khaira777 merged 20 commits into
mainfrom
fm/flocafe-pr560-kot-tax-bill-regressions-r1
Sep 3, 2026
Merged

khaira777 merged 20 commits into
mainfrom
fm/flocafe-pr560-kot-tax-bill-regressions-r1

Conversation

@khaira777

@khaira777 khaira777 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Implement and ship the FloCafe Phase 3 remediation for the PR #560 KOT and tax-bill regressions. Preserve KOT order metadata, filtering, visibility, and localized order types across browser, backend thermal-safe, and WebUSB paths for en, es, de, tr, fil, fr, pt, and fa. Preserve tax-bill localized headers and raw dates while refusing unsupported amount-bearing rows before thermal transport, with no partial financial receipts. Keep this scope narrow: do not alter service charges, country packs, timezone architecture, currency precision, raster support, printer capability architecture, or unrelated UI. Captain decisions and constraints are part of the intent: generic non-shaping thermal KOT order types retain an explicit ASCII-safe fallback; dynamic non-ASCII KOT station, table, customer, and order identifiers must remain visible with explicit ASCII [UNSUPPORTED] placeholders rather than being silently omitted; synthetic print-test hardware must use the local encoder and explicit Kitchen labeling so it cannot print database order 1; broader automatic cross-transport station routing is reverted to the minimal station fix; browser/system receipts retain active UI-language behavior. This is a follow-up on PR #615 after its branch was updated to current main: preserve all existing pipeline commits, address the Greptile metadata finding, use the supported no-mistakes rebase/sync flow for the current PR, and do not hand-rebase, force-push, discard history, or merge until validation and review requirements are satisfied. After this PR is merged, pause before starting any other work.

What Changed

  • Restored localized KOT metadata and order-type labels, pending-item filtering, and station-aware behavior across browser, backend thermal, and WebUSB printing paths.
  • Added ASCII-safe KOT metadata fallbacks and tax-bill safeguards that preserve localized/raw dates and headers while refusing unsupported amount-bearing rows before thermal transport.
  • Added Phase 3 regression coverage for eight locales and updated printing documentation.

Risk Assessment

🚨 High: Two changed paths contradict explicit acceptance criteria and require human-approved behavior decisions before merge.

Testing

Installed locked dependencies temporarily, exercised KOT behavior across all eight locales and browser/backend/WebUSB paths, validated tax-bill localization and financial refusal before transport, checked printer/routing/API/document contracts, captured and visually inspected rendered receipt artifacts, then removed disposable node_modules. All targeted checks passed; no linters or full-suite tests were run.

  • Evidence: Persian RTL receipt (local file: ~/.no-mistakes/evidence/01M1JHBKKADANRVMFZVVX1BFF0/browser-receipts/01_persian_receipt_rial_persian_digits.png)
  • Evidence: Persian tax receipt (local file: ~/.no-mistakes/evidence/01M1JHBKKADANRVMFZVVX1BFF0/browser-receipts/04_persian_receipt_reprint_tax_persian.png)
Evidence: Rendered receipt HTML
<!DOCTYPE html>
<html lang="fa-IR" dir="rtl">
<head>
  <meta charset="utf-8">
  <title>رسید # BILL-IR-0089</title>
  <style>
    
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: -apple-system, 'Segoe UI', Tahoma, 'Noto Naskh Arabic', 'Helvetica Neue', Arial, sans-serif; font-size: 12px; line-height: 1.4; color: #333; }
    .bill-container { max-width: 100%; margin: 0 auto; }
    .reprint-banner { text-align: center; font-size: 22px; font-weight: bold; letter-spacing: 2px; color: #c00; border: 3px solid #c00; padding: 6px; margin-bottom: 15px; }
    .online-order-banner { text-align: center; font-size: 18px; font-weight: bold; letter-spacing: 1px; border: 2px solid #333; padding: 6px; margin-bottom: 15px; }
    .online-order-banner .online-order-detail { font-size: 13px; font-weight: normal; letter-spacing: normal; margin-top: 2px; }
    .header { text-align: center; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #ccc; }
    .header h1 { font-size: 24px; margin-bottom: 5px; }
    .bill-details { margin-bottom: 15px; }
    .bill-details table { width: 100%; }
    .items-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
    .items-table th, .items-table td { padding: 8px; border-bottom: 1px solid #eee; text-align: start; }
    .items-table th { background: #f5f5f5; font-weight: bold; }
    .tax-table, .payments-table { width: 50%; margin-inline-start: 50%; border-collapse: collapse; margin-bottom: 15px; }
    .tax-table th, .tax-table td, .payments-table th, .payments-table td { padding: 6px 8px; }
    .tax-table th, .payments-table th { background: #f9f9f9; text-align: start; }
    .totals-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
    .totals-table td { padding: 6px 8px; }
    .total-row { border-top: 2px solid #333; font-size: 16px; }
    .footer { text-align: center; margin-top: 30px; padding-top: 15px; border-top: 1px solid #ccc; }
    .powered-by { font-size: 10px; margin-top: 8px; color: #555; }
    .text-end { text-align: end !important; }
    .num { unicode-bidi: isolate; white-space: nowrap; }
    .ltr { direction: ltr; unicode-bidi: isolate; }
    .text-muted { color: #666; }
    .text-italic { font-style: italic; color: #888; }
  
        .bill-container { padding: 10px; max-width: 80mm; font-size: 11px; }
        .header h1 { font-size: 16px; }
      
    @media print {
      .no-print { display: none !important; }
      body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    }
  </style>
</head>
<body>
  <div class="bill-container">
    
    
    <!-- Header -->
    <div class="header">
      <h1>کافه کتاب تهران (Tehran Book Cafe)</h1>
      <p>تهران، خیابان انقلاب، پلاک ۱۲</p>
      <p>تلفن: <span class="ltr" dir="ltr">+98 21 6644 1234</span></p>
      <p>کد اقتصادی: <span class="ltr" dir="ltr">411123456789</span></p>
    </div>

    <!-- Bill Details -->
    <div class="bill-details">
      <table>
        <tr>
          <td><strong>رسید #</strong> <span class="ltr" dir="ltr">BILL-IR-0089</span></td>
          <td class="text-end"><strong>تاریخ</strong> ۲۶ مرداد ۱۴۰۵، ۱۸:۰۰</td>
        </tr>
        <tr><td><strong>میز</strong> میز ۱۲ (Table 12)</td><td></td></tr>
        <tr><td><strong>مشتری</strong> رضا حسینی (Reza Hosseini)</td><td></td></tr>
        <tr><td><strong>شماره مشتری</strong> <span class="ltr" dir="ltr">+98 912 345 6789</span></td><td></td></tr>
      </table>
    </div>

    <!-- Items Table -->
    <table class="items-table">
      <thead>
        <tr>
          <th>اقلام</th>
          <th class="text-end">تعداد</th>
          <th class="text-end">نرخ</th>
          <th class="text-end">مبلغ</th>
        </tr>
      </thead>
      <tbody>
        
          <tr>
            <td>
              چای زعفرانی (Saffron Tea)
              <br><small class="text-muted">+ هل اضافه</small>
              <br><small class="text-italic">کم شیرین</small>
            </td>
            <td class="text-end num">۲</td>
            <td class="text-end num">‎ریال ۳۰۰٬۰۰۰</td>
            <td class="text-end num">‎ریال ۶۶۰٬۰۰۰</td>
          </tr>
        
          <tr>
            <td>
              باقلوا یزدی (Baklava)
              
              
            </td>
            <td class="text-end num">۱</td>
            <td class="text-end num">‎ریال ۳۰۰٬۰۰۰</td>
            <td class="text-end num">‎ریال ۳۳۰٬۰۰۰</td>
          </tr>
        
      </tbody>
    </table>

    <!-- Tax Breakdown -->
    
    <table class="tax-table">
      <thead>
        <tr><th colspan="2">جزئیات مالیات</th></tr>
      </thead>
      <tbody>
        
          <tr><td>ارزش افزوده (VAT) @10%</td><td class="text-end num">‎ریال ۹۰٬۰۰۰</td></tr>
        
      </tbody>
    </table>
    

    <!-- Totals -->
    <table class="totals-table">
      
      <tr><td>جمع جزء</td><td class="text-end num">‎ریال ۹۰۰٬۰۰۰</td></tr>
      
      
      
      
      
      <tr class="total-row"><td><strong>جمع کل</strong></td><td class="text-end num"><strong>‎ریال ۹۹۰٬۰۰۰</strong></td></tr>
      
    </table>

    <!-- Payments -->
    
    <table class="payments-table">
      <thead>
        <tr><th colspan="2">پرداخت‌ها</th></tr>
      </thead>
      <tbody>
        
          <tr><td>کارت</td><td class="text-end num">‎ریال ۹۹۰٬۰۰۰</td></tr>
        
      </tbody>
    </table>
    

    <!-- Footer -->
    <div class="footer">
      <p>از بازدید شما سپاسگزاریم!</p>
      <p>مالیات در صورت اعمال، شامل شده است</p>
      <p class="powered-by">Powered by FloPOS<br>https://flopos.com</p>
    </div>
  </div>

  <div class="no-print" style="text-align:center;margin-top:20px;">
    <button onclick="window.print()" style="padding:10px 20px;font-size:16px;cursor:pointer;">چاپ رسید</button>
  </div>
</body>
</html>
  

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 errors
  • 🚨 main/printers/document-kot.ts:126 - With arabicShaping enabled, unsupported non-Arabic metadata is not replaced. For example, station Café remains Station: Café, then buildEscPos rejects the line and emits no [UNSUPPORTED] placeholder. The frontend helper has the same issue. Shaping should allow only supported Arabic-only lines; other unsupported metadata must retain visibility via the ASCII placeholder.
  • ⚠️ frontend/src/hooks/usePrinter.ts:395 - A normal POS call without an explicit station, such as printKot(order, { items: order.items }), gets Kitchen in browser output but no station line over WebUSB: the browser branch defaults at line 395 while the WebUSB branch forwards only opts?.stationName at line 370. Decide whether the minimal station fix should apply the same fallback to both transports.

🔧 Fix: Fix shaped KOT metadata placeholders; focused test unavailable
2 errors still open:

  • 🚨 frontend/src/hooks/usePrinter.ts:135 - usePrinter.ts:135 and the tax-browser fallback at line 272 pass the fixed receipt policy to printWebBill, so browser receipts can ignore the active UI language. This contradicts the required criterion that browser/system receipts retain active UI-language behavior.
  • 🚨 frontend/src/app/(dashboard)/print-test/page.tsx:95 - The synthetic KOT test still calls the general printKot path. With hardware configured, it posts testOrder.id (hardcoded to 1) to the backend, which can print real database order 1. This contradicts the requirement that synthetic print-test hardware use the local encoder and explicit Kitchen labeling.
✅ **Test** - passed

✅ No issues found.

  • npm run test:print-labels
  • npm run test:print-parity
  • npm run test:bills-print-api
  • npm run test:issue-134-routing
  • npm run test:printer
  • npm run test:browser-receipts
  • npm run test:receipt-printing
  • npm run test:print-document
  • Visual inspection of Persian receipt PNG evidence
  • git diff --check and final git status --short --branch
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR localizes KOT order types and tax-bill output while preserving completed-item filtering and refusing unsupported financial rows before thermal transport.

  • Adds localized KOT labels and ASCII-safe metadata fallbacks across backend, browser, and WebUSB printing.
  • Filters ready and served items before KOT dispatch.
  • Applies localized tax-bill dates and preflights amount-bearing rows for unsupported printer text.
  • Extends cross-locale and cross-transport regression coverage and updates printing documentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
main/printers/document-kot.ts Filters completed KOT items and renders localized, capability-safe header metadata without leaving the previously reported omission reachable.
frontend/src/lib/printer/kot-encoder.ts Localizes WebUSB KOT order types and preserves unsupported dynamic metadata with an ASCII-safe placeholder.
frontend/src/lib/printer/kot-web-print.ts Adds escaped station metadata and localized order types to browser KOT output.
frontend/src/lib/printer/tax-bill-encoder.ts Localizes raw dates and preflights complete amount-bearing rows so unsupported financial text triggers refusal before printing.
frontend/src/hooks/usePrinter.ts Propagates resolved languages, KOT item subsets, and station metadata consistently across print transports.
main/routes/printers.ts Filters completed items before explicit-station or automatically routed backend KOT dispatch.
shared/print/document.ts Resolves localized KOT order-type concepts while retaining the raw code for thermal fallback.
tests/phase3-print-regressions.test.ts Adds focused regression coverage for localization, filtering, metadata fallbacks, date handling, and financial-row refusal.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Print request] --> B{Document type}
  B -->|KOT| C[Resolve KOT language]
  C --> D[Exclude ready and served items]
  D --> E{Transport}
  E -->|Backend ESC/POS| F[Render localized headers]
  E -->|WebUSB| G[Encode localized ticket]
  E -->|Browser| H[Generate localized HTML]
  F --> I[Use ASCII-safe metadata placeholder when required]
  G --> I
  B -->|Tax bill| J[Resolve receipt language]
  J --> K[Localize raw date with safe fallback]
  K --> L[Preflight complete financial rows]
  L --> M{Unsupported financial text?}
  M -->|Yes| N[Refuse before transport]
  M -->|No| O[Send receipt]
Loading

Reviews (4): Last reviewed commit: "no-mistakes(document): Clarified KOT the..." | Re-trigger Greptile

Comment thread main/printers/document-kot.ts Resolved
Comment thread main/printers/document-kot.ts Resolved
@khaira777 khaira777 changed the title fix: localize KOT output and harden tax-bill safety fix: remediate KOT and tax-bill printing regressions Sep 3, 2026
@khaira777
khaira777 merged commit 0171ba8 into main Sep 3, 2026
15 checks passed
@khaira777
khaira777 deleted the fm/flocafe-pr560-kot-tax-bill-regressions-r1 branch September 3, 2026 02:57
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.

1 participant