feat(subs): scannable out-of-window slip + two-step booth flow
The advisory out-of-window slip for a subscriber had two problems:
1. Faulty character codes. It rendered via the generic text printReport,
which has no CP852 mapping for the em dash, ellipsis, or warning sign in
the composed strings — so they printed as "?" ("PARKIM ? JASHTE ORARIT").
Added ASCII transliterations for that typographic punctuation in the
ESC/POS encoder (— → -, ⚠ → !, … → ..., curly quotes/bullet), so they
degrade to a readable glyph instead of "?".
2. Not scannable. The slip printed only "Nr: SUBSESS-…" as plain text, so
the operator had to hand-key it. Gave the notice its own render function
(renderWindowChargeNotice) + a printWindowChargeNotice device method that
prints the occurrence id as a Code128 AND a QR — the same scan path as a
transient ticket, so the operator scans it straight into the booth pay
modal, which then quotes the combined window charge. Implemented on both
the rongta and cashino drivers.
Also fixed the booth pay modal: "Open barrier" no longer shows by default
for a subscriber. A prepaid subscriber with nothing owed sees only a small
"assist open" reveal (the audited manual open for a faulty reader / lost
card stays available, just not the default). A subscriber owing an
out-of-window charge is now two steps — take payment first, then "Open
barrier" appears — instead of an always-on open button.
Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { eq, ledgerEvents, siteConfig, type Db } from "@parking/db";
|
||||
import {
|
||||
formatStampSq,
|
||||
printWithFailover,
|
||||
registry,
|
||||
type PrinterDevice,
|
||||
@@ -166,26 +165,19 @@ export async function printSubscriptionCard(
|
||||
*/
|
||||
export async function printWindowChargeNotice(
|
||||
db: Db,
|
||||
notice: { occurrenceId: string; holderName?: string | null; at: string; windowOpensMin?: number; edge: "entry" | "exit" },
|
||||
notice: { occurrenceId: string; holderName?: string | null; at: string; windowOpensMin?: number | null; edge: "entry" | "exit" },
|
||||
logger: FastifyBaseLogger,
|
||||
): Promise<string> {
|
||||
const printers = loadPrinters(db);
|
||||
const hhmm = (m?: number) =>
|
||||
m == null ? "" : `${String(Math.floor(m / 60)).padStart(2, "0")}:${String(m % 60).padStart(2, "0")}`;
|
||||
const lines = [
|
||||
`Abonent: ${notice.holderName || "-"}`,
|
||||
`${notice.edge === "entry" ? "Hyrje" : "Dalje"}: ${formatStampSq(notice.at)}`,
|
||||
notice.edge === "entry"
|
||||
? `Ka hyrë jashtë orarit${notice.windowOpensMin != null ? ` (orari hap ${hhmm(notice.windowOpensMin)})` : ""}`
|
||||
: "Ka dalë jashtë orarit",
|
||||
"",
|
||||
"⚠ Detyrim do të llogaritet në dalje",
|
||||
" (paguhet në kabinë para se të dilni)",
|
||||
"",
|
||||
`Nr: ${notice.occurrenceId}`,
|
||||
];
|
||||
const printedBy = await printWithFailover(printers, "booth-receipt", (d: PrinterDevice) =>
|
||||
d.printReport({ title: "PARKIM — JASHTË ORARIT", lines }),
|
||||
d.printWindowChargeNotice({
|
||||
occurrenceId: notice.occurrenceId,
|
||||
holderName: notice.holderName ?? null,
|
||||
at: notice.at,
|
||||
edge: notice.edge,
|
||||
windowOpensMin: notice.windowOpensMin ?? null,
|
||||
header: ticketHeader(db),
|
||||
}),
|
||||
);
|
||||
logger.info(`out-of-window notice printed for ${notice.occurrenceId} on ${printedBy}`);
|
||||
return printedBy;
|
||||
|
||||
Reference in New Issue
Block a user