
Features implemented: - Product management with CRUD operations - Category and supplier management - Stock movement tracking with automatic updates - Inventory reports and analytics - SQLite database with Alembic migrations - Health monitoring endpoints - CORS configuration for API access - Comprehensive API documentation - Code quality with Ruff linting and formatting The system provides a complete backend solution for small business inventory management with proper database relationships, stock tracking, and reporting capabilities.
26 lines
810 B
Python
26 lines
810 B
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, DateTime, Text, ForeignKey, Enum
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
|
|
class MovementType(enum.Enum):
|
|
IN = "in"
|
|
OUT = "out"
|
|
ADJUSTMENT = "adjustment"
|
|
|
|
|
|
class StockMovement(Base):
|
|
__tablename__ = "stock_movements"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
product_id = Column(Integer, ForeignKey("products.id"), nullable=False)
|
|
movement_type = Column(Enum(MovementType), nullable=False)
|
|
quantity = Column(Integer, nullable=False)
|
|
reference = Column(String(100), nullable=True)
|
|
notes = Column(Text, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
product = relationship("Product", backref="stock_movements")
|