From 82e5833e4e2b20199202d57498f6b5c6f0682a12 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Fri, 9 Oct 2026 08:37:44 +0200 Subject: [PATCH] =?UTF-8?q?feat(exit):=20manual-exit=20dialog=20+=20wordin?= =?UTF-8?q?g=20=E2=80=94=20styled=20modal=20replaces=20window.prompt;=20co?= =?UTF-8?q?py=20says=20'manual=20exit'=20/=20'dalje=20manuale'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BoothScreen: the no-ticket open uses the app's Modal (explainer, optional reason, red confirm; Enter confirms, Escape/Cancel abort) instead of a browser prompt. - en/sq: forgive/forgiven/forgone wording dropped from every user-facing string (buttons, dialog, results, live-feed reasons, shift figures); Albanian edited by the user, English aligned. Printed Z line is 'Dalje manuale (N)'. The signed English fallback sentences follow. Identifiers (exit.forgiven, forgoneMinor, barrier:create) unchanged. - wiki: forgiven-exit §Wording, shift, log. --- apps/server/src/exit-flow.test.ts | 4 +-- apps/server/src/shift-service.ts | 2 +- apps/web/src/BoothScreen.tsx | 49 ++++++++++++++++++++++++++----- apps/web/src/lib/i18n/en.ts | 31 +++++++++++-------- apps/web/src/lib/i18n/sq.ts | 31 +++++++++++-------- packages/shared/src/index.ts | 4 +-- wiki/concepts/shift.md | 2 +- wiki/decisions/forgiven-exit.md | 12 ++++++-- wiki/log.md | 6 ++++ 9 files changed, 99 insertions(+), 42 deletions(-) diff --git a/apps/server/src/exit-flow.test.ts b/apps/server/src/exit-flow.test.ts index e190a67..005a53e 100644 --- a/apps/server/src/exit-flow.test.ts +++ b/apps/server/src/exit-flow.test.ts @@ -131,8 +131,8 @@ describe("forgiven exit (wiki/decisions/forgiven-exit.md)", () => { expect(r.ok).toBe(true); expect(exitsSigned("T1")).toHaveLength(1); expect(exitsSigned("T1")[0]!.payload).toMatchObject({ reasonCode: "exit.forgiven" }); - expect(anomalies("forgiven exit by owner")).toHaveLength(1); - expect(anomalies("forgiven exit by owner")[0]!.payload).toMatchObject({ forgiven: true, forgoneMinor: 20000, operator: "owner" }); + expect(anomalies("manual exit by owner")).toHaveLength(1); + expect(anomalies("manual exit by owner")[0]!.payload).toMatchObject({ forgiven: true, forgoneMinor: 20000, operator: "owner" }); // The plain unpaid re-open path is still refused for the NEXT unpaid car. await enter("T2", minutesAgo(90)); expect((await exit.reopenBarrier("T2", "owner")).ok).toBe(false); diff --git a/apps/server/src/shift-service.ts b/apps/server/src/shift-service.ts index fe5b20a..56497aa 100644 --- a/apps/server/src/shift-service.ts +++ b/apps/server/src/shift-service.ts @@ -832,7 +832,7 @@ export class ShiftService { // (older slips stay byte-identical). The takings above are already NET of it. ...(r.discountTotalMinor > 0 ? [`Zbritje (validime): ${money(r.discountTotalMinor)} ${cur}`] : []), // Forgiven exits — fees waived by an operator; $0 payments, NOT in the takings. - ...(r.forgoneCount > 0 ? [`Dalje të falura (${r.forgoneCount}): ${money(r.forgoneTotalMinor)} ${cur}`] : []), + ...(r.forgoneCount > 0 ? [`Dalje manuale (${r.forgoneCount}): ${money(r.forgoneTotalMinor)} ${cur}`] : []), "", "-- Arka --", `Gjëndje fillestare: ${money(r.openingFloatMinor)} ${cur}`, diff --git a/apps/web/src/BoothScreen.tsx b/apps/web/src/BoothScreen.tsx index 84c067a..cb41237 100644 --- a/apps/web/src/BoothScreen.tsx +++ b/apps/web/src/BoothScreen.tsx @@ -7,6 +7,7 @@ import { qk } from "./lib/query.js"; import { useLiveStore } from "./lib/live-store.js"; import { useShift } from "./lib/use-shift.js"; import { useScanner } from "./lib/use-scanner.js"; +import { Modal } from "./ui/Modal.js"; import { Panel } from "./ui/Panel.js"; import { StatusDot } from "./ui/StatusDot.js"; import { BoothPayModal } from "./BoothPayModal.js"; @@ -217,25 +218,26 @@ function LaneIndicators() { } // FORGIVEN exit for a car with NO ticket (barrier:create; wiki/decisions/forgiven-exit.md): - // signed anomaly + exit snapshot + pulse, no money, nothing printed. Reason optional - // (Cancel in the prompt aborts; an empty answer proceeds). + // signed anomaly + exit snapshot + pulse, no money, nothing printed. A small styled + // dialog (same chrome as every other form) asks for an OPTIONAL reason, then confirms. const canForgive = can(user, "barrier:create") && shiftOpen && isMine; + const [forgiveOpen, setForgiveOpen] = useState(false); + const [forgiveNote, setForgiveNote] = useState(""); const forgive = useMutation({ mutationFn: (note: string) => forgiveExit(null, note), onSuccess: (r) => { + setForgiveOpen(false); + setForgiveNote(""); setMsg({ ok: r.opened, text: r.opened ? t("booth.forgiveExitOk") : t("booth.forgiveExitNotOpened", { reason: r.reason ?? "" }) }); void qc.invalidateQueries({ queryKey: qk.events }); setTimeout(() => setMsg(null), 5000); }, onError: (e) => { + setForgiveOpen(false); setMsg({ ok: false, text: (e as Error).message }); setTimeout(() => setMsg(null), 5000); }, }); - function onForgiveNoTicket() { - const note = window.prompt(t("booth.forgiveExitPrompt")); - if (note !== null) forgive.mutate(note.trim()); - } return (
@@ -252,7 +254,7 @@ function LaneIndicators() { {canForgive && ( )} + {/* Forgiven-exit dialog (no ticket): what it does, an optional reason, a deliberate red + confirm. Enter in the field confirms; Escape / ✕ / Cancel abort. */} + setForgiveOpen(false)} title={t("booth.forgiveDialogTitle")} width="max-w-md"> +
{ + e.preventDefault(); + if (!forgive.isPending) forgive.mutate(forgiveNote.trim()); + }} + className="flex flex-col gap-3" + > +
+ {t("booth.forgiveDialogBody")} +
+ +
+ + +
+
+
{msg && ( {msg.text} )} diff --git a/apps/web/src/lib/i18n/en.ts b/apps/web/src/lib/i18n/en.ts index a90c877..032cc22 100644 --- a/apps/web/src/lib/i18n/en.ts +++ b/apps/web/src/lib/i18n/en.ts @@ -317,11 +317,16 @@ export const en: Catalog = { issueEntryTitle: "Issue an entry ticket & open the barrier (physical button broken)", issueEntryConfirm: "A vehicle is at the entry. Issue an entry ticket and open the barrier?", issueEntryOk: "Entry ticket {{ticket}} issued.", - forgiveExit: "Forgive & open exit", + forgiveExit: "Open exit manually", forgiveExitTitle: "Open the exit barrier for a car with NO ticket — no money, signed and flagged", - forgiveExitPrompt: "Reason for opening the exit with no ticket (optional — OK to leave empty):", - forgiveExitOk: "Exit opened — forgiven, no payment.", + forgiveExitOk: "Exit opened manually, no payment.", forgiveExitNotOpened: "Recorded, but the barrier did not open: {{reason}}", + forgiveDialogTitle: "Manual exit", + forgiveDialogBody: "Opens the EXIT barrier for a car with no ticket. No money is taken and nothing is printed; the open is signed under your name with the exit camera's snapshot and shows on your shift report.", + forgiveDialogReason: "Reason (optional)", + forgiveDialogReasonPlaceholder: "e.g. came in while the barriers were up…", + forgiveDialogConfirm: "Open exit — no payment", + forgiveDialogWorking: "opening…", exitedGrace: "exited · grace", exitedGraceLeft: "exited · {{time}}", exitedGraceTitle: "Paid and exited — barrier not confirmed; waiting out the grace period.", @@ -424,8 +429,8 @@ export const en: Catalog = { "exit.open.failed": "Exit recorded, but the barrier did not open — open manually", "exit.freeGrace": "Free entry-grace (no charge)", "exit.manualOpen": "Manual barrier open (human intervention)", - "exit.forgiven": "Forgiven exit by {{operator}} — fee of {{forgone}} {{currency}} waived: {{note}}", - "exit.forgiven.noSession": "Forgiven exit by {{operator}} — no ticket / no session: {{note}}", + "exit.forgiven": "Manual exit by {{operator}} — fee of {{forgone}} {{currency}}, no payment: {{note}}", + "exit.forgiven.noSession": "Manual exit by {{operator}} — no ticket / no session: {{note}}", "exit.plateSwapSuspected": "Possible ticket swap — plate {{plate}} is already inside under ticket {{otherIdentity}}", "exit.plateSwapOverride": "Operator {{operator}} released a suspected ticket-swap exit (plate {{plate}}, also open under {{otherIdentity}})", "sub.refused.notFound": "Subscription refused — not found", @@ -998,7 +1003,7 @@ export const en: Catalog = { srcSubscriptions: "Subscriptions:", srcOnTicket: "{{module}} (on ticket):", srcSubWindow: "out-of-window", - srcForgone: "Forgiven exits ({{count}}):", + srcForgone: "Manual exits ({{count}}):", drawerSection: "— Drawer —", openingFloat: "Opening cash:", cashTaken: "Daily takings:", @@ -1047,7 +1052,7 @@ export const en: Catalog = { srcTickets: "Tickets", srcSubscriptions: "Subscriptions", srcSubWindow: "out-of-window", - srcForgone: "Forgiven exits ({{count}})", + srcForgone: "Manual exits ({{count}})", expectedDrawer: "Expected drawer", filterFrom: "From", filterTo: "To", @@ -1255,14 +1260,14 @@ export const en: Catalog = { confirmCancelTicket: "Confirm cancellation", cancelling: "cancelling…", ticketCancelled: "Ticket cancelled.", - forgiveExit: "Forgive & open", - forgiveTitle: "Forgive this exit", - forgiveHint: "Lets the car out with NO payment. The fee owed ({{amount}}) is recorded as forgone on your shift report — never as cash. A reason is optional; nothing is printed.", - forgiveReasonPlaceholder: "Reason for forgiving (optional)…", + forgiveExit: "Open manually", + forgiveTitle: "Open this exit manually", + forgiveHint: "Lets the car out with NO payment. The fee owed ({{amount}}) is recorded as a manual exit on your shift report, not as money. A reason is optional; nothing is printed.", + forgiveReasonPlaceholder: "Reason (optional)…", confirmForgive: "Confirm — open exit, no payment", forgiving: "opening…", - exitForgiven: "Exit forgiven — {{amount}} waived, barrier opened.", - exitForgivenNotOpened: "Exit forgiven — {{amount}} waived, but the barrier did not open: {{reason}}", + exitForgiven: "Manual exit — {{amount}}, barrier opened.", + exitForgivenNotOpened: "Manual exit — {{amount}}, barrier did not open: {{reason}}", noSnapshots: "no snapshots", loadingSnapshots: "loading snapshots…", snapEntry: "entry", diff --git a/apps/web/src/lib/i18n/sq.ts b/apps/web/src/lib/i18n/sq.ts index 19e2e6c..b322f24 100644 --- a/apps/web/src/lib/i18n/sq.ts +++ b/apps/web/src/lib/i18n/sq.ts @@ -319,11 +319,16 @@ export const sq = { issueEntryTitle: "Lësho një biletë hyrjeje & hap barrierën (butoni fizik i prishur)", issueEntryConfirm: "Një automjet është te hyrja. Të lëshohet një biletë hyrjeje dhe të hapet barriera?", issueEntryOk: "Bileta e hyrjes {{ticket}} u lëshua.", - forgiveExit: "Fal & hap daljen", + forgiveExit: "Hap daljen manualisht", forgiveExitTitle: "Hap barrierën e daljes për një automjet PA biletë — pa para, e nënshkruar dhe e shënuar", - forgiveExitPrompt: "Arsyeja e hapjes së daljes pa biletë (opsionale — mund të lihet bosh):", - forgiveExitOk: "Dalja u hap — e falur, pa pagesë.", + forgiveExitOk: "Dalja u hap manualisht, pa pagesë.", forgiveExitNotOpened: "U regjistrua, por barriera nuk u hap: {{reason}}", + forgiveDialogTitle: "Hapje manuale", + forgiveDialogBody: "Hap barrierën e DALJES për një automjet pa biletë. Nuk merret asnjë pagesë dhe nuk printohet asgjë; hapja nënshkruhet me emrin tënd bashkë me foton e kamerës së daljes dhe shfaqet në raportin e turnit tënd.", + forgiveDialogReason: "Arsyeja (opsionale)", + forgiveDialogReasonPlaceholder: "p.sh. hyri kur barrierat ishin të hapura…", + forgiveDialogConfirm: "Hap daljen — pa pagesë", + forgiveDialogWorking: "duke hapur…", exitedGrace: "doli · në afat", exitedGraceLeft: "doli · {{time}}", exitedGraceTitle: "Paguar dhe dalur — barriera nuk u konfirmua; po pret afatin kohor.", @@ -427,8 +432,8 @@ export const sq = { "exit.open.failed": "Dalja u regjistrua, por barriera nuk u hap — hape manualisht", "exit.freeGrace": "Periudhë pa pagesë në hyrje (pa tarifë)", "exit.manualOpen": "Hapje manuale e barrierës (ndërhyrje njerëzore)", - "exit.forgiven": "Dalje e falur nga {{operator}} — tarifa {{forgone}} {{currency}} u fal: {{note}}", - "exit.forgiven.noSession": "Dalje e falur nga {{operator}} — pa biletë / pa seancë: {{note}}", + "exit.forgiven": "Dalje manuale nga {{operator}} — tarifa {{forgone}} {{currency}}: {{note}}", + "exit.forgiven.noSession": "Dalje manuale nga {{operator}} — pa biletë / pa seancë: {{note}}", "exit.plateSwapSuspected": "Mundësi ndërrimi biletash — targa {{plate}} është tashmë brenda me biletën {{otherIdentity}}", "exit.plateSwapOverride": "Operatori {{operator}} lëshoi një dalje me dyshim ndërrimi biletash (targa {{plate}}, edhe e hapur me {{otherIdentity}})", "sub.refused.notFound": "Abonimi u refuzua — nuk u gjet", @@ -1011,7 +1016,7 @@ export const sq = { srcSubscriptions: "Abonime:", srcOnTicket: "{{module}} (në biletë):", srcSubWindow: "jashtë orarit", - srcForgone: "Dalje të falura ({{count}}):", + srcForgone: "Dalje manuale ({{count}}):", drawerSection: "— Arka —", openingFloat: "Arka fillestare:", cashTaken: "Xhiro ditore:", @@ -1060,7 +1065,7 @@ export const sq = { srcTickets: "Bileta", srcSubscriptions: "Abonime", srcSubWindow: "jashtë orarit", - srcForgone: "Dalje të falura ({{count}})", + srcForgone: "Dalje manuale ({{count}})", expectedDrawer: "Gjëndje arke", // Filter (admin only). filterFrom: "Nga", @@ -1271,14 +1276,14 @@ export const sq = { confirmCancelTicket: "Konfirmo anulimin", cancelling: "duke anuluar…", ticketCancelled: "Bileta u anulua.", - forgiveExit: "Fal & hap", - forgiveTitle: "Fal këtë dalje", - forgiveHint: "E lë automjetin të dalë PA pagesë. Shuma e detyruar ({{amount}}) regjistrohet si e falur në raportin e turnit — kurrë si para. Arsyeja është opsionale; nuk printohet asgjë.", - forgiveReasonPlaceholder: "Arsyeja e faljes (opsionale)…", + forgiveExit: "Hap Manualisht", + forgiveTitle: "Hap manualisht këtë dalje", + forgiveHint: "E lë automjetin të dalë PA pagesë. Shuma e detyruar ({{amount}}) regjistrohet si dalje manuale në raportin e turnit, jo si para. Arsyeja është opsionale; nuk printohet asgjë.", + forgiveReasonPlaceholder: "Arsyeja (opsionale)…", confirmForgive: "Konfirmo — hap daljen, pa pagesë", forgiving: "duke hapur…", - exitForgiven: "Dalja u fal — {{amount}} u fal, barriera u hap.", - exitForgivenNotOpened: "Dalja u fal — {{amount}} u fal, por barriera nuk u hap: {{reason}}", + exitForgiven: "Dalje manuale — {{amount}}, barriera u hap.", + exitForgivenNotOpened: "Dalje manuale — {{amount}}, barriera nuk u hap: {{reason}}", // snapshots noSnapshots: "asnjë foto", loadingSnapshots: "duke ngarkuar fotot…", diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 55d3de6..a8e685a 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -529,8 +529,8 @@ export const REASON_EN: Record = { "exit.open.failed": "exit recorded, but the barrier did not open — open manually", "exit.freeGrace": "free entry-grace (no charge)", "exit.manualOpen": "manual barrier open (human intervention)", - "exit.forgiven": "forgiven exit by {operator} — fee of {forgone} {currency} waived: {note}", - "exit.forgiven.noSession": "forgiven exit by {operator} — no ticket / no session: {note}", + "exit.forgiven": "manual exit by {operator} — fee of {forgone} {currency}, no payment: {note}", + "exit.forgiven.noSession": "manual exit by {operator} — no ticket / no session: {note}", "exit.plateSwapSuspected": "possible ticket swap — plate {plate} is already inside under ticket {otherIdentity}", "exit.plateSwapOverride": "operator {operator} released a suspected ticket-swap exit (plate {plate}, also open under {otherIdentity})", "sub.refused.notFound": "subscription refused — not found", diff --git a/wiki/concepts/shift.md b/wiki/concepts/shift.md index bd87ca3..7703580 100644 --- a/wiki/concepts/shift.md +++ b/wiki/concepts/shift.md @@ -120,7 +120,7 @@ waived, no tender. It adds **nothing** to cash, card, the ticket bucket or the d tender sums add 0), so the shift total is untouched by construction. The Z-report sums `forgoneMinor` into `forgoneTotalMinor` + `forgoneCount`, stamps them on the signed `shift_z_report` (only when > 0, so older payloads stay identical) and prints one line -`Dalje të falura (N): X` after the merchant-validation leakage line — a separate figure on +`Dalje manuale (N): X` after the merchant-validation leakage line — a separate figure on purpose, so the owner can tell "the bar validated it" from "the operator let it out". ### Shift history UI + permission scoping (2026-06-19) diff --git a/wiki/decisions/forgiven-exit.md b/wiki/decisions/forgiven-exit.md index 4cbf6e9..75acb9d 100644 --- a/wiki/decisions/forgiven-exit.md +++ b/wiki/decisions/forgiven-exit.md @@ -77,7 +77,7 @@ unchanged) and on the ticket being closed. role from Setup → Roles — "the owner can give permission to other operators" (user). - **`PayStation.forgive(identity, { operator, note })`** — quotes the fee as the pay flow would, signs `payment { amountMinor: 0, forgoneMinor: , operator, reasonCode: - "exit.forgiven", reason: "forgiven exit by X — fee of N CUR waived: " }` with **no + "exit.forgiven", reason: "manual exit by X — fee of N CUR, no payment: " }` with **no tender** (nothing was tendered), marks the projection paid. Refuses (409) when the quote carries module charge lines (a wash on the ticket): parking is forgiven, a wash is not. - **`ExitFlow.reopenBarrier(id, operator, { forgiven })`** — the existing human-intervention @@ -91,13 +91,19 @@ unchanged) and on the ticket being closed. gate (`409 no_shift`); the note is optional; no identity = the no-session path. - **Z-report**: `forgoneTotalMinor` + `forgoneCount` summed from `forgoneMinor` (never into cash/card; `discountTotalMinor` untouched), on the signed `shift_z_report` only when > 0, one - print line `Dalje të falura (N): X`, shown in the X-report, the close confirm and history. + print line `Dalje manuale (N): X`, shown in the X-report, the close confirm and history. - **Web**: in the pay/exit modal a red ghost "Forgive & open" for an OPEN transient that owes money (unpaid or overstay) → reason box → "Confirm — open exit, no payment"; on the booth header a "Forgive & open exit" next to the exit lane light for the no-ticket case - (`window.prompt` for the reason — Cancel aborts, empty proceeds). Both only render with + (a small styled dialog, same chrome as every other form — optional reason, red confirm). Both only render with `barrier:create` + own open shift. Live-feed reason texts in en/sq. **Nothing is printed.** - Tests: exit-flow (ticketed + no-session), pay-station (`forgive`), shift-service (totals untouched, own line, history), routes (403 without the permission, 409 no shift, 400 no note accepted, ledger sequence entry→payment→anomaly→exit, report figures). + +**Wording (user, 2026-10-09).** The user-facing words are **"manual exit" / "dalje manuale"**, +not forgive/forgiven/forgone — too much "fal, falur, falje" (user). Applies to both language +files, the printed Z-report line (`Dalje manuale (N)`) and the signed English fallback +sentences. Internal names stay (`exit.forgiven`, `forgoneMinor`, `barrier:create`) — they +are code identifiers, not copy. diff --git a/wiki/log.md b/wiki/log.md index ee2d6cd..f8b41da 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3490,3 +3490,9 @@ Pages: [[forgiven-exit]], [[booth-exit-flow]] §Forgiven exit, [[shift]] §Forgi "We don't need to force the user to write a reason." Route no longer 400s without a note; an empty note is signed as "(no reason given)"; modal confirm enabled with an empty box; booth prompt: Cancel aborts, empty proceeds; en/sq texts say optional. [[forgiven-exit]] §5 updated. + +## [2026-10-09] decision | Forgiven exit wording → "manual exit" / "dalje manuale" + +User trimmed the Albanian copy ("Too much fal, falur, falje") and asked for the same in +English: buttons, dialog, results, live-feed reasons, shift figures, the printed Z line and the +signed English fallback now say manual exit; identifiers unchanged. [[forgiven-exit]] §Wording.