入库操作
This commit is contained in:
2
app/models/__init__.py
Normal file
2
app/models/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from app.models.material import MaterialBase
|
||||
from app.models.stock import StockBuy
|
||||
0
app/models/base.py
Normal file
0
app/models/base.py
Normal file
11
app/models/material.py
Normal file
11
app/models/material.py
Normal file
@ -0,0 +1,11 @@
|
||||
from app.extensions import db
|
||||
|
||||
class MaterialBase(db.Model):
|
||||
__tablename__ = 'material_base'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
sku_code = db.Column(db.String(100), unique=True, nullable=False)
|
||||
name = db.Column(db.String(255), nullable=False)
|
||||
spec_model = db.Column(db.String(255))
|
||||
unit = db.Column(db.String(50))
|
||||
# 其他字段按需添加,入库时主要是为了外键关联
|
||||
25
app/models/stock.py
Normal file
25
app/models/stock.py
Normal file
@ -0,0 +1,25 @@
|
||||
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')
|
||||
0
app/models/system.py
Normal file
0
app/models/system.py
Normal file
0
app/models/transaction.py
Normal file
0
app/models/transaction.py
Normal file
Reference in New Issue
Block a user