25 lines
993 B
Python
25 lines
993 B
Python
from app.extensions import db
|
|
from datetime import datetime
|
|
|
|
|
|
class StockBuy(db.Model):
|
|
__tablename__ = 'stock_buy'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
material_id = db.Column(db.Integer, db.ForeignKey('material_base.id'), nullable=False)
|
|
inbound_date = db.Column(db.DateTime, default=datetime.now)
|
|
barcode = db.Column(db.String(100))
|
|
batch_no = db.Column(db.String(100))
|
|
|
|
# 数量相关 (使用 Numeric 对应数据库的 NUMERIC)
|
|
qty_inbound = db.Column(db.Numeric(19, 4), default=0)
|
|
qty_current = db.Column(db.Numeric(19, 4), default=0)
|
|
qty_available = db.Column(db.Numeric(19, 4), default=0)
|
|
|
|
price_unit = db.Column(db.Numeric(19, 4), default=0)
|
|
price_total = db.Column(db.Numeric(19, 4), default=0)
|
|
supplier_name = db.Column(db.String(255))
|
|
warehouse_loc = db.Column(db.String(100))
|
|
|
|
# 建立关联,方便查询物料详情
|
|
material = db.relationship('MaterialBase', backref='buy_stocks') |