2025-06-19 17:52:06 +00:00

63 lines
2.1 KiB
Python

from pydantic import BaseModel, Field
from typing import Dict, List, Optional
class ItemCount(BaseModel):
"""Count of items in the inventory"""
total: int = Field(..., description="Total number of items", example=100)
by_category: Dict[str, int] = Field(
...,
description="Count of items by category",
example={"Electronics": 45, "Books": 55}
)
class CategoryCount(BaseModel):
"""Count of categories in the inventory"""
total: int = Field(..., description="Total number of categories", example=5)
class InventoryValue(BaseModel):
"""Total value of inventory"""
total: float = Field(..., description="Total value of all items", example=10500.75)
by_category: Dict[str, float] = Field(
...,
description="Total value by category",
example={"Electronics": 8000.50, "Books": 2500.25}
)
class LowStockItems(BaseModel):
"""Information about low stock items"""
count: int = Field(..., description="Number of items with low stock", example=3)
threshold: int = Field(..., description="Threshold used for low stock", example=10)
items: List[Dict[str, str]] = Field(
...,
description="Basic information about low stock items",
example=[
{"id": 1, "name": "Laptop", "quantity": 5},
{"id": 2, "name": "Monitor", "quantity": 8},
]
)
class RecentTransactions(BaseModel):
"""Recent inventory transactions"""
count: int = Field(..., description="Number of recent transactions", example=5)
transactions: List[Dict[str, str]] = Field(
...,
description="Basic information about recent transactions",
example=[
{"id": 1, "item_name": "Laptop", "quantity_change": 10, "type": "addition"},
{"id": 2, "item_name": "Monitor", "quantity_change": -2, "type": "removal"},
]
)
class DashboardStatistics(BaseModel):
"""Complete dashboard statistics"""
item_count: ItemCount
category_count: CategoryCount
inventory_value: Optional[InventoryValue] = None
low_stock_items: Optional[LowStockItems] = None
recent_transactions: Optional[RecentTransactions] = None