feat(booth): payment receipt / exit voucher — transparency slip + CP852 fixes
After a completed payment the customer always gets a transparency record:
entry time, payment time, duration parked, amount + tender. One shared
ESC/POS renderer (renderReceipt + ReceiptData in @parking/devices), two
modes: VOUCHER = those figures PLUS the scannable Code128 barcode and an
emphasised walk-back-grace line, so the one slip both proves payment and
self-exits at a distant exit reader (replaced the old barcode-only voucher);
STANDALONE = detail-only, auto-printed at payment when no voucher is issued.
Figures fold from the SIGNED ledger (latest payment event); printed on the
booth printer (failover to dispenser). Best-effort: a printer fault never
blocks the exit that already happened — the modal shows a note and offers
"Reprint receipt".
Server: booth-print.ts printPaymentReceipt() + receiptFigures(); routes
POST /api/voucher (voucher) + new POST /api/receipt (standalone/reprint).
Both ESC/POS drivers gained printReceipt(). Web: BoothPayModal auto-prints
after a non-voucher payment + reprint button; api.ts printReceipt().
CP852 fixes found on a real printout: (1) uppercase Ë was mapped to 0xEB
(that's ű) — correct byte is 0xD3; (2) Intl.NumberFormat injects a NO-BREAK
SPACE (U+00A0/U+202F) that isn't in CP852 and printed as "?" — line() now
normalises it to a plain space ("1000 Lekë"); (3) grace line wrapped
mid-word — split into two short lines.
Full build green; both receipt modes render-verified; routes live.
Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -209,6 +209,30 @@ export interface TicketData {
|
||||
readonly header?: TicketHeader;
|
||||
}
|
||||
|
||||
/** A PAYMENT RECEIPT handed to the customer after a completed payment — the
|
||||
* transparency record: when they entered, when they paid, how long they stayed,
|
||||
* and how much they paid. Printed in two modes (see `voucher`):
|
||||
* - voucher mode: ALSO carries the scannable ticket-id barcode + the walk-back
|
||||
* grace window, so the same slip both proves payment AND self-exits at a
|
||||
* distant exit reader (replaces the old barcode-only voucher);
|
||||
* - standalone mode: detail-only (no barcode), printed at payment when the booth
|
||||
* is at the exit and no voucher is issued.
|
||||
* Money is integer MINOR units + an ISO-4217 currency (never a float) — the
|
||||
* driver formats it. See wiki/concepts/booth-exit-flow.md, tariff.md. */
|
||||
export interface ReceiptData {
|
||||
readonly ticketId: string;
|
||||
readonly enteredAt: string; // ISO-8601
|
||||
readonly paidAt: string; // ISO-8601
|
||||
readonly amountMinor: number;
|
||||
readonly currency: string; // ISO-4217 (e.g. "ALL")
|
||||
readonly tender: "cash" | "card";
|
||||
/** Voucher mode: print the scannable barcode + emphasise the walk-back grace. */
|
||||
readonly voucher: boolean;
|
||||
/** Minutes the customer has to reach the exit after paying (voucher mode only). */
|
||||
readonly graceExitMin?: number | null;
|
||||
readonly header?: TicketHeader;
|
||||
}
|
||||
|
||||
/** A subscription card: the customer's keepsake, printed at the booth on creation
|
||||
* (and re-printable). The driver renders the `code` as a SCANNABLE QR (the
|
||||
* subscriber scans it every entry/exit) plus the code as text + the holder/validity.
|
||||
@@ -231,6 +255,10 @@ export interface PrinterDevice extends Device {
|
||||
printReport(report: PrintReport): Promise<void>;
|
||||
/** Print a subscription card: a scannable QR of the code + holder/validity. */
|
||||
printSubscriptionCard(data: SubscriptionCardData): Promise<void>;
|
||||
/** Print a payment receipt (transparency: entry/paid/duration/amount). In
|
||||
* voucher mode it also carries the ticket-id barcode + grace window so it
|
||||
* doubles as the self-exit voucher. See ReceiptData. */
|
||||
printReceipt(data: ReceiptData): Promise<void>;
|
||||
}
|
||||
|
||||
export interface PrintReport {
|
||||
|
||||
Reference in New Issue
Block a user