
- Setup project structure with FastAPI application - Create database models with SQLAlchemy - Configure Alembic for database migrations - Implement CRUD operations for products, categories, suppliers - Add inventory transaction functionality - Implement user authentication with JWT - Add health check endpoint - Create comprehensive documentation
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
# Shared properties
|
|
class ProductBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
sku: str
|
|
barcode: Optional[str] = None
|
|
quantity: Optional[int] = 0
|
|
unit_price: float
|
|
cost_price: Optional[float] = None
|
|
is_active: Optional[bool] = True
|
|
min_stock_level: Optional[int] = 0
|
|
max_stock_level: Optional[int] = 1000
|
|
category_id: Optional[int] = None
|
|
supplier_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class ProductCreate(ProductBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class ProductUpdate(ProductBase):
|
|
name: Optional[str] = None
|
|
sku: Optional[str] = None
|
|
unit_price: Optional[float] = None
|
|
|
|
|
|
class ProductInDBBase(ProductBase):
|
|
id: int
|
|
created_at: Optional[datetime] = None
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Product(ProductInDBBase):
|
|
pass
|
|
|
|
|
|
# Schema for inventory adjustment
|
|
class ProductAdjustment(BaseModel):
|
|
quantity: int
|
|
notes: Optional[str] = None |