- Add KiosksManagement component with full CRUD for kiosks
- Add ScheduleManagement for staff schedules with break reminders
- Update booking flow to allow artist selection by customers
- Add staff_services API for assigning services to artists
- Update staff management UI with service assignment dialog
- Add auto-break reminder when schedule >= 8 hours
- Update availability API to filter artists by service
- Add kiosk management to Aperture dashboard
- Clean up ralphy artifacts and logs
- Created migration to fix ALL locations with incorrect business hours
- Added debug endpoint to check business hours
- Migration updates locations with 22:00/23:00 times to correct 10:00-19:00
This resolves the booking availability showing wrong time slots.
FIX 1 - Calendar Day Offset (already fixed in previous commit):
- Corrected DatePicker component to calculate proper day offset
- Added padding cells for correct weekday alignment
- January 1, 2026 now correctly shows as Thursday instead of Monday
FIX 2 - Business Hours Only Showing 22:00-23:00:
PROBLEM:
- Time slots API only returned 22:00 and 23:00 as available hours
- Incorrect business hours in database (likely 22:00-23:00 instead of 10:00-19:00)
- Poor timezone conversion in get_detailed_availability function
ROOT CAUSES:
1. Location business_hours stored incorrect hours (22:00-23:00)
2. get_detailed_availability had timezone concatenation issues
- Used string concatenation for timestamp construction
- Didn't properly handle timezone conversion
3. Fallback to defaults was using wrong values
SOLUTIONS:
1. Migration 20260118080000_fix_business_hours_default.sql:
- Update default business hours to normal salon hours
- Mon-Fri: 10:00-19:00
- Saturday: 10:00-18:00
- Sunday: Closed
2. Migration 20260118090000_fix_get_detailed_availability_timezone.sql:
- Rewrite get_detailed_availability function
- Use make_timestamp() instead of string concatenation
- Proper timezone handling with AT TIME ZONE
- Better NULL handling for business_hours
- Fix is_available_for_booking COALESCE to default true
CHANGES:
- components/booking/date-picker.tsx: Added day offset calculation
- supabase/migrations/20260118080000.sql: Fix default business hours
- supabase/migrations/20260118090000.sql: Fix timezone in availability function
✅ SISTEMA DE NÓMINA COMPLETO:
- API con cálculos automáticos de sueldo
- Cálculo de comisiones (10% de revenue de servicios completados)
- Cálculo de propinas (5% estimado de revenue)
- Cálculo de horas trabajadas desde bookings completados
- Sueldo base configurable por staff
✅ COMPONENTE PayrollManagement:
- Interfaz completa para gestión de nóminas
- Cálculo por períodos mensuales
- Tabla de resultados con exportación CSV
- Diálogo de cálculo detallado
✅ APIs CRUD STAFF FUNCIONALES:
- GET/POST/PUT/DELETE y
- Gestión de roles y ubicaciones
- Auditoría completa de cambios
✅ APIs CRUD RESOURCES FUNCIONALES:
- GET/POST con disponibilidad en tiempo real
- Estado de ocupación por recurso
- Capacidades y tipos de recursos
✅ MIGRACIÓN PAYROLL PREPARADA:
- Tablas: staff_salaries, commission_rates, tip_records, payroll_records
- Funciones PostgreSQL para cálculos complejos
- RLS policies configuradas
Próximo: POS completo con múltiples métodos de pago
✅ COMENTARIOS AUDITABLES IMPLEMENTADOS:
- 80+ archivos con JSDoc completo para auditoría manual
- APIs críticas con validaciones business/security/performance
- Componentes con reglas de negocio documentadas
- Funciones core con edge cases y validaciones
✅ CALENDARIO MULTI-COLUMNA FUNCIONAL (95%):
- Drag & drop con reprogramación automática
- Filtros por sucursal/staff, tiempo real
- Indicadores de conflictos y disponibilidad
- APIs completas con validaciones de colisión
✅ GESTIÓN OPERATIVA COMPLETA:
- CRUD staff: APIs + componente con validaciones
- CRUD recursos: APIs + componente con disponibilidad
- Autenticación completa con middleware seguro
- Auditoría completa en todas las operaciones
✅ DOCUMENTACIÓN ACTUALIZADA:
- TASKS.md: FASE 4 95% completado
- README.md: Estado actual y funcionalidades
- API.md: 40+ endpoints documentados
✅ SEGURIDAD Y VALIDACIONES:
- RLS policies documentadas en comentarios
- Business rules validadas manualmente
- Performance optimizations anotadas
- Error handling completo
Próximos: Nómina/POS/CRM avanzado (FASE 4 final)
Major changes:
- Add customer registration with email/phone lookup (app/booking/registro)
- Add customers API endpoint (app/api/customers/route)
- Implement business hours for locations (mon-fri 10-7, sat 10-6, sun closed)
- Fix availability function type casting issues
- Add business hours utilities (lib/utils/business-hours.ts)
- Update Location type to include business_hours JSONB
- Add mock payment component for testing
- Remove Supabase auth from booking flow
- Fix /cita redirect path in booking flow
Database migrations:
- Add category column to services table
- Add business_hours JSONB column to locations table
- Fix availability functions with proper type casting
- Update get_detailed_availability to use business_hours
Features:
- Customer lookup by email or phone
- Auto-redirect to registration if customer not found
- Pre-fill customer data if exists
- Business hours per day of week
- Location-specific opening/closing times
- Corregir uso de INTO en SELECT con múltiples columnas
- La migración de Telegram se ejecutó correctamente
- Campos de scoring agregados: performance_score, total_bookings_completed, etc.
- Funciones de scoring implementadas: update_staff_performance_score(), get_top_performers()
- Triggers automáticos para notificaciones de Telegram
- Migrated database schema from db/migrations to supabase/migrations
- Added Supabase CLI configuration (config.toml, .gitignore)
- Added kiosk role and amenities tables for touch kiosks
- Added notification system for artist alerts
- Added seed data with test locations and staff
- Removed old migration scripts and documentation
- Updated tasks_mg.md with current setup
Features:
- 2 locations: ANCHOR:23 - Via KLAVA and TEST
- Kiosk role for touch screen check-in/booking
- Amenities: coffee, cocktails, mocktails for clients
- Notifications when client arrives
- 1 staff + 4 artists + 1 kiosk per location
- Services: hair, nails, makeup, lashes