Esempio n. 1
0
class Materiel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    materiel_name = db.Column(db.String(30),
                              unique=True,
                              nullable=False,
                              comment='物料名称')
    standard = db.Column(db.String(30), comment='规格')
    unit = db.Column(db.String(10), comment='单位')
    # 关联 - stock
    stocks = db.relationship('Stock', back_populates='materiel')
Esempio n. 2
0
class Stock(db.Model):
    id = db.Column(db.Integer,
                   primary_key=True,
                   mssql_identity_start=1,
                   mssql_identity_increment=2)
    price = db.Column(db.DECIMAL(6, 1), nullable=False, comment='总价')
    in_number = db.Column(db.DECIMAL(6, 1), nullable=False, comment='总量')
    # 关联 - materiel
    materiel_id = db.Column(db.Integer,
                            db.ForeignKey('materiel.id'),
                            nullable=False,
                            comment='关联物料ID')
    materiel = db.relationship('Materiel', back_populates='stocks')
    # 关联 - batch_in
    batch_ins = db.relationship('Batch_in', back_populates='stock')
Esempio n. 3
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), unique=True, nullable=False)
    password = db.Column(db.Text, nullable=False)
Esempio n. 4
0
class Batch_out(db.Model):
  id          = db.Column(db.Integer, primary_key=True)
  out_number  = db.Column(db.DECIMAL(6,1), nullable=False, comment='出库数量')
  price       = db.Column(db.DECIMAL(6,1), nullable=False, comment='出售单价')
  loss        = db.Column(db.DECIMAL(6,1), default=0, comment='损耗')
  document    = db.Column(db.String(20), comment='单据编号')
  code        = db.Column(db.String(20), comment='物料长代码')
  comment     = db.Column(db.Text, comment='备注')
  created_at  = db.Column(db.DateTime, default=datetime.utcnow, comment='出库时间')
  updated_at  = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
  delete_at   = db.Column(db.DateTime)
  # 关联 - batch_in
  batch_in_id = db.Column(db.Integer, db.ForeignKey('batch_in.id'), nullable=False, comment='关联入库批次ID')
  batch_in    = db.relationship('Batch_in', back_populates='batch_outs')
Esempio n. 5
0
class Batch_in(db.Model):
  id         = db.Column(db.Integer, primary_key=True, mssql_identity_start=2, mssql_identity_increment=2)
  serial     = db.Column(db.String, nullable=False, comment='批次序列号')
  in_number  = db.Column(db.DECIMAL(6,1), nullable=False, comment='入库数量')
  remainder  = db.Column(db.DECIMAL(6,1), nullable=False, comment='剩余库存')
  price      = db.Column(db.DECIMAL(6,1), nullable=False, comment='进货单价')
  commission = db.Column(db.DECIMAL(6,1), default=0, comment='佣金')
  comment    = db.Column(db.Text, comment='备注')
  created_at = db.Column(db.DateTime, default=datetime.utcnow, comment='入库时间')
  updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
  delete_at  = db.Column(db.DateTime)
  # 关联 - stock
  stock_id   = db.Column(db.Integer, db.ForeignKey('stock.id'), nullable=False, comment='关联库存ID')
  stock      = db.relationship('Stock', back_populates='batch_ins')
  # 关联 - batch_out
  batch_outs = db.relationship('Batch_out', back_populates='batch_in')