Initial kitchen scaffold — Phase 1 kitchen port (build-verified 2026-07-11)
FastAPI backend (Python 3.11, MSSQL ODBC for SambaPOS, Azure DI OCR),
kitchen_db on central PG. React/TS/Vite frontend with navy sidebar layout.
Backend: auth.py (APP_SLUG=kitchen, SimpleNamespace — archive routes use
.kitchen_id/.is_admin without modification), main.py (51 migrations, scheduler,
internal router for KDS bookings feed), api/internal.py, full archive API
(31 routers: invoices, recipes, menus, sambapos, resos, newbook, disputes,
purchase_orders, etc.), models, migrations, OCR pipeline.
kitchen_id pinned to 1 (B1 — single hotel).
Frontend: AuthGate (app=kitchen, token shim for archive compat — B5b pending),
Layout (navy sidebar, 6 sections, Lucide icons, teal --app-primary),
App.tsx (Outlet pattern, UploadApp outside Layout), index.css (full :root block).
strict: false — archive components have type issues; build clean.
Note: 45 archive components call fetch('/api/...') without /kitchen/ prefix
(B5b). Runtime 404s; deferred until after initial testing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
8d688b459d
10003 changed files with 1928395 additions and 0 deletions
117
backend/migrations/add_cover_overrides.py
Normal file
117
backend/migrations/add_cover_overrides.py
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
"""
|
||||
Migration: Add cover overrides, forecast snapshots, and spend rate overrides tables.
|
||||
|
||||
Creates:
|
||||
- cover_overrides: Per-day per-period cover overrides for lunch/dinner
|
||||
- forecast_snapshots: Full weekly forecast snapshot (all periods/days) with spend rates
|
||||
- forecast_week_snapshots: Weekly revenue totals at snapshot time
|
||||
- spend_rate_overrides: Per-week per-period spend rate overrides
|
||||
"""
|
||||
import asyncio
|
||||
from sqlalchemy import text
|
||||
from database import engine
|
||||
|
||||
|
||||
async def migrate():
|
||||
async with engine.begin() as conn:
|
||||
# Create cover_overrides table
|
||||
try:
|
||||
await conn.execute(text("""
|
||||
CREATE TABLE IF NOT EXISTS cover_overrides (
|
||||
id SERIAL PRIMARY KEY,
|
||||
kitchen_id INTEGER NOT NULL REFERENCES kitchens(id),
|
||||
override_date DATE NOT NULL,
|
||||
period VARCHAR(20) NOT NULL,
|
||||
override_covers INTEGER NOT NULL,
|
||||
original_forecast INTEGER,
|
||||
original_otb INTEGER,
|
||||
created_by INTEGER REFERENCES users(id),
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_by INTEGER REFERENCES users(id),
|
||||
updated_at TIMESTAMP DEFAULT NOW(),
|
||||
UNIQUE(kitchen_id, override_date, period)
|
||||
)
|
||||
"""))
|
||||
print("+ Created cover_overrides table")
|
||||
except Exception as e:
|
||||
if "already exists" in str(e).lower():
|
||||
print("- cover_overrides table already exists, skipping")
|
||||
else:
|
||||
raise
|
||||
|
||||
# Create forecast_snapshots table
|
||||
try:
|
||||
await conn.execute(text("""
|
||||
CREATE TABLE IF NOT EXISTS forecast_snapshots (
|
||||
id SERIAL PRIMARY KEY,
|
||||
kitchen_id INTEGER NOT NULL REFERENCES kitchens(id),
|
||||
snapshot_date DATE NOT NULL,
|
||||
period VARCHAR(20) NOT NULL,
|
||||
forecast_covers INTEGER NOT NULL,
|
||||
otb_covers INTEGER NOT NULL,
|
||||
food_spend NUMERIC(10,2),
|
||||
drinks_spend NUMERIC(10,2),
|
||||
forecast_dry_revenue NUMERIC(10,2),
|
||||
week_start DATE NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
UNIQUE(kitchen_id, snapshot_date, period)
|
||||
)
|
||||
"""))
|
||||
print("+ Created forecast_snapshots table")
|
||||
except Exception as e:
|
||||
if "already exists" in str(e).lower():
|
||||
print("- forecast_snapshots table already exists, skipping")
|
||||
else:
|
||||
raise
|
||||
|
||||
# Create forecast_week_snapshots table
|
||||
try:
|
||||
await conn.execute(text("""
|
||||
CREATE TABLE IF NOT EXISTS forecast_week_snapshots (
|
||||
id SERIAL PRIMARY KEY,
|
||||
kitchen_id INTEGER NOT NULL REFERENCES kitchens(id),
|
||||
week_start DATE NOT NULL,
|
||||
total_forecast_revenue NUMERIC(12,2),
|
||||
total_otb_revenue NUMERIC(12,2),
|
||||
gp_target NUMERIC(5,2),
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW(),
|
||||
UNIQUE(kitchen_id, week_start)
|
||||
)
|
||||
"""))
|
||||
print("+ Created forecast_week_snapshots table")
|
||||
except Exception as e:
|
||||
if "already exists" in str(e).lower():
|
||||
print("- forecast_week_snapshots table already exists, skipping")
|
||||
else:
|
||||
raise
|
||||
|
||||
# Create spend_rate_overrides table
|
||||
try:
|
||||
await conn.execute(text("""
|
||||
CREATE TABLE IF NOT EXISTS spend_rate_overrides (
|
||||
id SERIAL PRIMARY KEY,
|
||||
kitchen_id INTEGER NOT NULL REFERENCES kitchens(id),
|
||||
week_start DATE NOT NULL,
|
||||
period VARCHAR(20) NOT NULL,
|
||||
food_spend NUMERIC(10,2),
|
||||
drinks_spend NUMERIC(10,2),
|
||||
created_by INTEGER REFERENCES users(id),
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_by INTEGER REFERENCES users(id),
|
||||
updated_at TIMESTAMP DEFAULT NOW(),
|
||||
UNIQUE(kitchen_id, week_start, period)
|
||||
)
|
||||
"""))
|
||||
print("+ Created spend_rate_overrides table")
|
||||
except Exception as e:
|
||||
if "already exists" in str(e).lower():
|
||||
print("- spend_rate_overrides table already exists, skipping")
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Running migration: add_cover_overrides")
|
||||
asyncio.run(migrate())
|
||||
print("Migration complete!")
|
||||
Loading…
Add table
Add a link
Reference in a new issue