
- Set up project structure with FastAPI and SQLite - Create database models for inventory management - Set up SQLAlchemy and Alembic for database migrations - Create initial database migrations - Implement CRUD operations for products, categories, suppliers - Implement stock movement tracking and inventory management - Add authentication and user management - Add API endpoints for all entities - Add health check endpoint - Update README with project information and usage instructions
45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
from pydantic import BaseModel, Field
|
|
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
|
|
category_id: Optional[str] = None
|
|
supplier_id: Optional[str] = None
|
|
cost_price: float = Field(ge=0)
|
|
selling_price: float = Field(ge=0)
|
|
reorder_level: int = Field(ge=0, default=0)
|
|
is_active: bool = True
|
|
|
|
|
|
# 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
|
|
cost_price: Optional[float] = None
|
|
selling_price: Optional[float] = None
|
|
|
|
|
|
class ProductInDBBase(ProductBase):
|
|
id: str
|
|
current_stock: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Product(ProductInDBBase):
|
|
pass |