
- Set up project structure and FastAPI application - Create database models with SQLAlchemy - Implement authentication with JWT - Add CRUD operations for products, inventory, categories - Implement purchase order and sales functionality - Create reporting endpoints - Set up Alembic for database migrations - Add comprehensive documentation in README.md
41 lines
899 B
Python
41 lines
899 B
Python
from typing import Optional, List
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class InventoryBase(BaseModel):
|
|
product_id: int
|
|
quantity: int = Field(..., gt=0)
|
|
location: Optional[str] = None
|
|
|
|
|
|
# Properties to receive on inventory creation
|
|
class InventoryCreate(InventoryBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on inventory update
|
|
class InventoryUpdate(InventoryBase):
|
|
product_id: Optional[int] = None
|
|
quantity: Optional[int] = None
|
|
|
|
|
|
# Properties shared by models in DB
|
|
class InventoryInDBBase(InventoryBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return via API
|
|
class Inventory(InventoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties for inventory adjustment
|
|
class InventoryAdjustment(BaseModel):
|
|
product_id: int
|
|
quantity: int # Can be positive (add) or negative (remove)
|
|
reason: str
|
|
location: Optional[str] = None |