diff --git a/src/db.js b/src/db.js index 19eb837..1f04f17 100644 --- a/src/db.js +++ b/src/db.js @@ -121,10 +121,10 @@ export async function initDb() { ('noticeboard', 'Noticeboard', 'Staff notices and announcements', '/notices', 'ClipboardList', '#1e3a5f', NULL, '10.10.10.112', 3080), ('kitchen', 'Kitchen Flash','Invoice processing and GP tracking', '/kitchen', 'ChefHat', '#e85d04', 'Kitchen', '10.10.10.110', 3080), ('cashup', 'Cash Up', 'Hotel daily cashing up', '/cashup', 'Banknote', '#6b2d8b', 'Finance', '10.10.10.117', 3083), - ('housekeeping','Housekeeping', 'Room status and task management', '/hk', 'BedDouble', '#2d6a4f', 'Housekeeping', '10.10.10.114', 3080), - ('hk-planner', 'HK Planner', 'Housekeeping workload and hours planning', '/hk-planner', 'CalendarClock', '#2d6a4f', 'Housekeeping', '10.10.10.118', 3080), + ('housekeeping','Housekeeping', 'Room status and task management', '/hk', 'BedDouble', '#2d6a4f', 'Hotel', '10.10.10.114', 3080), + ('hk-planner', 'Rota Check', 'Housekeeping workload and hours planning', '/hk-planner', 'CalendarClock', '#2d6a4f', 'Housekeeping', '10.10.10.118', 3080), ('twin-optimiser', 'Twin Optimiser', 'Identify twin room opportunities from booking grid', '/twin-optimiser', 'LayoutGrid', '#c9841a', 'Housekeeping', '10.10.10.119', 3080), - ('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecast', 'TrendingUp', '#0077b6', 'Finance', '10.10.10.113', 3080), + ('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecasting', 'TrendingUp', '#0077b6', 'Finance', '10.10.10.113', 3080), ('rates', 'Rate Scraper', 'Competitor rate monitoring', '/rates', 'Tag', '#7b4f00', 'Finance', '10.10.10.115', 3080), ('maintenance', 'Maintenance', 'Maintenance log book — faults, recurring tasks, assets and contractors', '/maintenance', 'Wrench', '#b45309', 'Operations', '10.10.10.121', 3080) ON CONFLICT (slug) DO UPDATE SET @@ -230,6 +230,26 @@ export async function initDb() { ON CONFLICT DO NOTHING `) + // Seed forecasting capabilities + await pool.query(` + INSERT INTO app_capabilities (app_id, slug, name, description, sort_order) + SELECT a.id, c.slug, c.name, c.description, c.sort_order + FROM apps a + CROSS JOIN (VALUES + ('view', 'View Forecasts', 'View dashboard, forecasts, and history', 1), + ('view_bookability', 'View Bookability', 'View the rate / bookability matrix', 2), + ('view_competitor_rates', 'View Competitors', 'View competitor rate scraping and matrix', 3), + ('view_accuracy', 'View Accuracy', 'View model accuracy metrics and backtesting', 4), + ('manage_sync', 'Manage Data Sync', 'Trigger Newbook / Resos data syncs manually', 5), + ('settings', 'Manage Settings', 'Configure Newbook credentials and sync schedules', 6) + ) AS c(slug, name, description, sort_order) + WHERE a.slug = 'forecasting' + ON CONFLICT (app_id, slug) DO UPDATE SET + name = EXCLUDED.name, + description = EXCLUDED.description, + sort_order = EXCLUDED.sort_order + `) + // Seed first admin user if table is empty const { rows } = await pool.query('SELECT COUNT(*) FROM users') if (parseInt(rows[0].count) === 0) {