feat(exit): forgiven exit — open the exit barrier with no payment (barrier:create)
Build & push images / images (push) Successful in 3m23s
Build & push images / images (push) Successful in 3m23s
The owner (or any role the owner grants barrier:create) lets a car out for free.
Exit side only. Every use is signed, attributed, photographed and on the operator's
Z-report; the shift's cash/card/drawer are untouched by construction.
- shared: resource 'barrier' + permission 'barrier:create'; reason codes
exit.forgiven / exit.forgiven.noSession; LedgerPayload.forgoneMinor.
- pay-station: forgive() signs a $0 payment carrying the quoted fee as forgoneMinor
(no tender), refuses a ticket with module charge lines (a wash is not forgiven).
- exit-flow: reopenBarrier(..., { forgiven }) bypasses the walk-back check and stamps
the forgiven reason on the anomaly + vehicle_exit; forgiveExitNoSession() for a car
with no ticket (anomaly under forgiven:<id> + exit snapshot + pulse). Relay driving
shared in #pulseExit.
- route POST /api/barrier/forgive { identity?, note? }: barrier:create + open shift;
the reason is optional (an empty note is signed as '(no reason given)').
- shift-service: forgoneTotalMinor + forgoneCount on the report/summary/signed
shift_z_report (only when > 0), print line 'Dalje të falura (N)'.
- web: 'Forgive & open' in the pay/exit modal for an open transient that owes money;
'Forgive & open exit' on the booth header for the no-ticket case; forgone line on
the X-report, close confirm and history; en/sq. Prints nothing.
- tests: exit-flow, pay-station, shift-service, HTTP route (403 without the
permission, 409 no shift, empty note accepted, ledger sequence, report figures).
- wiki: decisions/forgiven-exit.md (decision + as-built), booth-exit-flow, shift,
index, log.
This commit is contained in:
@@ -60,6 +60,7 @@ export async function payRoutes(
|
||||
const guard = requirePermission("payment:create");
|
||||
const readGuard = requirePermission("session:read");
|
||||
const voidGuard = requirePermission("event:void");
|
||||
const forgiveGuard = requirePermission("barrier:create");
|
||||
|
||||
// Money-path gate: a shift must be open site-wide before any payment/exit/voucher/
|
||||
// re-open is processed, so every taking is attributed to a shift (one operator's
|
||||
@@ -144,6 +145,37 @@ export async function payRoutes(
|
||||
},
|
||||
);
|
||||
|
||||
// FORGIVEN exit (wiki/decisions/forgiven-exit.md): an operator holding barrier:create
|
||||
// lets a car out with NO money. With a ticket: PayStation.forgive signs a $0 payment
|
||||
// carrying the forgone fee (never in cash/card), then the human-intervention re-open
|
||||
// signs the exit + pulses. Without a ticket: anomaly + snapshot + pulse. A free-text
|
||||
// reason is OPTIONAL (user, 2026-10-09 — the signature + snapshot + Z-report line are
|
||||
// the accountability); an open shift is required so it lands on someone's Z-report.
|
||||
// Prints nothing.
|
||||
app.post<{ Body: { identity?: string; note?: string } }>(
|
||||
"/api/barrier/forgive",
|
||||
{ preHandler: [forgiveGuard, requireShift] },
|
||||
async (req, reply) => {
|
||||
const note = (req.body?.note ?? "").trim();
|
||||
const identity = (req.body?.identity ?? "").trim();
|
||||
const operator = req.user?.username ?? "?";
|
||||
if (!identity) {
|
||||
const r = await exitFlow.forgiveExitNoSession(operator, note);
|
||||
if (!r.ok) return reply.code(409).send({ error: r.reason });
|
||||
return reply.code(200).send(r);
|
||||
}
|
||||
try {
|
||||
const f = await payStation.forgive(identity, { operator, note });
|
||||
if (!f.ok) return reply.code(409).send({ error: f.reason });
|
||||
const r = await exitFlow.reopenBarrier(identity, operator, { forgiven: { note, forgoneMinor: f.forgoneMinor, currency: f.currency } });
|
||||
if (!r.ok) return reply.code(409).send({ error: r.reason });
|
||||
return reply.code(200).send({ ...r, forgoneMinor: f.forgoneMinor, currency: f.currency });
|
||||
} catch (err) {
|
||||
return mapError(reply, err);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Cancel (void) a wrongly-printed transient ticket. Appends a SIGNED `void` event
|
||||
// referencing the entry, with the operator + a REQUIRED reason — the entry itself is
|
||||
// never edited/deleted (append-only). The session projection folds the void to CLOSED,
|
||||
|
||||
Reference in New Issue
Block a user