gongchunyi
10 小时以前 1635bfb381b94ce4b6b195537e47775fa6e320ca
fix: 应付金额去重并扣减历史记录
已修改2个文件
59 ■■■■ 文件已修改
src/views/procurementManagement/paymentLedger/index.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/receiptPaymentLedger/index.vue 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/paymentLedger/index.vue
@@ -195,6 +195,14 @@
    const n = Number(v);
    return Number.isFinite(n) ? n : 0;
  };
  const toTime = (v) => {
    const t = new Date(v).getTime();
    return Number.isFinite(t) ? t : -Infinity;
  };
  const toId = (v) => {
    const n = Number(v);
    return Number.isFinite(n) ? n : -Infinity;
  };
  // 以当前右侧表格展示的数据为准(分页 slice 后的数据)
  const rows = originalTableDataSon.value || [];
@@ -214,7 +222,25 @@
  );
  const paymentTotal = rows.reduce((sum, r) => sum + toNum(r?.paymentAmount), 0);
  const payableTotal = rows.reduce((sum, r) => sum + toNum(r?.payableAmount), 0);
  const latestRowByContract = new Map();
  for (const r of rows) {
    const contractNo = r?.purchaseContractNumber;
    if (!contractNo) continue;
    const existed = latestRowByContract.get(contractNo);
    const currentTime = toTime(r?.paymentDate);
    const existedTime = toTime(existed?.paymentDate);
    const shouldReplace =
      !existed ||
      currentTime > existedTime ||
      (currentTime === existedTime && toId(r?.id) > toId(existed?.id));
    if (shouldReplace) {
      latestRowByContract.set(contractNo, r);
    }
  }
  const payableTotal = Array.from(latestRowByContract.values()).reduce(
    (sum, r) => sum + toNum(r?.payableAmount),
    0
  );
  const columns = param?.columns || [];
  const summary = columns.map((col, idx) => {
src/views/salesManagement/receiptPaymentLedger/index.vue
@@ -210,6 +210,14 @@
    const n = Number(v);
    return Number.isFinite(n) ? n : 0;
  };
  const toTime = (v) => {
    const t = new Date(v).getTime();
    return Number.isFinite(t) ? t : -Infinity;
  };
  const toId = (v) => {
    const n = Number(v);
    return Number.isFinite(n) ? n : -Infinity;
  };
  // 以右侧当前展示数据为准
  const rows = receiptRecord.value || [];
@@ -234,14 +242,25 @@
    0
  );
  // 应收金额保持主表当前客户口径
  let unReceiptTotal = 0;
  if (rows.length > 0) {
    const index = tableData.value.findIndex((item) => item.id == customerId.value);
    if (index > -1) {
      unReceiptTotal = toNum(tableData.value[index]?.unReceiptPaymentAmount);
  const latestRowByContract = new Map();
  for (const row of rows) {
    const contractNo = row?.salesContractNo;
    if (!contractNo) continue;
    const existed = latestRowByContract.get(contractNo);
    const currentTime = toTime(row?.receiptPaymentDate);
    const existedTime = toTime(existed?.receiptPaymentDate);
    const shouldReplace =
      !existed ||
      currentTime > existedTime ||
      (currentTime === existedTime && toId(row?.id) > toId(existed?.id));
    if (shouldReplace) {
      latestRowByContract.set(contractNo, row);
    }
  }
  const unReceiptTotal = Array.from(latestRowByContract.values()).reduce(
    (sum, row) => sum + toNum(row?.unReceiptPaymentAmount),
    0
  );
  const columns = param?.columns || [];
  return columns.map((column, index) => {