
- Fix unused imports in API endpoints - Add proper __all__ exports in model and schema modules - Add proper TYPE_CHECKING imports in models to prevent circular imports - Fix import order in migrations - Fix long lines in migration scripts - All ruff checks passing
78 lines
1.6 KiB
Python
78 lines
1.6 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class ProductBase(BaseModel):
|
|
"""
|
|
Base schema for product data.
|
|
"""
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
sku: Optional[str] = None
|
|
price: Optional[float] = None
|
|
cost: Optional[float] = None
|
|
quantity: Optional[int] = None
|
|
reorder_level: Optional[int] = None
|
|
category_id: Optional[str] = None
|
|
supplier_id: Optional[str] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class ProductCreate(ProductBase):
|
|
"""
|
|
Schema for creating new products.
|
|
"""
|
|
name: str
|
|
sku: str
|
|
price: float
|
|
cost: float
|
|
quantity: int = 0
|
|
reorder_level: int = 10
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class ProductUpdate(ProductBase):
|
|
"""
|
|
Schema for updating product data.
|
|
"""
|
|
pass
|
|
|
|
|
|
class ProductInDBBase(ProductBase):
|
|
"""
|
|
Base schema for product data from the database.
|
|
"""
|
|
id: str
|
|
owner_id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Product(ProductInDBBase):
|
|
"""
|
|
Schema for product data to return via API.
|
|
"""
|
|
pass
|
|
|
|
|
|
# Additional properties for inventory status
|
|
class ProductInventoryStatus(BaseModel):
|
|
"""
|
|
Schema for product inventory status.
|
|
"""
|
|
id: str
|
|
name: str
|
|
sku: str
|
|
quantity: int
|
|
reorder_level: int
|
|
status: str # "In Stock", "Low Stock", "Out of Stock"
|
|
|
|
class Config:
|
|
from_attributes = True |