
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.
25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, DateTime, Text, Float, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base import Base
|
|
|
|
|
|
class Product(Base):
|
|
__tablename__ = "products"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(200), nullable=False, index=True)
|
|
sku = Column(String(50), unique=True, nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
price = Column(Float, nullable=False)
|
|
cost = Column(Float, nullable=True)
|
|
quantity_in_stock = Column(Integer, default=0)
|
|
minimum_stock_level = Column(Integer, default=0)
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
|
supplier_id = Column(Integer, ForeignKey("suppliers.id"), nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
category = relationship("Category", backref="products")
|
|
supplier = relationship("Supplier", backref="products")
|