from sqlalchemy import Column, String, Text, Integer, Float, ForeignKey, Boolean from sqlalchemy.orm import relationship from app.db.base_class import BaseClass from app.db.base import Base class Product(Base, BaseClass): """ Product model for inventory items. """ name = Column(String(255), index=True, nullable=False) description = Column(Text, nullable=True) sku = Column(String(50), unique=True, index=True, nullable=False) barcode = Column(String(100), unique=True, index=True, nullable=True) price = Column(Float, nullable=False, default=0.0) cost = Column(Float, nullable=False, default=0.0) # Stock management min_stock_level = Column(Integer, nullable=False, default=0) is_active = Column(Boolean, default=True) # Foreign keys category_id = Column(Integer, ForeignKey("category.id"), nullable=True) supplier_id = Column(Integer, ForeignKey("supplier.id"), nullable=True) # Relationships category = relationship("Category", back_populates="products") supplier = relationship("Supplier", back_populates="products") inventory_items = relationship("Inventory", back_populates="product")