> ## Documentation Index
> Fetch the complete documentation index at: https://docs.laportenard.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Printing

> Manual QA checklist for kitchen tickets, checks, fiscal receipts, and thermal printer configuration.

Manual QA checklist for the printing system. Run against a Tauri desktop build connected to a real thermal printer.

## Prerequisites

* Tauri desktop build (`npm run desktop:build`)
* At least one ESC/POS network thermal printer (e.g., Epson TM-T20III)
* Printer configured in Odoo POS config (IP address, kitchen routes)

## 1. Kitchen tickets

| #   | Scenario              | Expected                                       |
| --- | --------------------- | ---------------------------------------------- |
| 1.1 | Basic kitchen ticket  | Table, server, items with qty, timestamp, cut  |
| 1.2 | Multi-station routing | Each printer receives only its category items  |
| 1.3 | Refire ticket         | Only delta items print on refire               |
| 1.4 | Void ticket           | VOID header, item name, reason                 |
| 1.5 | Void routing          | Void ticket goes to category's station printer |
| 1.6 | Spanish characters    | Accents (ñ, é, á) render correctly             |
| 1.7 | Long item names       | Truncated with ellipsis, price aligned right   |
| 1.8 | Takeout badge         | TAKEOUT badge shown prominently                |
| 1.9 | Delivery badge        | DELIVERY badge shown prominently               |

## Reprint restrictions

Reprinting receipts and checks requires the `reprint` permission, which defaults to manager-only. Non-managers are prompted with a `ManagerOverrideModal` before the reprint executes.

| Action                 | Permission | Default access |
| ---------------------- | ---------- | -------------- |
| Reprint check          | `reprint`  | Manager only   |
| Reprint fiscal receipt | `reprint`  | Manager only   |

Reprinted documents include a **COPY** banner at the top to distinguish them from originals.

## 2. Checks (pre-payment bill)

| #   | Scenario              | Expected                                                             |
| --- | --------------------- | -------------------------------------------------------------------- |
| 2.1 | Basic check           | Company header, table, server, guests, items, subtotal, taxes, total |
| 2.2 | Check with discounts  | Discount line shown under item, total reflects discount              |
| 2.3 | Check reprint         | COPY banner at top                                                   |
| 2.4 | Takeout check         | TAKEOUT badge in header                                              |
| 2.5 | Check alias           | Check alias shown in header                                          |
| 2.6 | POS reference         | Reference number shown                                               |
| 2.7 | Voided items excluded | Voided items not shown                                               |
| 2.8 | Multiple tax lines    | ITBIS + Propina both itemized                                        |
| 2.9 | Currency formatting   | Correct symbol, decimal places, alignment                            |

## 3. Fiscal receipts

| #   | Scenario              | Expected                                                        |
| --- | --------------------- | --------------------------------------------------------------- |
| 3.1 | Basic fiscal receipt  | Company header with RNC, NCF box, items, taxes, payment section |
| 3.2 | Cash payment          | Payment method: Cash, Amount, Change                            |
| 3.3 | Card payment          | Payment method shown, no change line                            |
| 3.4 | Zero change           | Change line omitted                                             |
| 3.5 | Customer RNC          | Customer name and RNC shown                                     |
| 3.6 | NCF display           | NCF prominently displayed in box                                |
| 3.7 | Receipt reprint       | COPY banner at top                                              |
| 3.8 | Voided items excluded | Only non-voided items on receipt                                |

## 4. Adapter routing

| #   | Scenario             | Expected                        |
| --- | -------------------- | ------------------------------- |
| 4.1 | Tauri check          | Uses `printRaw` (ESC/POS bytes) |
| 4.2 | Tauri fiscal receipt | Uses `printRaw`                 |
| 4.3 | Tauri kitchen ticket | Uses `printRaw`                 |
| 4.4 | Browser dev mode     | Uses `printHtml` (HTML string)  |

## 5. Queue and retry behavior

| #   | Scenario                 | Expected                                               |
| --- | ------------------------ | ------------------------------------------------------ |
| 5.1 | Offline printer recovery | Job retries after backoff, eventually prints           |
| 5.2 | Backoff escalation       | \~5s → \~30s → fails permanently                       |
| 5.3 | Manual retry             | Job re-enters queue and prints                         |
| 5.4 | Queue persistence        | Pending jobs restored from IndexedDB after app restart |
| 5.5 | Concurrent printers      | Both jobs process in parallel                          |
| 5.6 | TCP timeout              | Fails within timeout (not hanging)                     |

## 6. Device settings

| #   | Scenario                 | Expected                                               |
| --- | ------------------------ | ------------------------------------------------------ |
| 6.1 | Override receipt printer | Subsequent receipts go to selected printer             |
| 6.2 | Override check printer   | Subsequent checks go to selected printer               |
| 6.3 | Clear override (None)    | Falls back to POS default printer                      |
| 6.4 | Stale override cleanup   | Override cleared when printer removed from Odoo config |
| 6.5 | Override persists        | Override still applied after app restart               |

## 7. Codepage / encoding

| #   | Scenario                       | Expected                                       |
| --- | ------------------------------ | ---------------------------------------------- |
| 7.1 | UTF-8 printer (TM-T20III)      | Spanish chars (ñ, é, á, ¿, ¡) render correctly |
| 7.2 | CP437 fallback (older printer) | Spanish chars render via CP437 mapping         |
| 7.3 | Mixed ASCII + accented         | All characters correct                         |

## 8. Edge cases

| #   | Scenario              | Expected                        |
| --- | --------------------- | ------------------------------- |
| 8.1 | Empty order           | No print job created            |
| 8.2 | Printing disabled     | No print jobs enqueued          |
| 8.3 | No printer configured | Warning logged, no crash        |
| 8.4 | 20+ item order        | Prints correctly, no truncation |
| 8.5 | Cash drawer enabled   | Drawer opens after print        |

## Automated test coverage

| Module                              | Tests  |
| ----------------------------------- | ------ |
| `escpos.ts` (ESC/POS builder)       | 17     |
| `printQueue.ts` (queue)             | 9      |
| `printService.ts` (service)         | 17     |
| `models.ts` (domain)                | 13     |
| `checkEscpos.ts` (template)         | 10     |
| `fiscalReceiptEscpos.ts` (template) | 7      |
| `fiscalReceiptTemplate.ts` (HTML)   | 9      |
| **Total**                           | **82** |
