
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, EmailStr, Field
|
|
|
|
|
|
class SupplierBase(BaseModel):
|
|
"""
|
|
Base supplier schema with common attributes.
|
|
"""
|
|
name: str = Field(..., description="Supplier name")
|
|
contact_name: Optional[str] = Field(None, description="Contact person name")
|
|
email: Optional[EmailStr] = Field(None, description="Supplier email address")
|
|
phone: Optional[str] = Field(None, description="Supplier phone number")
|
|
address: Optional[str] = Field(None, description="Supplier address")
|
|
|
|
|
|
class SupplierCreate(SupplierBase):
|
|
"""
|
|
Schema for supplier creation.
|
|
"""
|
|
pass
|
|
|
|
|
|
class SupplierUpdate(BaseModel):
|
|
"""
|
|
Schema for updating supplier information.
|
|
"""
|
|
name: Optional[str] = Field(None, description="Supplier name")
|
|
contact_name: Optional[str] = Field(None, description="Contact person name")
|
|
email: Optional[EmailStr] = Field(None, description="Supplier email address")
|
|
phone: Optional[str] = Field(None, description="Supplier phone number")
|
|
address: Optional[str] = Field(None, description="Supplier address")
|
|
|
|
|
|
class SupplierInDBBase(SupplierBase):
|
|
"""
|
|
Base schema for suppliers from the database.
|
|
"""
|
|
id: int = Field(..., description="Supplier ID")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Supplier(SupplierInDBBase):
|
|
"""
|
|
Schema for supplier information returned to clients.
|
|
"""
|
|
pass
|
|
|
|
|
|
class SupplierWithItems(SupplierInDBBase):
|
|
"""
|
|
Schema for supplier with related items.
|
|
"""
|
|
from app.schemas.item import Item
|
|
items: List[Item] = Field([], description="Items from this supplier") |