fix(inbound): 直拨绑定模式 received_quantity 统一按实际入库记录量写入,多绑定明细取最后一条用于批次展示
This commit is contained in:
parent
3026465218
commit
f1fb6a7e19
@ -893,7 +893,9 @@ class InboundDirectLogService extends Service {
|
||||
const detailById = new Map(details.map(d => [ d.id, d ]));
|
||||
for (const b of pendingBindings) {
|
||||
const d = detailById.get(b.receiving_detail_id);
|
||||
if (d) bindingDetailMap.set(b.entry_item_id, d);
|
||||
if (!d) continue;
|
||||
// 多条绑定取最后一条明细信息,用于批次/生产日期/到期日期等展示字段
|
||||
bindingDetailMap.set(b.entry_item_id, d);
|
||||
}
|
||||
}
|
||||
|
||||
@ -923,21 +925,14 @@ class InboundDirectLogService extends Service {
|
||||
: (stockSummary[String(stockId)] || 0);
|
||||
if (inboundQty <= 0) continue;
|
||||
|
||||
// 判断是否为绑定模式:比较收货明细数量与入库记录数量
|
||||
// 判断是否为绑定模式:比较收货明细数量合计与入库记录数量
|
||||
const bindInfo = bindingDetailMap.get(item.id);
|
||||
let itemReceivedQty = inboundQty;
|
||||
if (bindInfo) {
|
||||
// 收货明细的实际数量
|
||||
const rdQty = Number(bindInfo.actual_quantity) || 0;
|
||||
// 该 entry_item 对应的入库记录汇总数量
|
||||
const logSumQty = itemDirectLogQtyMap[String(item.id)] || 0;
|
||||
if (rdQty > logSumQty) {
|
||||
// 收货明细数量 > 入库记录数量 → 部分入库,仅入库实际记录的数量
|
||||
itemReceivedQty = logSumQty;
|
||||
} else {
|
||||
// 收货明细数量 <= 入库记录数量 → 全部入库
|
||||
itemReceivedQty = rdQty;
|
||||
}
|
||||
// 绑定模式下 received_quantity 与库存流水保持一致:
|
||||
// 统一按实际入库记录量(inboundQty,绑定模式下即 itemDirectQty)写入,
|
||||
// 不再因收货明细 actual_quantity 较小而缩减
|
||||
itemReceivedQty = inboundQty;
|
||||
}
|
||||
|
||||
// 非绑定模式:同一 stock_id 只对第一个 entryItem 写入 received_quantity,后续写 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user