23 lines
685 B
Python
23 lines
685 B
Python
import uuid
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, String, DateTime, Integer, Enum, ForeignKey
|
|
from app.database import Base
|
|
import enum
|
|
|
|
|
|
class MovementType(str, enum.Enum):
|
|
IN = "IN"
|
|
OUT = "OUT"
|
|
ADJUST = "ADJUST"
|
|
|
|
|
|
class StockMovement(Base):
|
|
__tablename__ = "stock_movements"
|
|
|
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
product_id = Column(String(36), ForeignKey("products.id"), nullable=False)
|
|
type = Column(Enum(MovementType), nullable=False)
|
|
quantity = Column(Integer, nullable=False)
|
|
reason = Column(String(200), nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|