fix(inbound): correct date attributes for StockProduct and StockSemi in history location query
This commit is contained in:
@ -543,21 +543,21 @@ class BuyInboundService:
|
||||
# 2. 查询成品入库最新记录
|
||||
last_product = StockProduct.query.filter(
|
||||
StockProduct.base_id == base_id
|
||||
).order_by(StockProduct.in_date.desc()).first()
|
||||
).order_by(StockProduct.production_date.desc()).first()
|
||||
|
||||
# 3. 查询半成品入库最新记录
|
||||
last_semi = StockSemi.query.filter(
|
||||
StockSemi.base_id == base_id
|
||||
).order_by(StockSemi.in_date.desc()).first()
|
||||
).order_by(StockSemi.production_date.desc()).first()
|
||||
|
||||
# 比较三个表中的最新入库时间,返回最新的库位
|
||||
candidates = []
|
||||
if last_buy and last_buy.warehouse_location:
|
||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||
if last_product and last_product.warehouse_location:
|
||||
candidates.append((last_product.in_date, last_product.warehouse_location))
|
||||
candidates.append((last_product.production_date, last_product.warehouse_location))
|
||||
if last_semi and last_semi.warehouse_location:
|
||||
candidates.append((last_semi.in_date, last_semi.warehouse_location))
|
||||
candidates.append((last_semi.production_date, last_semi.warehouse_location))
|
||||
|
||||
if not candidates:
|
||||
return ""
|
||||
|
||||
@ -590,7 +590,7 @@ class ProductInboundService:
|
||||
# 1. 查询成品入库最新记录
|
||||
last_product = StockProduct.query.filter(
|
||||
StockProduct.base_id == base_id
|
||||
).order_by(StockProduct.in_date.desc()).first()
|
||||
).order_by(StockProduct.production_date.desc()).first()
|
||||
|
||||
# 2. 查询采购入库最新记录
|
||||
last_buy = StockBuy.query.filter(
|
||||
@ -600,16 +600,16 @@ class ProductInboundService:
|
||||
# 3. 查询半成品入库最新记录
|
||||
last_semi = StockSemi.query.filter(
|
||||
StockSemi.base_id == base_id
|
||||
).order_by(StockSemi.in_date.desc()).first()
|
||||
).order_by(StockSemi.production_date.desc()).first()
|
||||
|
||||
# 比较三个表中的最新入库时间,返回最新的库位
|
||||
candidates = []
|
||||
if last_product and last_product.warehouse_location:
|
||||
candidates.append((last_product.in_date, last_product.warehouse_location))
|
||||
candidates.append((last_product.production_date, last_product.warehouse_location))
|
||||
if last_buy and last_buy.warehouse_location:
|
||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||
if last_semi and last_semi.warehouse_location:
|
||||
candidates.append((last_semi.in_date, last_semi.warehouse_location))
|
||||
candidates.append((last_semi.production_date, last_semi.warehouse_location))
|
||||
|
||||
if not candidates:
|
||||
return ""
|
||||
|
||||
@ -667,7 +667,7 @@ class SemiInboundService:
|
||||
# 1. 查询半成品入库最新记录
|
||||
last_semi = StockSemi.query.filter(
|
||||
StockSemi.base_id == base_id
|
||||
).order_by(StockSemi.in_date.desc()).first()
|
||||
).order_by(StockSemi.production_date.desc()).first()
|
||||
|
||||
# 2. 查询采购入库最新记录
|
||||
last_buy = StockBuy.query.filter(
|
||||
@ -677,16 +677,16 @@ class SemiInboundService:
|
||||
# 3. 查询成品入库最新记录
|
||||
last_product = StockProduct.query.filter(
|
||||
StockProduct.base_id == base_id
|
||||
).order_by(StockProduct.in_date.desc()).first()
|
||||
).order_by(StockProduct.production_date.desc()).first()
|
||||
|
||||
# 比较三个表中的最新入库时间,返回最新的库位
|
||||
candidates = []
|
||||
if last_semi and last_semi.warehouse_location:
|
||||
candidates.append((last_semi.in_date, last_semi.warehouse_location))
|
||||
candidates.append((last_semi.production_date, last_semi.warehouse_location))
|
||||
if last_buy and last_buy.warehouse_location:
|
||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||
if last_product and last_product.warehouse_location:
|
||||
candidates.append((last_product.in_date, last_product.warehouse_location))
|
||||
candidates.append((last_product.production_date, last_product.warehouse_location))
|
||||
|
||||
if not candidates:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user