Improve the frontend 3

This commit is contained in:
Urtzi Alfaro
2025-10-30 21:08:07 +01:00
parent 36217a2729
commit 63f5c6d512
184 changed files with 21512 additions and 7442 deletions

View File

@@ -3,7 +3,7 @@
# ================================================================
"""
Orders Service - FastAPI Application
Customer orders and procurement planning service
Customer orders management service
"""
from fastapi import FastAPI, Request
@@ -13,9 +13,7 @@ from app.core.database import database_manager
from app.api.orders import router as orders_router
from app.api.customers import router as customers_router
from app.api.order_operations import router as order_operations_router
from app.api.procurement_operations import router as procurement_operations_router
from app.api import internal_demo
from app.services.procurement_scheduler_service import ProcurementSchedulerService
from shared.service_base import StandardFastAPIService
@@ -47,7 +45,7 @@ class OrdersService(StandardFastAPIService):
# Define expected database tables for health checks
orders_expected_tables = [
'customers', 'customer_contacts', 'customer_orders', 'order_items',
'order_status_history', 'procurement_plans', 'procurement_requirements'
'order_status_history', 'audit_logs'
]
super().__init__(
@@ -62,29 +60,22 @@ class OrdersService(StandardFastAPIService):
async def on_startup(self, app: FastAPI):
"""Custom startup logic for orders service"""
# Initialize procurement scheduler service
scheduler_service = ProcurementSchedulerService(settings)
await scheduler_service.start()
self.logger.info("Procurement scheduler service started")
# Store scheduler service in app state
app.state.scheduler_service = scheduler_service
# REMOVED: Procurement scheduler service initialization
# Procurement scheduling is now handled by the Orchestrator Service
# which calls the Procurement Service's /auto-generate endpoint
pass
async def on_shutdown(self, app: FastAPI):
"""Custom shutdown logic for orders service"""
# Stop scheduler service
if hasattr(app.state, 'scheduler_service'):
await app.state.scheduler_service.stop()
self.logger.info("Scheduler service stopped")
# REMOVED: Scheduler service shutdown
pass
def get_service_features(self):
"""Return orders-specific features"""
return [
"customer_management",
"order_processing",
"procurement_planning",
"order_tracking",
"automated_scheduling"
"order_tracking"
]
@@ -106,25 +97,12 @@ service.add_router(orders_router)
# BUSINESS: Complex operations and workflows
service.add_router(order_operations_router)
service.add_router(procurement_operations_router)
# INTERNAL: Service-to-service endpoints
service.add_router(internal_demo.router)
@app.post("/test/procurement-scheduler")
async def test_procurement_scheduler():
"""Test endpoint to manually trigger procurement scheduler"""
try:
if hasattr(app.state, 'scheduler_service'):
scheduler_service = app.state.scheduler_service
await scheduler_service.test_procurement_generation()
return {"message": "Procurement scheduler test triggered successfully"}
else:
return {"error": "Scheduler service not available"}
except Exception as e:
service.logger.error("Error testing procurement scheduler", error=str(e))
return {"error": f"Failed to trigger scheduler test: {str(e)}"}
# REMOVED: test_procurement_scheduler endpoint
# Procurement scheduling is now triggered by the Orchestrator Service
@app.middleware("http")