models.py 1.5 KB

123456789101112131415161718192021222324252627282930
  1. from sqlalchemy import Column, Integer, String, Float, DateTime, Text, func
  2. from database import Base
  3. class Inventory(Base):
  4. """库存表"""
  5. __tablename__ = "inventory"
  6. id = Column(Integer, primary_key=True, index=True, autoincrement=True, comment="序号")
  7. cInvCode = Column(String(100), nullable=False, index=True, comment="产品编码")
  8. supplier = Column(String(200), nullable=True, comment="供应商")
  9. casing_label_remark = Column(Text, nullable=True, comment="现外壳&标签&备注")
  10. batch = Column(String(100), nullable=True, comment="批次")
  11. current_remaining = Column(Float, default=0, comment="当前时间剩余")
  12. storage_location = Column(String(200), nullable=True, comment="存货地点")
  13. created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
  14. updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
  15. class TransactionLog(Base):
  16. """出入库记录表"""
  17. __tablename__ = "transaction_log"
  18. id = Column(Integer, primary_key=True, index=True, autoincrement=True)
  19. inventory_id = Column(Integer, nullable=False, index=True, comment="库存ID")
  20. cInvCode = Column(String(100), nullable=False, index=True, comment="产品编码")
  21. type = Column(String(10), nullable=False, comment="类型: in/out")
  22. quantity = Column(Float, nullable=False, comment="数量")
  23. remark = Column(Text, nullable=True, comment="备注")
  24. created_at = Column(DateTime, server_default=func.now(), comment="操作时间")