yyb
2 天以前 1bd1061c60c286e3b2216a67090c4976c9c7b35f
src/pages/inventoryManagement/scanOut/scanOut.logic.ts
@@ -13,16 +13,23 @@
}
export function parseRemainingQuantity(row: AnyRow): number | null {
  const remRaw =
    row?.remainingQuantity ??
    row?.remaining_quantity ??
    row?.remainQuantity ??
    row?.remain_quantity;
  const remRaw = row?.remainingQuantity;
  return parseOptionalNumber(remRaw);
}
export function defaultStockedQuantityFromRow(row: AnyRow): string {
  const rem = parseRemainingQuantity(row);
export function parseRemainingShippedQuantity(row: AnyRow): number | null {
  const remRaw = row?.remainingShippedQuantity;
  return parseOptionalNumber(remRaw);
}
export function defaultStockedQuantityFromRow(
  row: AnyRow,
  scene: "inbound" | "outbound" = "inbound"
): string {
  const rem =
    scene === "outbound"
      ? parseRemainingShippedQuantity(row) ?? parseRemainingQuantity(row)
      : parseRemainingQuantity(row) ?? parseRemainingShippedQuantity(row);
  if (rem !== null) return String(Math.max(0, rem));
  const avail = parseOptionalNumber(row?.availableQuality ?? row?.availableQuantity);
@@ -65,9 +72,9 @@
export function buildSalesLedgerProductList(recordList: AnyRow[]): AnyRow[] {
  return recordList.map((item: AnyRow) => {
    const n = parseOptionalNumber(item.stockedQuantity);
    const n = parseOptionalNumber(item.operateQuantity);
    const qty = n !== null && !Number.isNaN(n) ? Math.max(0, n) : 0;
    const { stockedQuantity: _sq, ...rest } = item;
    const { operateQuantity: _oq, ...rest } = item;
    return { ...rest, stockedQuantity: qty };
  });
}