
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from sqlalchemy import Column, Float, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Item(Base):
|
|
"""
|
|
Inventory item model for tracking products and stock.
|
|
"""
|
|
__tablename__ = "items"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
sku = Column(String, unique=True, index=True, nullable=True)
|
|
barcode = Column(String, unique=True, index=True, nullable=True)
|
|
quantity = Column(Integer, default=0, nullable=False)
|
|
unit_price = Column(Float, nullable=False)
|
|
reorder_level = Column(Integer, default=10, nullable=False)
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
|
supplier_id = Column(Integer, ForeignKey("suppliers.id"), nullable=True)
|
|
|
|
# Relationships
|
|
category = relationship("Category", back_populates="items")
|
|
supplier = relationship("Supplier", back_populates="items")
|
|
transactions = relationship("Transaction", back_populates="item") |