Improve the frontend modals
This commit is contained in:
@@ -2,24 +2,37 @@
|
||||
Subscription management API for GDPR-compliant cancellation and reactivation
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query
|
||||
from pydantic import BaseModel, Field
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from uuid import UUID
|
||||
import structlog
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy import select
|
||||
|
||||
from shared.auth.decorators import get_current_user_dep, require_admin_role_dep
|
||||
from shared.routing import RouteBuilder
|
||||
from app.core.database import get_db
|
||||
from app.models.tenants import Subscription, Tenant
|
||||
from app.models.tenants import Subscription
|
||||
from app.services.subscription_limit_service import SubscriptionLimitService
|
||||
|
||||
logger = structlog.get_logger()
|
||||
router = APIRouter()
|
||||
route_builder = RouteBuilder('tenant')
|
||||
|
||||
|
||||
class QuotaCheckResponse(BaseModel):
|
||||
"""Response for quota limit checks"""
|
||||
allowed: bool
|
||||
message: str
|
||||
limit: int
|
||||
current_count: int
|
||||
max_allowed: int
|
||||
reason: str
|
||||
requested_amount: int
|
||||
available_amount: int
|
||||
|
||||
|
||||
class SubscriptionCancellationRequest(BaseModel):
|
||||
"""Request model for subscription cancellation"""
|
||||
tenant_id: str = Field(..., description="Tenant ID to cancel subscription for")
|
||||
|
||||
@@ -34,7 +34,12 @@ class TenantSettings(Base):
|
||||
"demand_forecast_days": 14,
|
||||
"safety_stock_percentage": 20.0,
|
||||
"po_approval_reminder_hours": 24,
|
||||
"po_critical_escalation_hours": 12
|
||||
"po_critical_escalation_hours": 12,
|
||||
"use_reorder_rules": True,
|
||||
"economic_rounding": True,
|
||||
"respect_storage_limits": True,
|
||||
"use_supplier_minimums": True,
|
||||
"optimize_price_tiers": True
|
||||
})
|
||||
|
||||
# Inventory Management Settings (Inventory Service)
|
||||
@@ -86,7 +91,11 @@ class TenantSettings(Base):
|
||||
"good_quality_rate": 95.0,
|
||||
"critical_delivery_delay_hours": 24,
|
||||
"critical_quality_rejection_rate": 10.0,
|
||||
"high_cost_variance_percentage": 15.0
|
||||
"high_cost_variance_percentage": 15.0,
|
||||
# Supplier Approval Workflow Settings
|
||||
"require_supplier_approval": True,
|
||||
"auto_approve_for_admin_owner": True,
|
||||
"approval_required_roles": ["member", "viewer"]
|
||||
})
|
||||
|
||||
# POS Integration Settings (POS Service)
|
||||
@@ -132,7 +141,12 @@ class TenantSettings(Base):
|
||||
"demand_forecast_days": 14,
|
||||
"safety_stock_percentage": 20.0,
|
||||
"po_approval_reminder_hours": 24,
|
||||
"po_critical_escalation_hours": 12
|
||||
"po_critical_escalation_hours": 12,
|
||||
"use_reorder_rules": True,
|
||||
"economic_rounding": True,
|
||||
"respect_storage_limits": True,
|
||||
"use_supplier_minimums": True,
|
||||
"optimize_price_tiers": True
|
||||
},
|
||||
"inventory_settings": {
|
||||
"low_stock_threshold": 10,
|
||||
@@ -178,7 +192,10 @@ class TenantSettings(Base):
|
||||
"good_quality_rate": 95.0,
|
||||
"critical_delivery_delay_hours": 24,
|
||||
"critical_quality_rejection_rate": 10.0,
|
||||
"high_cost_variance_percentage": 15.0
|
||||
"high_cost_variance_percentage": 15.0,
|
||||
"require_supplier_approval": True,
|
||||
"auto_approve_for_admin_owner": True,
|
||||
"approval_required_roles": ["member", "viewer"]
|
||||
},
|
||||
"pos_settings": {
|
||||
"sync_interval_minutes": 5,
|
||||
|
||||
@@ -26,6 +26,11 @@ class ProcurementSettings(BaseModel):
|
||||
safety_stock_percentage: float = Field(20.0, ge=0.0, le=100.0)
|
||||
po_approval_reminder_hours: int = Field(24, ge=1, le=168)
|
||||
po_critical_escalation_hours: int = Field(12, ge=1, le=72)
|
||||
use_reorder_rules: bool = Field(True, description="Use ingredient reorder point and reorder quantity in procurement calculations")
|
||||
economic_rounding: bool = Field(True, description="Round order quantities to economic multiples (reorder_quantity or supplier minimum_order_quantity)")
|
||||
respect_storage_limits: bool = Field(True, description="Enforce max_stock_level constraints on orders")
|
||||
use_supplier_minimums: bool = Field(True, description="Respect supplier minimum_order_quantity and minimum_order_amount")
|
||||
optimize_price_tiers: bool = Field(True, description="Optimize order quantities to capture volume discount price tiers")
|
||||
|
||||
|
||||
class InventorySettings(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user