Merge pull request #13 from ualsweb/claude/jtbd-bakery-inventory-ui-011CUrU1eJcvQVUnNQZYh67L
Claude/jtbd bakery inventory UI 011 c ur u1e jcv qv un nqz yh67 l
This commit is contained in:
@@ -38,22 +38,66 @@ class UpdateStepRequest(BaseModel):
|
||||
completed: bool
|
||||
data: Optional[Dict[str, Any]] = None
|
||||
|
||||
# Define the onboarding steps and their order - matching frontend step IDs
|
||||
# Define the onboarding steps and their order - matching frontend UnifiedOnboardingWizard step IDs
|
||||
ONBOARDING_STEPS = [
|
||||
"user_registered", # Auto-completed: User account created
|
||||
"setup", # Step 1: Basic bakery setup and tenant creation
|
||||
"smart-inventory-setup", # Step 2: Sales data upload and inventory configuration
|
||||
"suppliers", # Step 3: Suppliers configuration (optional)
|
||||
"ml-training", # Step 4: AI model training
|
||||
"completion" # Step 5: Onboarding completed, ready to use dashboard
|
||||
# Phase 0: System Steps
|
||||
"user_registered", # Auto-completed: User account created
|
||||
|
||||
# Phase 1: Discovery
|
||||
"bakery-type-selection", # Choose bakery type: production/retail/mixed
|
||||
|
||||
# Phase 2: Core Setup
|
||||
"setup", # Basic bakery setup and tenant creation
|
||||
|
||||
# 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: Suppliers (shared by all paths)
|
||||
"suppliers-setup", # Suppliers configuration
|
||||
|
||||
# Phase 3: Advanced Configuration (all optional)
|
||||
"recipes-setup", # Production recipes (conditional: production/mixed bakery)
|
||||
"production-processes", # Finishing processes (conditional: retail/mixed bakery)
|
||||
"quality-setup", # Quality standards and templates
|
||||
"team-setup", # Team members and permissions
|
||||
|
||||
# Phase 4: ML & Finalization
|
||||
"ml-training", # AI model training
|
||||
"setup-review", # Review all configuration
|
||||
"completion" # Onboarding completed
|
||||
]
|
||||
|
||||
# Step dependencies - defines which steps must be completed before others
|
||||
# Steps not listed here have no dependencies (can be completed anytime after user_registered)
|
||||
STEP_DEPENDENCIES = {
|
||||
"setup": ["user_registered"],
|
||||
# Discovery phase
|
||||
"bakery-type-selection": ["user_registered"],
|
||||
|
||||
# Core setup - no longer depends on data-source-choice (removed)
|
||||
"setup": ["user_registered", "bakery-type-selection"],
|
||||
|
||||
# AI-Assisted path dependencies (ONLY path now)
|
||||
"smart-inventory-setup": ["user_registered", "setup"],
|
||||
"suppliers": ["user_registered", "setup", "smart-inventory-setup"], # Optional step
|
||||
"product-categorization": ["user_registered", "setup", "smart-inventory-setup"],
|
||||
"initial-stock-entry": ["user_registered", "setup", "smart-inventory-setup", "product-categorization"],
|
||||
|
||||
# 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"],
|
||||
"quality-setup": ["user_registered", "setup"],
|
||||
"team-setup": ["user_registered", "setup"],
|
||||
|
||||
# ML Training - requires AI path completion
|
||||
"ml-training": ["user_registered", "setup", "smart-inventory-setup"],
|
||||
"completion": ["user_registered", "setup", "smart-inventory-setup", "ml-training"]
|
||||
|
||||
# Review and completion
|
||||
"setup-review": ["user_registered", "setup"],
|
||||
"completion": ["user_registered", "setup"] # Minimal requirements for completion
|
||||
}
|
||||
|
||||
class OnboardingService:
|
||||
@@ -233,27 +277,26 @@ class OnboardingService:
|
||||
|
||||
# SPECIAL VALIDATION FOR ML TRAINING STEP
|
||||
if step_name == "ml-training":
|
||||
# Ensure that smart-inventory-setup was completed with sales data imported
|
||||
smart_inventory_data = user_progress_data.get("smart-inventory-setup", {}).get("data", {})
|
||||
|
||||
# Check if sales data was imported successfully
|
||||
sales_import_result = smart_inventory_data.get("salesImportResult", {})
|
||||
has_sales_data_imported = (
|
||||
sales_import_result.get("records_created", 0) > 0 or
|
||||
sales_import_result.get("success", False) or
|
||||
sales_import_result.get("imported", False)
|
||||
)
|
||||
|
||||
if not has_sales_data_imported:
|
||||
logger.warning(f"ML training blocked for user {user_id}: No sales data imported",
|
||||
extra={"sales_import_result": sales_import_result})
|
||||
return False
|
||||
|
||||
# Also check if inventory is configured
|
||||
inventory_configured = smart_inventory_data.get("inventoryConfigured", False)
|
||||
if not inventory_configured:
|
||||
logger.warning(f"ML training blocked for user {user_id}: Inventory not configured")
|
||||
return False
|
||||
# ML training requires AI-assisted path completion (only path available now)
|
||||
ai_path_complete = user_progress_data.get("smart-inventory-setup", {}).get("completed", False)
|
||||
|
||||
if ai_path_complete:
|
||||
# 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 = (
|
||||
sales_import_result.get("records_created", 0) > 0 or
|
||||
sales_import_result.get("success", False) or
|
||||
sales_import_result.get("imported", False)
|
||||
)
|
||||
|
||||
if has_sales_data_imported:
|
||||
logger.info(f"ML training allowed for user {user_id}: AI path with sales data")
|
||||
return True
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user