
This commit includes: - Project structure setup with FastAPI and SQLite - Database models and schemas for inventory management - CRUD operations for all entities - API endpoints for product, category, supplier, and inventory management - User authentication with JWT tokens - Initial database migration - Comprehensive README with setup instructions
98 lines
2.2 KiB
Python
98 lines
2.2 KiB
Python
from typing import Optional, List
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties for Inventory
|
|
class InventoryBase(BaseModel):
|
|
product_id: int
|
|
quantity: int = 0
|
|
location: Optional[str] = None
|
|
last_counted_at: Optional[datetime] = 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
|
|
|
|
|
|
# Properties shared by models in DB
|
|
class InventoryInDBBase(InventoryBase):
|
|
id: int
|
|
product_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Inventory(InventoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class InventoryInDB(InventoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Shared properties for InventoryTransaction
|
|
class InventoryTransactionBase(BaseModel):
|
|
product_id: int
|
|
quantity: int
|
|
transaction_type: str # purchase, sale, adjustment, return, transfer
|
|
reference: Optional[str] = None
|
|
unit_price: Optional[float] = None
|
|
notes: Optional[str] = None
|
|
transaction_date: Optional[datetime] = None
|
|
user_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive on inventory transaction creation
|
|
class InventoryTransactionCreate(InventoryTransactionBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on inventory transaction update
|
|
class InventoryTransactionUpdate(InventoryTransactionBase):
|
|
product_id: Optional[int] = None
|
|
quantity: Optional[int] = None
|
|
transaction_type: Optional[str] = None
|
|
|
|
|
|
# Properties shared by models in DB
|
|
class InventoryTransactionInDBBase(InventoryTransactionBase):
|
|
id: int
|
|
transaction_date: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class InventoryTransaction(InventoryTransactionInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class InventoryTransactionInDB(InventoryTransactionInDBBase):
|
|
pass
|
|
|
|
|
|
# Inventory summary for a product
|
|
class InventorySummary(BaseModel):
|
|
product_id: int
|
|
product_name: str
|
|
sku: str
|
|
current_stock: int
|
|
min_stock_level: int
|
|
is_low_stock: bool
|
|
|
|
|
|
# List of inventory summaries
|
|
class InventorySummaryList(BaseModel):
|
|
inventories: List[InventorySummary] |