diff --git a/services/auth/app/api/onboarding_progress.py b/services/auth/app/api/onboarding_progress.py index 2acb2446..dfcd905f 100644 --- a/services/auth/app/api/onboarding_progress.py +++ b/services/auth/app/api/onboarding_progress.py @@ -45,23 +45,21 @@ ONBOARDING_STEPS = [ # Phase 1: Discovery "bakery-type-selection", # Choose bakery type: production/retail/mixed - "data-source-choice", # Choose setup method: AI-assisted or manual # Phase 2: Core Setup "setup", # Basic bakery setup and tenant creation - # Phase 2a: AI-Assisted Path + # Phase 2a: AI-Assisted Path (ONLY PATH - manual path removed) "smart-inventory-setup", # Sales data upload and AI analysis "product-categorization", # Categorize products as ingredients vs finished products "initial-stock-entry", # Capture initial stock levels - # Phase 2b: Manual Setup Path + # Phase 2b: Suppliers (shared by all paths) "suppliers-setup", # Suppliers configuration - "inventory-setup", # Manual inventory configuration + + # Phase 3: Advanced Configuration (all optional) "recipes-setup", # Production recipes (conditional: production/mixed bakery) "production-processes", # Finishing processes (conditional: retail/mixed bakery) - - # Phase 3: Advanced Configuration "quality-setup", # Quality standards and templates "team-setup", # Team members and permissions @@ -75,28 +73,27 @@ ONBOARDING_STEPS = [ # Steps not listed here have no dependencies (can be completed anytime after user_registered) STEP_DEPENDENCIES = { # Discovery phase - "data-source-choice": ["user_registered", "bakery-type-selection"], + "bakery-type-selection": ["user_registered"], - # Core setup - "setup": ["user_registered", "data-source-choice"], + # Core setup - no longer depends on data-source-choice (removed) + "setup": ["user_registered", "bakery-type-selection"], - # AI-Assisted path dependencies + # AI-Assisted path dependencies (ONLY path now) "smart-inventory-setup": ["user_registered", "setup"], "product-categorization": ["user_registered", "setup", "smart-inventory-setup"], "initial-stock-entry": ["user_registered", "setup", "smart-inventory-setup", "product-categorization"], - # Manual path dependencies - "suppliers-setup": ["user_registered", "setup"], - "inventory-setup": ["user_registered", "setup"], + # Suppliers (after AI inventory setup) + "suppliers-setup": ["user_registered", "setup", "smart-inventory-setup"], + + # Advanced configuration (optional, minimal dependencies) "recipes-setup": ["user_registered", "setup"], "production-processes": ["user_registered", "setup"], - - # Advanced configuration "quality-setup": ["user_registered", "setup"], "team-setup": ["user_registered", "setup"], - # ML Training - requires either AI path or manual inventory - "ml-training": ["user_registered", "setup"], # Flexible: can work with either path + # ML Training - requires AI path completion + "ml-training": ["user_registered", "setup", "smart-inventory-setup"], # Review and completion "setup-review": ["user_registered", "setup"], @@ -280,14 +277,11 @@ class OnboardingService: # SPECIAL VALIDATION FOR ML TRAINING STEP if step_name == "ml-training": - # ML training can work with either AI-assisted path or manual inventory path - # Check if user has data through either path - + # ML training requires AI-assisted path completion (only path available now) ai_path_complete = user_progress_data.get("smart-inventory-setup", {}).get("completed", False) - manual_path_complete = user_progress_data.get("inventory-setup", {}).get("completed", False) if ai_path_complete: - # AI path: validate sales data was imported + # Validate sales data was imported smart_inventory_data = user_progress_data.get("smart-inventory-setup", {}).get("data", {}) sales_import_result = smart_inventory_data.get("salesImportResult", {}) has_sales_data_imported = ( @@ -300,13 +294,8 @@ class OnboardingService: logger.info(f"ML training allowed for user {user_id}: AI path with sales data") return True - if manual_path_complete: - # Manual path: just check if inventory setup was completed - logger.info(f"ML training allowed for user {user_id}: Manual inventory path") - return True - - # Neither path is complete - logger.warning(f"ML training blocked for user {user_id}: No inventory data (AI or manual)") + # AI path not complete or no sales data + logger.warning(f"ML training blocked for user {user_id}: No inventory data from AI path") return False return True