
- Set up project structure for FastAPI application - Create database models for items, categories, suppliers, and transactions - Set up Alembic for database migrations - Implement API endpoints for all entities - Add authentication with JWT tokens - Add health check endpoint - Create comprehensive README with documentation
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from sqlalchemy import Column, String, Text, Integer, Float, ForeignKey, Enum
|
|
from sqlalchemy.orm import relationship
|
|
import enum
|
|
|
|
from app.db.base import Base
|
|
from app.db.base_class import BaseModel
|
|
|
|
|
|
class TransactionType(str, enum.Enum):
|
|
"""Enum for transaction types."""
|
|
STOCK_IN = "stock_in"
|
|
STOCK_OUT = "stock_out"
|
|
ADJUSTMENT = "adjustment"
|
|
|
|
|
|
class Transaction(Base, BaseModel):
|
|
"""Transaction model for inventory movements."""
|
|
__tablename__ = "transactions"
|
|
|
|
transaction_type = Column(Enum(TransactionType), nullable=False)
|
|
quantity = Column(Integer, nullable=False)
|
|
unit_price = Column(Float, nullable=True)
|
|
reference = Column(String, nullable=True) # Invoice/PO number
|
|
notes = Column(Text, nullable=True)
|
|
|
|
# Foreign keys
|
|
item_id = Column(Integer, ForeignKey("items.id"), nullable=False)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
|
|
# Relationships
|
|
item = relationship("Item", back_populates="transactions")
|
|
user = relationship("User", back_populates="transactions") |