
Features include: - User management with JWT authentication and role-based access - Inventory items with SKU/barcode tracking and stock management - Categories and suppliers organization - Inventory transactions with automatic stock updates - Low stock alerts and advanced search/filtering - RESTful API with comprehensive CRUD operations - SQLite database with Alembic migrations - Auto-generated API documentation Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Text, Float, ForeignKey, DateTime, Enum
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
class TransactionType(enum.Enum):
|
|
IN = "in"
|
|
OUT = "out"
|
|
ADJUSTMENT = "adjustment"
|
|
|
|
class InventoryTransaction(Base):
|
|
__tablename__ = "inventory_transactions"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
transaction_type = Column(Enum(TransactionType), nullable=False)
|
|
quantity = Column(Integer, nullable=False)
|
|
unit_cost = Column(Float)
|
|
total_cost = Column(Float)
|
|
reference_number = Column(String, index=True)
|
|
notes = Column(Text)
|
|
|
|
# Foreign Keys
|
|
item_id = Column(Integer, ForeignKey("inventory_items.id"), nullable=False)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
# Relationships
|
|
item = relationship("InventoryItem", back_populates="transactions")
|
|
user = relationship("User") |