
- Created complete RESTful API for inventory management - Set up database models for items, categories, suppliers, and transactions - Implemented user authentication with JWT tokens - Added transaction tracking for inventory movements - Created comprehensive API endpoints for all CRUD operations - Set up Alembic for database migrations - Added input validation and error handling - Created detailed documentation in README
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from sqlalchemy import Column, String, Integer, Float, DateTime, Text, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Item(Base):
|
|
id = Column(String, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
sku = Column(String, index=True, unique=True, nullable=False)
|
|
quantity = Column(Integer, default=0, nullable=False)
|
|
unit_price = Column(Float, nullable=False)
|
|
location = Column(String, nullable=True)
|
|
min_stock_level = Column(Integer, default=0, nullable=True)
|
|
category_id = Column(String, ForeignKey("category.id"), nullable=True)
|
|
supplier_id = Column(String, ForeignKey("supplier.id"), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Relationships
|
|
category = relationship("Category", back_populates="items")
|
|
supplier = relationship("Supplier", back_populates="items")
|
|
transactions = relationship("Transaction", back_populates="item") |