Skip to content

fix(printer): preserve IR raw ESC/POS financial lines and layout bounds - #273

Merged
khaira777 merged 1 commit into
mainfrom
fix/241-ir-thermal-receipt-safety
Aug 17, 2026
Merged

khaira777 merged 1 commit into
mainfrom
fix/241-ir-thermal-receipt-safety

Conversation

@khaira777

@khaira777 khaira777 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • Normalize the Iranian Rial (ریال) symbol to IRR and enforce Latin numerals for raw ESC/POS thermal printing across backend and frontend encoders while preserving native Persian formatting for browser prints.
  • Implement dynamic column width resolution and multi-line wrapping for line items, add-ons, and financial summary rows on 58mm and 80mm ESC/POS layouts.
  • Route browser printing in usePrinter directly through printWebBill HTML generation rather than decoding ESC/POS byte buffers, and add tests for IR receipt encoding and layout constraints.

Risk Assessment

✅ Low: The changes cleanly and safely normalize the Iranian Rial currency symbol to ASCII IRR and enforce Latin numerals for ESC/POS thermal printing while preserving Persian output for browser printing, backed by comprehensive end-to-end receipt formatting tests.

Testing

Executed the full printer test suite and targeted receipt/currency validation suites covering backend thermal formatting, frontend raw ESC/POS encoders, browser HTML print generation, column constraint invariants, and unsupported character warning contracts; all 287 assertions and all 8 test suites passed with zero failures.

Evidence: Browser HTML Receipt (Persian Rial & Numerals Preserved)

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Bill #INV-IR-001</title>
  <style>
    
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: '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; }
    .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: left; }
    .items-table th { background: #f5f5f5; font-weight: bold; }
    .tax-table, .payments-table { width: 50%; margin-left: 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: left; }
    .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-right { text-align: right !important; }
    .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>Flo Cafe Tehran</h1>
      <p>Valiasr Ave, Tehran, Iran</p>
      <p>Ph: +98 21 8877 6655</p>
      <p>Economic Code: IR-987654321</p>
    </div>

    <!-- Bill Details -->
    <div class="bill-details">
      <table>
        <tr>
          <td><strong>Bill #:</strong> INV-IR-001</td>
          <td><strong>Date:</strong> ۲۵ مرداد ۱۴۰۵، ۱۹:۵۶</td>
        </tr>
        <tr><td><strong>Table:</strong> Table 4</td><td></td></tr>
        <tr><td><strong>Customer:</strong> Ali Reza</td><td></td></tr>
        <tr><td><strong>Customer No:</strong> +98 912 345 6789</td><td></td></tr>
      </table>
    </div>

    <!-- Items Table -->
    <table class="items-table">
      <thead>
        <tr>
          <th>Item</th>
          <th class="text-right">Qty</th>
          <th class="text-right">Rate</th>
          <th class="text-right">Amount</th>
        </tr>
      </thead>
      <tbody>
        
          <tr>
            <td>
              Espresso
              
              
            </td>
            <td class="text-right">2</td>
            <td class="text-right">ریال۵۰٬۰۰۰٫۰۰</td>
            <td class="text-right">ریال۱۰۰٬۰۰۰٫۰۰</td>
          </tr>
        
          <tr>
            <td>
              Saffron Tea
              
              
            </td>
            <td class="text-right">1</td>
            <td class="text-right">ریال۴۵٬۰۰۰٫۰۰</td>
            <td class="text-right">ریال۴۵٬۰۰۰٫۰۰</td>
          </tr>
        
      </tbody>
    </table>

    <!-- Tax Breakdown -->
    
    <table class="tax-table">
      <thead>
        <tr><th colspan="2">Tax Details</th></tr>
      </thead>
      <tbody>
        
          <tr><td>Tax</td><td class="text-right">ریال۱۱٬۷۰۰٫۰۰</td></tr>
        
      </tbody>
    </table>
    

    <!-- Totals -->
    <table class="totals-table">
      <tr><td>Subtotal</td><td class="text-right">ریال۱۴۵٬۰۰۰٫۰۰</td></tr>
      <tr><td>Discount</td><td class="text-right">-ریال۱۵٬۰۰۰٫۰۰</td></tr>
      <tr><td>Total Tax</td><td class="text-right">ریال۱۱٬۷۰۰٫۰۰</td></tr>
      
      
      <tr class="total-row"><td><strong>Grand Total</strong></td><td class="text-right"><strong>ریال۱۴۱٬۷۰۰٫۰۰</strong></td></tr>
    </table>

    <!-- Payments -->
    
    <table class="payments-table">
      <thead>
        <tr><th colspan="2">Payments</th></tr>
      </thead>
      <tbody>
        
          <tr><td>Cash</td><td class="text-right">ریال۱۴۱٬۷۰۰٫۰۰</td></tr>
        
      </tbody>
    </table>
    

    <!-- Footer -->
    <div class="footer">
      <p>Thank you for dining with us! / سپاس از همراهی شما</p>
      <p>Tax included where applicable</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;">Print Bill</button>
  </div>
</body>
</html>
  
- Evidence: ESC/POS Receipt Transcripts (IRR ASCII & Latin Numerals) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M06FWAEBR1CP1GKM5JMAD0Y9/escpos-receipts-ir.txt) - Evidence: Interactive HTML Preview of Rendered Thermal Receipts (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M06FWAEBR1CP1GKM5JMAD0Y9/rendered-thermal-preview.html)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • ts-node --transpile-only -P tests/tsconfig.json tests/printer.test.ts
  • npm run test:printer-api
  • npm run test:printer-width-refresh
  • npm run test:printer-migrations
  • npm run test:receipt-column-width
  • npm run test:receipt-printing
  • npm run test:bills-print-api
  • npm run test:currency
  • npm run test:issue-266-currency-symbol-print
  • End-to-end receipt rendering artifact generation for Iranian Rial (IR/IRR) across all ESC/POS thermal templates and browser HTML print paths
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@khaira777 khaira777 changed the title fix(printing): preserve IR receipt financial lines fix(printer): preserve IR receipt financial lines Aug 13, 2026
@khaira777
khaira777 force-pushed the fix/241-ir-thermal-receipt-safety branch from 683460e to 4decc37 Compare August 16, 2026 23:49
@khaira777
khaira777 marked this pull request as ready for review August 16, 2026 23:50
@khaira777
khaira777 requested a review from itsbkm as a code owner August 16, 2026 23:50
@khaira777 khaira777 changed the title fix(printer): preserve IR receipt financial lines fix(printer): preserve IR raw ESC/POS financial lines and layout bounds Aug 16, 2026
@khaira777
khaira777 merged commit eda0e03 into main Aug 17, 2026
12 checks passed
@khaira777
khaira777 deleted the fix/241-ir-thermal-receipt-safety branch August 17, 2026 00:39
khaira777 added a commit that referenced this pull request Aug 17, 2026
… capability (#355)

* feat(printers): gate Arabic thermal output behind shaping capability

Add an explicit `arabicShaping` capability flag to printer profiles and
thread it through every raw ESC/POS encoder (receipt, plugin template,
and KOT). Arabic/Persian script is now only emitted when the profile
declares shaping support; otherwise it is skipped with a precise warning
and financial lines keep their ASCII currency fallback (ریال → IRR), so
corrupted or unshaped glyphs can never reach the printer. Defaults to off
(safe) for every existing profile, matching the #273 financial-line
protection.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* no-mistakes(document): Verify printer shaping docs and fix thermal lint

---------

Co-authored-by: Codebuff <[email protected]>
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