diff --git a/inventory-backend/app/api/v1/inbound/stock.py b/inventory-backend/app/api/v1/inbound/stock.py index 4a8a716..4d29c05 100644 --- a/inventory-backend/app/api/v1/inbound/stock.py +++ b/inventory-backend/app/api/v1/inbound/stock.py @@ -811,7 +811,11 @@ def get_drafts(): 'id': row.draft_id, 'user_id': row.user_id, 'uuid': row.uuid, - 'quantity': float(row.quantity or 1), + # ★ 不可写 `or 1`:实盘 0(货架确实空了)是合法且有信息量的值, + # 而 0 是 falsy,`0 or 1` 会把它报成 1 —— 前端「重复扫码」提示读 + # 的就是这个值,库管看到"当前实盘为 1"会以为填错而改成 1, + # 真实的盘亏就这么被抹掉了。 + 'quantity': float(row.quantity) if row.quantity is not None else 0, 'scan_time': row.scan_time.strftime('%Y-%m-%d %H:%M:%S') if row.scan_time else None, 'session_id': row.session_id, 'source_table': row.source_table, diff --git a/inventory-backend/app/models/inbound/stocktake.py b/inventory-backend/app/models/inbound/stocktake.py index a804eea..d0eb18d 100644 --- a/inventory-backend/app/models/inbound/stocktake.py +++ b/inventory-backend/app/models/inbound/stocktake.py @@ -95,7 +95,8 @@ class StocktakeDraft(db.Model): 'id': self.id, 'user_id': self.user_id, 'uuid': self.uuid, - 'quantity': float(self.quantity or 1), + # ★ 同 stock.py 的 /draft/list:0 是合法实盘值,`or 1` 会把它变成 1 + 'quantity': float(self.quantity) if self.quantity is not None else 0, 'scan_time': self.scan_time.strftime('%Y-%m-%d %H:%M:%S') if self.scan_time else None, 'session_id': self.session_id, 'source_table': self.source_table,