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:
@@ -34,12 +34,14 @@ afterEach(() => close());
|
||||
/** Append a signed payment with source-split flags, as the booth/pay paths do. */
|
||||
async function payment(
|
||||
amountMinor: number,
|
||||
opts: { tender?: "cash" | "card"; subscriptionSale?: boolean; subscriptionWindowCharge?: boolean } = {},
|
||||
opts: { tender?: "cash" | "card"; subscriptionSale?: boolean; subscriptionWindowCharge?: boolean; forgoneMinor?: number } = {},
|
||||
) {
|
||||
await log.append({
|
||||
type: "payment", source: "manual", identity: "T",
|
||||
payload: {
|
||||
sessionRef: "T", amountMinor, currency: "ALL", tender: opts.tender ?? "cash",
|
||||
sessionRef: "T", amountMinor, currency: "ALL",
|
||||
// A forgiven exit's $0 payment carries no tender (nothing was tendered).
|
||||
...(opts.forgoneMinor != null ? { forgoneMinor: opts.forgoneMinor } : { tender: opts.tender ?? "cash" }),
|
||||
...(opts.subscriptionSale ? { subscriptionSale: true } : {}),
|
||||
...(opts.subscriptionWindowCharge ? { subscriptionWindowCharge: true } : {}),
|
||||
},
|
||||
@@ -74,6 +76,29 @@ describe("single-open invariant", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("forgiven exits on the Z-report", () => {
|
||||
it("a $0 forgiven payment adds nothing to cash/card/drawer and is reported as its own line", async () => {
|
||||
await shift.open("alice");
|
||||
await payment(10000); // a real ticket, cash
|
||||
await payment(0, { forgoneMinor: 25000 });
|
||||
await payment(0, { forgoneMinor: 5000 });
|
||||
|
||||
const r = shift.currentReport()!;
|
||||
expect(r.cashTotalMinor).toBe(10000);
|
||||
expect(r.cardTotalMinor).toBe(0);
|
||||
expect(r.ticketTotalMinor).toBe(10000);
|
||||
expect(r.forgoneTotalMinor).toBe(30000);
|
||||
expect(r.forgoneCount).toBe(2);
|
||||
expect(r.discountTotalMinor).toBe(0); // not a merchant validation
|
||||
expect(r.expectedDrawerMinor).toBe(r.openingFloatMinor + 10000);
|
||||
|
||||
const closed = await shift.close("alice");
|
||||
expect(closed).toMatchObject({ forgoneTotalMinor: 30000, forgoneCount: 2, cashTotalMinor: 10000 });
|
||||
const hist = shift.listShifts();
|
||||
expect(hist[0]).toMatchObject({ forgoneTotalMinor: 30000, forgoneCount: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("takings split by source", () => {
|
||||
it("separates subscription sales, out-of-window charges, and transient tickets", async () => {
|
||||
await shift.open("alice");
|
||||
|
||||
Reference in New Issue
Block a user