wwt-certificate-tool 1.2.68 → 1.2.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <title>WWT 金蝶凭证工具 · 纯前端版 P1.2.68</title>
6
+ <title>WWT 金蝶凭证工具 · 纯前端版 P1.2.69</title>
7
7
  <style>*{box-sizing:border-box;margin:0;padding:0}
8
8
  body{font-family:"Microsoft YaHei","PingFang SC",-apple-system,Segoe UI,sans-serif;font-size:13px;color:#1f2328;background:#f4f6f9;line-height:1.6}
9
9
  h1{font-size:17px;font-weight:600}
@@ -328,7 +328,7 @@ input[data-f="field"][list^="dlGe_"]::placeholder{color:#a8861f;font-style:itali
328
328
  <div class="brand">
329
329
  <span class="logo">WWT</span>
330
330
  <div>
331
- <h1>金蝶凭证工具 <span class="ver">P1.2.68</span></h1>
331
+ <h1>金蝶凭证工具 <span class="ver">P1.2.69</span></h1>
332
332
  <div class="sub">纯前端离线版 · 双击即用 · 数据只存在本机,不上传任何服务器</div>
333
333
  </div>
334
334
  </div>
@@ -1816,7 +1816,7 @@ window.WWT_ENGINE = (function () {
1816
1816
  if (!globalExcludedUsed[curSrc]) globalExcludedUsed[curSrc] = new Set();
1817
1817
 
1818
1818
  // 命中行(同一行只归属第一条命中的规则)
1819
- const rowsIn = [];
1819
+ let rowsIn = [];
1820
1820
  for (let i = 0; i < rowsAll.length; i++) {
1821
1821
  if (usedRows[curSrc].has(i)) continue;
1822
1822
  const row = rowsAll[i];
@@ -1834,11 +1834,20 @@ window.WWT_ENGINE = (function () {
1834
1834
  }
1835
1835
  }
1836
1836
  if (!rowsIn.length) { stats.skipped.push({ rule: rule.name, why: "无条件命中行" }); continue; }
1837
- rowsIn.forEach(it => usedRows[curSrc].add(it._i));
1838
- stats.rules++; stats.rows += rowsIn.length;
1839
1837
 
1840
1838
  // 每行挂上生效 lines(分支优先)
1841
1839
  for (const it of rowsIn) it._lines = resolveEffectiveLines(rule, it.row, curSrc, idx);
1840
+ // 【P1.2.69】命中顶层条件但无有效分录行(分支未覆盖且无默认 lines)的行,不占用 usedRows,
1841
+ // 留给后续规则 / 遗漏统计,避免" silently 被吞"。
1842
+ const noLinesRows = rowsIn.filter(it => !it._lines || !it._lines.length);
1843
+ if (noLinesRows.length) {
1844
+ stats.skipped.push({ rule: rule.name, why: "命中但无有效分录行 " + noLinesRows.length + " 行" });
1845
+ }
1846
+ const effectiveRowsIn = rowsIn.filter(it => it._lines && it._lines.length);
1847
+ if (!effectiveRowsIn.length) { stats.skipped.push({ rule: rule.name, why: "无有效分录行" }); continue; }
1848
+ effectiveRowsIn.forEach(it => usedRows[curSrc].add(it._i));
1849
+ stats.rules++; stats.rows += effectiveRowsIn.length;
1850
+ rowsIn = effectiveRowsIn; // 后续分桶统一用有效行
1842
1851
 
1843
1852
  // Step A:分桶(决定几张凭证)
1844
1853
  const genMode = opts.modeOverride || rule.genMode || "一对一";
@@ -2208,11 +2217,12 @@ window.WWT_ENGINE = (function () {
2208
2217
  const out = [];
2209
2218
  const missing = [];
2210
2219
  const stats = { rules: 0, rows: 0, vouchers: 0, entries: 0, skipped: [], totalRows: 0 };
2220
+ const noLinesIdxs = new Set(); // 【P1.2.69】命中顶层条件但无有效分录行的索引
2211
2221
  if (rowsAll.length) {
2212
2222
  // 直接复用 generate 走一遍,但只跑这一条 rule;为不污染 vstart,每次都重算起始号
2213
2223
  // 这里简单实现:复制 generate 主循环的核心分桶逻辑,但只跑一条 rule
2214
2224
  const sel = new Set([r.id]);
2215
- const rowsIn = [];
2225
+ let rowsIn = [];
2216
2226
  for (let i = 0; i < rowsAll.length; i++) {
2217
2227
  if (usedRows.has(i)) continue;
2218
2228
  const row = rowsAll[i];
@@ -2232,6 +2242,19 @@ window.WWT_ENGINE = (function () {
2232
2242
  rowsIn.forEach(it => usedRows.add(it._i));
2233
2243
  stats.rules++; stats.rows += rowsIn.length;
2234
2244
  for (const it of rowsIn) it._lines = resolveEffectiveLines(r, it.row, curSrc, idx);
2245
+ // 【P1.2.69】无有效分录行的,不算真正命中,从 usedRows 移除并单独记录
2246
+ for (const it of rowsIn) {
2247
+ if (!it._lines || !it._lines.length) {
2248
+ usedRows.delete(it._i);
2249
+ noLinesIdxs.add(it._i);
2250
+ }
2251
+ }
2252
+ const effectiveRowsIn = rowsIn.filter(it => it._lines && it._lines.length);
2253
+ if (effectiveRowsIn.length) {
2254
+ stats.rules = Math.max(1, stats.rules); // 保持规则计数
2255
+ stats.rows = effectiveRowsIn.length; // 修正为有效行数
2256
+ rowsIn = effectiveRowsIn; // 后续分桶用有效行
2257
+ }
2235
2258
 
2236
2259
  const genMode = r.genMode;
2237
2260
  const gb = r.genGroupBy || "";
@@ -2386,11 +2409,12 @@ window.WWT_ENGINE = (function () {
2386
2409
  }
2387
2410
 
2388
2411
  /* ---- by_source:本源覆盖情况 ----
2389
- * 拆三段:
2412
+ * 拆四段:
2390
2413
  * candidatesMissed = 应处理子集(满足全部 = 条件)但未生成凭证 = 真正的"遗漏"
2414
+ * branchMissed = 命中顶层条件但无有效分录行(分支未覆盖且无默认 lines)
2391
2415
  * excludedRows = 源表里不满足本规则的全部 = 条件 → 按规则就不该处理,不算遗漏
2392
2416
  * neverMatchedRows = candidatesMissed(兼容旧字段名) */
2393
- const candidatesMissed = [], excludedRows = [];
2417
+ const candidatesMissed = [], branchMissed = [], excludedRows = [];
2394
2418
  let ruleExcludedCount = 0, ruleExcludedAmount = 0;
2395
2419
  let globalExcludedCount = 0, globalExcludedAmount = 0; // 【P1.2.35】
2396
2420
  for (let i = 0; i < rowsAll.length; i++) {
@@ -2421,8 +2445,14 @@ window.WWT_ENGINE = (function () {
2421
2445
  // 候选行 = 满足规则的全部 = 条件。重新判定一次而非靠 usedRows 倒推(兜底)
2422
2446
  const cand = isCandidate(row);
2423
2447
  if (cand) {
2424
- candidatesMissed.push(rec);
2425
- if (candidatesMissed.length >= 200) break;
2448
+ // 【P1.2.69】命中顶层条件但无有效分录行 → 单独归类为"分支未覆盖",而非普通遗漏
2449
+ if (noLinesIdxs.has(i)) {
2450
+ branchMissed.push(rec);
2451
+ if (branchMissed.length >= 200) break;
2452
+ } else {
2453
+ candidatesMissed.push(rec);
2454
+ if (candidatesMissed.length >= 200) break;
2455
+ }
2426
2456
  } else {
2427
2457
  excludedRows.push(rec);
2428
2458
  if (excludedRows.length >= 200) break;
@@ -2431,6 +2461,8 @@ window.WWT_ENGINE = (function () {
2431
2461
  // 漏算金额 = 应处理子集里漏命中的金额(非候选行的金额不算"遗漏",避免误报警报)
2432
2462
  let unmatchedAmt = 0;
2433
2463
  for (const r of candidatesMissed) unmatchedAmt += num(r.金额);
2464
+ let branchMissedAmt = 0;
2465
+ for (const r of branchMissed) branchMissedAmt += num(r.金额);
2434
2466
 
2435
2467
  const audit = {
2436
2468
  by_rule: [{
@@ -2447,6 +2479,8 @@ window.WWT_ENGINE = (function () {
2447
2479
  matched_amount: round2(matchedAmount),
2448
2480
  failed_amount: round2(failedAmount),
2449
2481
  missed_amount: round2(unmatchedAmt),
2482
+ branch_missed: branchMissed.length,
2483
+ branch_missed_amount: round2(branchMissedAmt),
2450
2484
  }],
2451
2485
  by_source: [{
2452
2486
  source: curSrc,
@@ -2466,6 +2500,11 @@ window.WWT_ENGINE = (function () {
2466
2500
  // 兼容旧字段(仍叫 never_matched,但其内容仅含真正应处理子集漏命中的行)
2467
2501
  never_matched: candidatesMissed.length,
2468
2502
  unmatched_amount: round2(unmatchedAmt),
2503
+ // 【P1.2.69】命中条件但无有效分录行(分支未覆盖)
2504
+ branch_missed: branchMissed.length,
2505
+ branch_missed_amount: round2(branchMissedAmt),
2506
+ branch_missed_clipped: branchMissed.length >= 200,
2507
+ branch_missed_rows: branchMissed,
2469
2508
  missing_code_count: missingCodeCount,
2470
2509
  missing_code_amount: round2(failedAmount),
2471
2510
  amount_col: amountCol,
@@ -2670,7 +2709,7 @@ const S = window.__STATE__ = {
2670
2709
  };
2671
2710
 
2672
2711
  /* ---------------- 版本 & 框架自动更新(只更新程序本身,本地数据/规则不动) ---------------- */
2673
- const WWT_VER=(function(){const raw='P1.2.68';return raw.indexOf('__WVER__')>=0?'P1.2.10':raw;})();
2712
+ const WWT_VER=(function(){const raw='P1.2.69';return raw.indexOf('__WVER__')>=0?'P1.2.10':raw;})();
2674
2713
  const UPD_URL_KEY='wwt_fe_updurl';
2675
2714
  // 默认更新源:Gitee 上本项目的 version.json(API 接口,浏览器可直接跨域读)
2676
2715
  const DEFAULT_UPD_URL='https://gitee.com/api/v5/repos/wwtmrhu/certificate-generation/contents/dist/version.json';
@@ -4657,10 +4696,11 @@ function previewRule(ruleId){
4657
4696
  const r0Matched = r0.actually_matched || 0;
4658
4697
  const r0Cand = r0.candidate_in_source || 0;
4659
4698
  const candMissed = bs.candidate_missed || 0;
4699
+ const branchMissed = bs.branch_missed || 0;
4660
4700
  const excluded = bs.excluded || 0;
4661
4701
  const coverage = r0Cand ? Math.round(r0Matched / r0Cand * 1000) / 10 : 0;
4662
- // ok:无遗漏 + 编码完整 + 真命中数 > 0
4663
- const ok = r0Matched > 0 && candMissed === 0 && (r0.missing_code_count || 0) === 0;
4702
+ // ok:无遗漏 + 无分支未覆盖 + 编码完整 + 真命中数 > 0
4703
+ const ok = r0Matched > 0 && candMissed === 0 && branchMissed === 0 && (r0.missing_code_count || 0) === 0;
4664
4704
  // warn:完全没命中(条件过严 / 数据缺映射)
4665
4705
  const bannerCls = ok ? 'ok' : (r0Matched === 0 ? 'warn' : 'err');
4666
4706
 
@@ -4674,16 +4714,18 @@ function previewRule(ruleId){
4674
4714
  ((r.genMode==='匹配汇总' || (r.genMode==='全部汇总' && r.genGroupBy && r.genGroupBy!=='单位名称'))?'(按 '+esc(r.genGroupBy||'单位名称')+')':'')+' · '+linesTxt+'</span>'+
4675
4715
  '<button class="mini" onclick="UI.closeModal()">✕ 关闭</button></div><div class="modalbd">';
4676
4716
 
4677
- // 顶部 banner:先说"覆盖率 N% + 命中数 / 应处理子集",再分别说"应处理子集漏命中" 与 "源表被规则排除"
4717
+ // 顶部 banner:先说"覆盖率 N% + 命中数 / 应处理子集",再分别说"应处理子集漏命中" / "分支未覆盖" / "源表被规则排除"
4678
4718
  h+='<div class="banner '+bannerCls+'">规则源表 <code>['+esc(r.source)+']</code> '+filterTxt+
4679
4719
  ' 源表共 <b>'+(r0.source_total||0)+'</b> 行 → 应处理的子集 <b>'+r0Cand+'</b> 行 → '+
4680
4720
  '命中 <b>'+r0Matched+'</b> 行(应处理子集覆盖率 <b>'+coverage+'%</b>)'+
4681
4721
  (candMissed?' <abbr title="满足本规则的全部 = 条件、应当命中却未生成凭证"><b style="color:#a40e26">应处理子集里漏了 '+candMissed+' 行</b></abbr>':'')+
4722
+ (branchMissed?' <abbr title="命中本规则顶层条件,但所有分支都不匹配且没有默认分录行,因此未生成凭证"><b style="color:#a40e26">分支未覆盖 '+branchMissed+' 行</b></abbr>':'')+
4682
4723
  (r0.missing_code_count?' <b style="color:#a40e26">编码缺失 '+r0.missing_code_count+' 条</b>':'')+
4683
4724
  (excluded?' <abbr title="源表里不满足本规则的全部 = 条件(付款方式≠对账S 等),按规则设计本就不该命中"><span style="color:#57606a">另有 '+excluded+' 行不满足条件</span></abbr>':'')+
4684
4725
  '<div style="margin-top:5px;font-size:12px;color:#57606a">命中金额 '+fmt(r0.matched_amount||0)+' 元 · '+
4685
4726
  '失败金额 '+fmt(r0.failed_amount||0)+' 元 · '+
4686
4727
  (candMissed?'<b style="color:#a40e26">应处理子集漏算 '+fmt(r0.missed_amount||0)+' 元</b>':'漏算金额 '+fmt(r0.missed_amount||0)+' 元')+
4728
+ (branchMissed?' · <b style="color:#a40e26">分支未覆盖金额 '+fmt(r0.branch_missed_amount||0)+' 元</b>':'')+
4687
4729
  (bs.amount_col?'(按 '+esc(bs.amount_col)+' 列汇总)':'')+'</div></div>';
4688
4730
 
4689
4731
  // 段 1:应处理子集漏命中 = 真遗漏(必显示,便于排查)
@@ -4697,7 +4739,21 @@ function previewRule(ruleId){
4697
4739
  '」在客户表里没记录;② 业务数值字段(如 实收金额)为空/为 0;③ 维度映射缺失导致 makeEntry 跳过。展开逐行查:</div>'+
4698
4740
  unmatchedTableHtml(candRows, r.source)+
4699
4741
  '</details>';
4700
- } else if(r0Matched > 0){
4742
+ }
4743
+
4744
+ // 段 1.5:命中顶层条件但无有效分录行 = 分支未覆盖(或默认 lines 为空)
4745
+ const branchRows = bs.branch_missed_rows || [];
4746
+ if(branchRows.length){
4747
+ const cap = bs.branch_missed_clipped ? '(已截断,最多显示 200 行)' : '';
4748
+ h+='<details style="margin-top:8px" open><summary style="cursor:pointer;color:#a40e26;font-weight:600">▼ 命中条件但无分支/分录匹配 <b>'+
4749
+ branchRows.length+'</b> 行(未生成凭证) '+cap+'</summary>'+
4750
+ '<div style="margin-top:6px;color:#57606a;font-size:12px">这些行满足本规则的顶层条件,但所有分支条件都不命中,且规则没有设置默认分录行,因此没有生成凭证。' +
4751
+ '请检查分支条件是否遗漏了「分类码」= E类其它 / 空白 等取值,或给规则添加默认分录行。</div>'+
4752
+ unmatchedTableHtml(branchRows, r.source)+
4753
+ '</details>';
4754
+ }
4755
+
4756
+ if(!candRows.length && !branchRows.length && r0Matched > 0){
4701
4757
  h+='<div class="banner ok" style="margin-top:8px">✅ 应处理子集全部命中,无遗漏</div>';
4702
4758
  }
4703
4759
 
package/dist/version.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "ver": "P1.2.68",
3
- "npm": "1.2.68",
4
- "url": "https://cdn.jsdelivr.net/npm/wwt-certificate-tool@1.2.68/dist/app.html",
5
- "url_unpkg": "https://unpkg.com/wwt-certificate-tool@1.2.68/dist/app.html",
6
- "url_gh": "https://api.github.com/repos/huweipei745839/certificate-generation/contents/dist/WWT%E5%87%AD%E8%AF%81%E5%B7%A5%E5%85%B7_P1.2.68.html",
7
- "note": "㉑ 【P1.2.68】修复规则编辑弹窗「+ 加条件」按钮无反应:P1.2.67 去掉全局排除的条件行逻辑下拉时,误把规则编辑器/分支的条件行逻辑下拉也一起去掉了,而 syncFormToObj 仍尝试读取该下拉,导致点击「加条件」时抛出 null 错误。本版恢复规则编辑器与分支条件行的「并且/或者」下拉,并加空值保护。"
2
+ "ver": "P1.2.69",
3
+ "npm": "1.2.69",
4
+ "url": "https://cdn.jsdelivr.net/npm/wwt-certificate-tool@1.2.69/dist/app.html",
5
+ "url_unpkg": "https://unpkg.com/wwt-certificate-tool@1.2.69/dist/app.html",
6
+ "url_gh": "https://api.github.com/repos/huweipei745839/certificate-generation/contents/dist/WWT%E5%87%AD%E8%AF%81%E5%B7%A5%E5%85%B7_P1.2.69.html",
7
+ "note": "㉒ 【P1.2.69】修复规则命中顶层条件但分支未覆盖(且无默认分录行)的行被静默吞掉:这些行不再计入「已命中/已覆盖」,也不占用 usedRows;auditRule 新增 branch_missed 统计,规则预览弹窗显式提示「命中条件但无分支/分录匹配 X 行」及金额,避免用户误以为「应处理子集全部命中」。"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wwt-certificate-tool",
3
- "version": "1.2.68",
3
+ "version": "1.2.69",
4
4
  "description": "WWT 金蝶凭证工具 · 纯前端版(离线单文件 HTML,双击即用)",
5
5
  "keywords": [
6
6
  "WWT",