feat: make products server managed
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-20 23:55:40 +02:00
parent 0ca9f4d16a
commit e7f59f7583
14 changed files with 697 additions and 181 deletions
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Product" ADD COLUMN "archivedAt" TIMESTAMP(3);
+8 -5
View File
@@ -232,12 +232,12 @@ model TabEvent {
@@index([venueId, type, occurredAt])
}
// The venue's products as reported by its terminals, with the stock. The server owns the stock: it follows the
// terminals' line events and stock counts and the dashboard's StockAdjustments. A product is never removed because
// one terminal doesn't report it.
// The venue's products and their stock. The dashboard manages the catalog and the terminals get it on every sync;
// the first terminal's own catalog was taken over once. The stock follows the terminals' line events and stock
// counts and the dashboard's StockAdjustments.
model Product {
venueId String
// Generated by the terminal
// Generated by the server, or by the terminal that reported it before the dashboard managed the catalog
productId String
name String
category String?
@@ -246,9 +246,12 @@ model Product {
stock Int?
// When the stock was last counted; line events that happened before it are already in the count
countedAt DateTime?
// Dashboard-only setting, never sent to or overwritten by the terminal
// Warn when the stock drops to this level
lowStockThreshold Int?
// When it was created or last changed
reportedAt DateTime
// Deleted on the dashboard: hidden on the terminals, kept because tabs and history refer to it
archivedAt DateTime?
venue Venue @relation(fields: [venueId], references: [id])