
- Setup project structure with FastAPI application - Create database models with SQLAlchemy - Configure Alembic for database migrations - Implement CRUD operations for products, categories, suppliers - Add inventory transaction functionality - Implement user authentication with JWT - Add health check endpoint - Create comprehensive documentation
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Float, ForeignKey, DateTime, Text, Enum
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base_class import Base
|
|
import enum
|
|
from datetime import datetime
|
|
|
|
|
|
class TransactionType(str, enum.Enum):
|
|
PURCHASE = "purchase"
|
|
SALE = "sale"
|
|
ADJUSTMENT = "adjustment"
|
|
RETURN = "return"
|
|
TRANSFER = "transfer"
|
|
|
|
|
|
class InventoryTransaction(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
transaction_type = Column(Enum(TransactionType), nullable=False)
|
|
quantity = Column(Integer, nullable=False)
|
|
unit_price = Column(Float, nullable=True)
|
|
transaction_date = Column(DateTime, default=datetime.utcnow)
|
|
notes = Column(Text, nullable=True)
|
|
reference_number = Column(String, nullable=True)
|
|
|
|
# Foreign Keys
|
|
product_id = Column(Integer, ForeignKey("product.id"), nullable=False)
|
|
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
|
|
|
# Relationships
|
|
product = relationship("Product", back_populates="inventory_transactions")
|
|
user = relationship("User", back_populates="inventory_transactions") |