from sqlalchemy import Column, Integer, String, Float, ForeignKey, Boolean from sqlalchemy.orm import relationship from app.db.base_class import Base class Product(Base): id = Column(Integer, primary_key=True, index=True) name = Column(String, index=True, nullable=False) description = Column(String, nullable=True) sku = Column(String, index=True, unique=True, nullable=False) barcode = Column(String, index=True, unique=True, nullable=True) price = Column(Float, nullable=False) cost = Column(Float, nullable=False) 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("InventoryItem", back_populates="product") order_items = relationship("OrderItem", back_populates="product")