Improve the frontend and repository layer
This commit is contained in:
@@ -5,11 +5,61 @@ Provides common settings and patterns
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List, Dict, Optional, Any
|
||||
from typing import List, Dict, Optional, Any, Set
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import validator, Field
|
||||
|
||||
|
||||
# ================================================================
|
||||
# INTERNAL SERVICE REGISTRY
|
||||
# ================================================================
|
||||
|
||||
# Central registry of all internal microservices that should have
|
||||
# automatic access to tenant resources without user membership
|
||||
# Service names should match the naming convention used in JWT tokens
|
||||
INTERNAL_SERVICES: Set[str] = {
|
||||
# Core services
|
||||
"auth-service",
|
||||
"tenant-service",
|
||||
|
||||
# Business logic services
|
||||
"inventory-service",
|
||||
"production-service",
|
||||
"recipes-service",
|
||||
"suppliers-service",
|
||||
"pos-service",
|
||||
"orders-service",
|
||||
"sales-service",
|
||||
|
||||
# ML and analytics services
|
||||
"training-service",
|
||||
"forecasting-service",
|
||||
|
||||
# Support services
|
||||
"notification-service",
|
||||
"alert-service",
|
||||
"alert-processor-service",
|
||||
"demo-session-service",
|
||||
"external-service",
|
||||
|
||||
# Legacy/alternative naming (for backwards compatibility)
|
||||
"data-service", # May be used by older components
|
||||
}
|
||||
|
||||
|
||||
def is_internal_service(service_identifier: str) -> bool:
|
||||
"""
|
||||
Check if a service identifier represents an internal service.
|
||||
|
||||
Args:
|
||||
service_identifier: Service name (e.g., 'production-service')
|
||||
|
||||
Returns:
|
||||
bool: True if the identifier is a recognized internal service
|
||||
"""
|
||||
return service_identifier in INTERNAL_SERVICES
|
||||
|
||||
|
||||
class BaseServiceSettings(BaseSettings):
|
||||
"""
|
||||
Base configuration class for all microservices
|
||||
@@ -333,29 +383,16 @@ class BaseServiceSettings(BaseSettings):
|
||||
# PROCUREMENT AUTOMATION
|
||||
# ================================================================
|
||||
|
||||
# Auto-PO Creation
|
||||
# NOTE: Tenant-specific procurement settings (auto-approval thresholds, supplier scores,
|
||||
# approval rules, lead times, forecast days, etc.) have been moved to TenantSettings.
|
||||
# Services should fetch these using TenantSettingsClient from shared/utils/tenant_settings_client.py
|
||||
|
||||
# System-level procurement settings (apply to all tenants):
|
||||
AUTO_CREATE_POS_FROM_PLAN: bool = os.getenv("AUTO_CREATE_POS_FROM_PLAN", "true").lower() == "true"
|
||||
AUTO_APPROVE_ENABLED: bool = os.getenv("AUTO_APPROVE_ENABLED", "true").lower() == "true"
|
||||
AUTO_APPROVE_THRESHOLD_EUR: float = float(os.getenv("AUTO_APPROVE_THRESHOLD_EUR", "500.0"))
|
||||
AUTO_APPROVE_TRUSTED_SUPPLIERS: bool = os.getenv("AUTO_APPROVE_TRUSTED_SUPPLIERS", "true").lower() == "true"
|
||||
AUTO_APPROVE_MIN_SUPPLIER_SCORE: float = float(os.getenv("AUTO_APPROVE_MIN_SUPPLIER_SCORE", "0.80"))
|
||||
|
||||
# Approval Rules
|
||||
REQUIRE_APPROVAL_ABOVE_EUR: float = float(os.getenv("REQUIRE_APPROVAL_ABOVE_EUR", "500.0"))
|
||||
REQUIRE_APPROVAL_NEW_SUPPLIERS: bool = os.getenv("REQUIRE_APPROVAL_NEW_SUPPLIERS", "true").lower() == "true"
|
||||
REQUIRE_APPROVAL_CRITICAL_ITEMS: bool = os.getenv("REQUIRE_APPROVAL_CRITICAL_ITEMS", "true").lower() == "true"
|
||||
|
||||
# Notifications
|
||||
PO_APPROVAL_REMINDER_HOURS: int = int(os.getenv("PO_APPROVAL_REMINDER_HOURS", "24"))
|
||||
PO_CRITICAL_ESCALATION_HOURS: int = int(os.getenv("PO_CRITICAL_ESCALATION_HOURS", "12"))
|
||||
PROCUREMENT_TEST_MODE: bool = os.getenv("PROCUREMENT_TEST_MODE", "false").lower() == "true"
|
||||
SEND_AUTO_APPROVAL_SUMMARY: bool = os.getenv("SEND_AUTO_APPROVAL_SUMMARY", "true").lower() == "true"
|
||||
AUTO_APPROVAL_SUMMARY_TIME_HOUR: int = int(os.getenv("AUTO_APPROVAL_SUMMARY_TIME_HOUR", "18"))
|
||||
|
||||
# Procurement Planning
|
||||
PROCUREMENT_PLANNING_ENABLED: bool = os.getenv("PROCUREMENT_PLANNING_ENABLED", "true").lower() == "true"
|
||||
PROCUREMENT_PLAN_HORIZON_DAYS: int = int(os.getenv("PROCUREMENT_PLAN_HORIZON_DAYS", "14"))
|
||||
PROCUREMENT_TEST_MODE: bool = os.getenv("PROCUREMENT_TEST_MODE", "false").lower() == "true"
|
||||
|
||||
# ================================================================
|
||||
# DEVELOPMENT & TESTING
|
||||
# ================================================================
|
||||
|
||||
Reference in New Issue
Block a user