Unifies the model: a table is ALWAYS one account; every active Order on a table number is a subaccount (named or not) — no more 'normal vs split table'. Total convergence (fixes the bug): the dashboard groups ALL active orders by tableNumber into one card; two normal orders on the same table now share one table card with two subaccounts. (POST /order already converges split too.) Batches: items sent together share a batchId + batchAt; later additions form a new batch. reconcileItems() carries id/batch/delivered for matched lines and opens one new batch for new lines. (OrderItem is embedded JSON, so its new fields — id, batchId, batchAt, delivered, deliveredAt — need no migration.) Per-item timer + delivery: each item runs from its batch start; 'Entregado' freezes that item's timer (deliveredAt) while siblings keep running. Color thresholds are per-restaurant (timerGreenMax/timerYellowMax, migration 0011) and editable in the Orders tab; each item colors green/yellow/red by its own minutes. Independent states: delivered (per item, kitchen) vs paid (per subaccount, billing). Admin can rename a subaccount inline (PATCH subaccountName). All live via SSE; retention unchanged. i18n es/en at parity. Glassmorphism/mobile-first/safe areas preserved. Cart, maridajes and consultant untouched. New: Restaurant.timerGreenMax/timerYellowMax (migration 0011); OrderItem JSON gains id/batchId/batchAt/delivered/deliveredAt (no migration); PATCH orders/[id] gains deliverItemId+delivered and subaccountName; settings + GET /orders carry thresholds. Verified (build passes, all i18n present, migration 0011 applies): 1 two normal orders table 7 -> one card, two subaccounts; 2 lote A (30m ago) red + lote B (now) green, two batches; 3 deliver A1 -> frozen w/ deliveredAt, A2 keeps running; 4 thresholds 5/15 persist and return via GET /orders; 5 paid toggles independent of delivered (and vice versa); 6 rename '(table)' -> 'Juan' persists + SSE order-edit carries it.
4 lines
177 B
SQL
4 lines
177 B
SQL
-- AlterTable
|
|
ALTER TABLE "Restaurant" ADD COLUMN "timerGreenMax" INTEGER NOT NULL DEFAULT 10;
|
|
ALTER TABLE "Restaurant" ADD COLUMN "timerYellowMax" INTEGER NOT NULL DEFAULT 20;
|