Refine Hose flow alignment for rejection targets and mid-flow modifications

This commit is contained in:
gitea committed 2026-09-15 10:19:20 +08:00
1 parent f493d5911b
commit a91f4b5f25
3 files changed
+394 -62

No files matched your search

+122 -6
View File
@@ -789,7 +789,9 @@ describe("Hose Flow Domain", () => {
const r1 = aligned.get("run-1")!;
expect(r1.eHumanAction).toBe("审批驳回");
expect(r1.eHumanComment).toBe("主管B: 发票不全缺少总经理审批,退回修改");
expect(r1.eHumanComment).toBe(
"主管B: 发票不全缺少总经理审批,退回修改\n↳ 驳回至: 提交人\n↳ 重新提交后由主管B继续审批"
);
expect(r1.operator?.name).toBe("主管B");
expect(r1.auditDrift).toBe(false);
@@ -1059,10 +1061,116 @@ describe("Hose Flow Domain", () => {
expect(r.aiDecision).toBe("备注通过");
expect(r.eHumanAction).toBe("审批驳回");
// Node prefix resolved from熊雪倩's approval node in history: 财务助理(熊雪倩): 修改附件
expect(r.eHumanComment).toBe("财务助理(熊雪倩): 修改附件");
expect(r.eHumanComment).toBe(
"财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批"
);
expect(r.auditDrift).toBe(false);
expect(r.operator?.name).toBe("熊雪倩");
});
test("B26002307 scenario: rejected to intermediate node with 样式 2-B format", () => {
const runs = [
{
id: "run-2307",
sourceDocumentSN: "B26002307",
taskMode: "assisted",
createdAt: 100000,
manualApprovalRecord: {
nodeName: "合思审批节点",
status: { type: "TERMINATED", label: "已驳回" }
},
result: { decision: "APPROVE" }
}
] as any[];
const flow = {
state: "已支付",
rawState: "paid",
history: [
{ time: 90000, action: "提交送审", rawAction: "freeflow.submit", operator: { name: "郭宝" } },
{ time: 95000, action: "自动同意", rawAction: "freeflow.autoAgree", isEbot: true, operator: { name: "Ebot" } },
{ time: 98000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "上级主管", operator: { name: "孙麓" }, comment: "同意" },
{ time: 101000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" },
{
time: 110000,
action: "审批驳回",
rawAction: "freeflow.reject",
nodeName: "财务经理",
operator: { name: "周晚容" },
comment: "修改",
rejectTargetNodeName: "财务助理",
rejectTargetOperator: { name: "熊雪倩" },
resubmitRuleText: "重新提交后由周晚容继续审批"
},
{
time: 120000,
action: "修改了单据",
rawAction: "flow.modify",
isModification: true,
nodeName: "财务助理",
operator: { name: "熊雪倩" }
},
{ time: 130000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" },
{ time: 140000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "董事长", operator: { name: "甘戈" }, comment: "同意" },
{ time: 150000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务经理", operator: { name: "周晚容" }, comment: "同意" },
{ time: 160000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "CFO", operator: { name: "张舒" }, comment: "同意" },
{ time: 170000, action: "支付成功", rawAction: "freeflow.pay", operator: { name: "高思琦" } }
]
} as any;
const aligned = alignApprovalRunsWithHoseFlow(runs, flow);
const r = aligned.get("run-2307")!;
expect(r.eHumanAction).toBe("审批驳回");
expect(r.eHumanComment).toBe(
"财务经理(周晚容): 修改\n↳ 驳回至: 财务助理(熊雪倩)\n↳ 重新提交后由周晚容继续审批"
);
expect(r.operator?.name).toBe("周晚容");
});
test("B26002144 scenario: mid-flow document modification yields 已支付 (中途修改) with modification at top", () => {
const runs = [
{
id: "run-2144",
sourceDocumentSN: "B26002144",
taskMode: "automatic",
createdAt: 92000,
manualApprovalRecord: {
status: { type: "APPROVED", label: "已支付/审批完成" }
},
result: { decision: "APPROVE" }
}
] as any[];
const flow = {
state: "已支付",
rawState: "paid",
history: [
{ time: 90000, action: "提交送审", rawAction: "freeflow.submit", operator: { name: "郭宝" } },
{ time: 95000, action: "自动同意", rawAction: "freeflow.autoAgree", isEbot: true, operator: { name: "费用标准检查" } },
{ time: 98000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "上级主管", operator: { name: "孙麓" }, comment: "同意" },
{
time: 105000,
action: "修改了单据",
rawAction: "flow.modify",
isModification: true,
nodeName: "财务助理",
operator: { name: "熊雪倩" }
},
{ time: 110000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" },
{ time: 120000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "董事长", operator: { name: "甘戈" }, comment: "同意" },
{ time: 130000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务经理", operator: { name: "周晚容" }, comment: "同意" },
{ time: 140000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "CFO", operator: { name: "张舒" }, comment: "同意" },
{ time: 150000, action: "支付成功", rawAction: "freeflow.pay", operator: { name: "高思琦" } }
]
} as any;
const aligned = alignApprovalRunsWithHoseFlow(runs, flow);
const r = aligned.get("run-2144")!;
expect(r.eHumanAction).toBe("已支付 (中途修改)");
expect(r.eHumanComment).toBe(
"1. 财务助理(熊雪倩): 修改了单据\n2. 上级主管(孙麓): 同意\n3. 财务助理(熊雪倩): 同意\n4. 董事长(甘戈): 同意\n5. 财务经理(周晚容): 同意\n6. CFO(张舒): 同意\n7. 高思琦: 支付成功"
);
});
});
describe("Pending and end-state handling", () => {
@@ -1136,7 +1244,9 @@ describe("Hose Flow Domain", () => {
{ rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" } } as any
]
);
expect(res1.comment).toBe("财务助理(熊雪倩): 修改附件");
expect(res1.comment).toBe(
"财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批"
);
expect(res1.operator?.name).toBe("熊雪倩");
const res2 = formatRejectionComment(
@@ -1147,14 +1257,18 @@ describe("Hose Flow Domain", () => {
reason: "单据超标缺少说明"
} as any
);
expect(res2.comment).toBe("财务经理(周晚容): 单据超标缺少说明");
expect(res2.comment).toBe(
"财务经理(周晚容): 单据超标缺少说明\n↳ 驳回至: 提交人\n↳ 重新提交后由周晚容继续审批"
);
const res3 = formatRejectionComment(
undefined,
undefined,
{ nodeName: "合思审批节点", rejectComment: "超额报销" }
);
expect(res3.comment).toBe("超额报销");
expect(res3.comment).toBe(
"超额报销\n↳ 驳回至: 提交人\n↳ 重新提交后继续审批"
);
expect(res3.comment).not.toContain("合思审批节点");
});
@@ -1254,7 +1368,9 @@ describe("Hose Flow Domain", () => {
const r = aligned.get("run-june-round1")!;
// Must NOT be falsely labeled as "已支付" just because Hose is currently paid!
expect(r.eHumanAction).toBe("审批驳回");
expect(r.eHumanComment).toBe("财务审批(李四): 发票模糊");
expect(r.eHumanComment).toBe(
"财务审批(李四): 发票模糊\n↳ 驳回至: 提交人\n↳ 重新提交后由李四继续审批"
);
expect(r.auditDrift).toBe(false);
});
});