2025-08-21 20:28:14 +02:00
|
|
|
# ================================================================
|
|
|
|
|
# services/orders/app/core/config.py
|
|
|
|
|
# ================================================================
|
|
|
|
|
"""
|
|
|
|
|
Orders Service Configuration
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
from shared.config.base import BaseServiceSettings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrdersSettings(BaseServiceSettings):
|
|
|
|
|
"""Orders service specific settings"""
|
|
|
|
|
|
|
|
|
|
# Service Identity
|
|
|
|
|
APP_NAME: str = "Orders Service"
|
|
|
|
|
SERVICE_NAME: str = "orders-service"
|
|
|
|
|
VERSION: str = "1.0.0"
|
|
|
|
|
DESCRIPTION: str = "Customer orders and procurement planning"
|
|
|
|
|
|
2025-09-27 11:18:13 +02:00
|
|
|
# Database configuration (secure approach - build from components)
|
|
|
|
|
@property
|
|
|
|
|
def DATABASE_URL(self) -> str:
|
|
|
|
|
"""Build database URL from secure components"""
|
|
|
|
|
# Try complete URL first (for backward compatibility)
|
|
|
|
|
complete_url = os.getenv("ORDERS_DATABASE_URL")
|
|
|
|
|
if complete_url:
|
|
|
|
|
return complete_url
|
|
|
|
|
|
|
|
|
|
# Build from components (secure approach)
|
|
|
|
|
user = os.getenv("ORDERS_DB_USER", "orders_user")
|
|
|
|
|
password = os.getenv("ORDERS_DB_PASSWORD", "orders_pass123")
|
|
|
|
|
host = os.getenv("ORDERS_DB_HOST", "localhost")
|
|
|
|
|
port = os.getenv("ORDERS_DB_PORT", "5432")
|
|
|
|
|
name = os.getenv("ORDERS_DB_NAME", "orders_db")
|
|
|
|
|
|
|
|
|
|
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
2025-08-21 20:28:14 +02:00
|
|
|
|
|
|
|
|
# Order Processing
|
|
|
|
|
ORDER_PROCESSING_ENABLED: bool = os.getenv("ORDER_PROCESSING_ENABLED", "true").lower() == "true"
|
|
|
|
|
AUTO_APPROVE_ORDERS: bool = os.getenv("AUTO_APPROVE_ORDERS", "false").lower() == "true"
|
|
|
|
|
MAX_ORDER_ITEMS: int = int(os.getenv("MAX_ORDER_ITEMS", "50"))
|
|
|
|
|
|
|
|
|
|
# Procurement Planning
|
|
|
|
|
PROCUREMENT_PLANNING_ENABLED: bool = os.getenv("PROCUREMENT_PLANNING_ENABLED", "true").lower() == "true"
|
|
|
|
|
PROCUREMENT_LEAD_TIME_DAYS: int = int(os.getenv("PROCUREMENT_LEAD_TIME_DAYS", "3"))
|
|
|
|
|
DEMAND_FORECAST_DAYS: int = int(os.getenv("DEMAND_FORECAST_DAYS", "14"))
|
|
|
|
|
SAFETY_STOCK_PERCENTAGE: float = float(os.getenv("SAFETY_STOCK_PERCENTAGE", "20.0"))
|
|
|
|
|
|
|
|
|
|
# Business Model Detection
|
|
|
|
|
ENABLE_BUSINESS_MODEL_DETECTION: bool = os.getenv("ENABLE_BUSINESS_MODEL_DETECTION", "true").lower() == "true"
|
|
|
|
|
CENTRAL_BAKERY_ORDER_THRESHOLD: int = int(os.getenv("CENTRAL_BAKERY_ORDER_THRESHOLD", "20"))
|
|
|
|
|
INDIVIDUAL_BAKERY_ORDER_THRESHOLD: int = int(os.getenv("INDIVIDUAL_BAKERY_ORDER_THRESHOLD", "5"))
|
|
|
|
|
|
|
|
|
|
# Customer Management
|
|
|
|
|
CUSTOMER_VALIDATION_ENABLED: bool = os.getenv("CUSTOMER_VALIDATION_ENABLED", "true").lower() == "true"
|
|
|
|
|
MAX_CUSTOMERS_PER_TENANT: int = int(os.getenv("MAX_CUSTOMERS_PER_TENANT", "10000"))
|
|
|
|
|
CUSTOMER_CREDIT_CHECK_ENABLED: bool = os.getenv("CUSTOMER_CREDIT_CHECK_ENABLED", "false").lower() == "true"
|
|
|
|
|
|
|
|
|
|
# Order Validation
|
|
|
|
|
MIN_ORDER_VALUE: float = float(os.getenv("MIN_ORDER_VALUE", "0.0"))
|
|
|
|
|
MAX_ORDER_VALUE: float = float(os.getenv("MAX_ORDER_VALUE", "100000.0"))
|
|
|
|
|
VALIDATE_PRODUCT_AVAILABILITY: bool = os.getenv("VALIDATE_PRODUCT_AVAILABILITY", "true").lower() == "true"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Payment and Pricing
|
|
|
|
|
PAYMENT_VALIDATION_ENABLED: bool = os.getenv("PAYMENT_VALIDATION_ENABLED", "true").lower() == "true"
|
|
|
|
|
DYNAMIC_PRICING_ENABLED: bool = os.getenv("DYNAMIC_PRICING_ENABLED", "false").lower() == "true"
|
|
|
|
|
DISCOUNT_ENABLED: bool = os.getenv("DISCOUNT_ENABLED", "true").lower() == "true"
|
|
|
|
|
MAX_DISCOUNT_PERCENTAGE: float = float(os.getenv("MAX_DISCOUNT_PERCENTAGE", "50.0"))
|
|
|
|
|
|
|
|
|
|
# Delivery and Fulfillment
|
|
|
|
|
DELIVERY_TRACKING_ENABLED: bool = os.getenv("DELIVERY_TRACKING_ENABLED", "true").lower() == "true"
|
|
|
|
|
DEFAULT_DELIVERY_WINDOW_HOURS: int = int(os.getenv("DEFAULT_DELIVERY_WINDOW_HOURS", "48"))
|
|
|
|
|
PICKUP_ENABLED: bool = os.getenv("PICKUP_ENABLED", "true").lower() == "true"
|
|
|
|
|
DELIVERY_ENABLED: bool = os.getenv("DELIVERY_ENABLED", "true").lower() == "true"
|
|
|
|
|
|
|
|
|
|
# Integration Settings
|
|
|
|
|
PRODUCTION_SERVICE_URL: str = os.getenv("PRODUCTION_SERVICE_URL", "http://production-service:8000")
|
|
|
|
|
INVENTORY_SERVICE_URL: str = os.getenv("INVENTORY_SERVICE_URL", "http://inventory-service:8000")
|
|
|
|
|
SUPPLIERS_SERVICE_URL: str = os.getenv("SUPPLIERS_SERVICE_URL", "http://suppliers-service:8000")
|
|
|
|
|
SALES_SERVICE_URL: str = os.getenv("SALES_SERVICE_URL", "http://sales-service:8000")
|
|
|
|
|
|
|
|
|
|
|
2025-09-22 16:10:08 +02:00
|
|
|
|
2025-08-21 20:28:14 +02:00
|
|
|
# Global settings instance
|
|
|
|
|
settings = OrdersSettings()
|