15 lines
863 B
Python
15 lines
863 B
Python
from sqlalchemy import Column, String, Integer, DateTime
|
|
from sqlalchemy.sql import func
|
|
from app.core.database.db_session import Base
|
|
|
|
class StockMovement(Base):
|
|
__tablename__ = "stock_movements"
|
|
|
|
movement_id = Column(String(26), primary_key=True)
|
|
entity_type = Column(String(20), nullable=False) # 'variant' or 'part'
|
|
entity_id = Column(String(26), nullable=False) # product variant id or part id
|
|
movement_type = Column(String(30), nullable=False) # Purchase, Sale, Repair, Adjustment, Return, Transfer, Damage
|
|
quantity = Column(Integer, nullable=False) # can be negative (outflow) or positive (inflow)
|
|
reference_type = Column(String(50), nullable=False) # e.g. Order, PurchaseOrder, RepairBooking, ManualAdjustment
|
|
reference_id = Column(String(36), nullable=False)
|
|
created_at = Column(DateTime, server_default=func.now())
|