yyb
2026-05-12 38d723b6de39a6882a537a691159e40bd4c0e837
src/pages/inventoryManagement/scanOut/scanOut.logic.ts
@@ -79,6 +79,32 @@
  });
}
/**
 * 扫码整单发货:每行待发数量由台账字段算出,与用户输入无关(与 defaultStockedQuantityFromRow 出库口径一致)。
 */
export function resolveScanShipLineQuantity(row: AnyRow): number {
  const rem =
    parseRemainingShippedQuantity(row) ?? parseRemainingQuantity(row);
  if (rem !== null) return Math.max(0, rem);
  const avail = parseOptionalNumber(row?.availableQuality ?? row?.availableQuantity);
  if (avail !== null) return Math.max(0, avail);
  const qty = parseOptionalNumber(row?.quantity);
  const shipped = parseOptionalNumber(row?.shippedQuantity) ?? 0;
  if (qty !== null) return Math.max(0, qty - shipped);
  return 0;
}
export function buildScanShipProductList(recordList: AnyRow[]): AnyRow[] {
  return recordList.map((item: AnyRow) => {
    const qty = resolveScanShipLineQuantity(item);
    const { operateQuantity: _oq, ...rest } = item;
    return { ...rest, stockedQuantity: qty };
  });
}
export function hasAnyPositiveStockedQty(salesLedgerProductList: AnyRow[]): boolean {
  return salesLedgerProductList.some((p: AnyRow) => Number(p.stockedQuantity) > 0);
}