weaver-work-cli 0.1.46 → 0.1.47

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.
Files changed (23) hide show
  1. package/dist/chunks/{chunk-UFIFZ4YC.js → chunk-J2VEB5K3.js} +1 -1
  2. package/dist/chunks/{chunk-GR76ZDDX.js → chunk-LIEQJIGM.js} +3 -0
  3. package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-UEAHSYAE.js} +279 -1
  4. package/dist/chunks/{lazy-dispatch-DD6ULZ3I.js → lazy-dispatch-25XGTXLM.js} +2 -2
  5. package/dist/index.js +4 -4
  6. package/dist/shortcuts/invoice/host.js +3 -0
  7. package/dist/shortcuts/invoice/manifest.js +61 -0
  8. package/dist/shortcuts/invoice/operations/registry.js +2 -0
  9. package/dist/shortcuts/invoice/operations/reim-subsidy.js +233 -0
  10. package/docs/invoice.md +1 -0
  11. package/package.json +1 -1
  12. package/skills/weaver-e10-yepiaotong/SKILL.md +7 -5
  13. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
  14. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +9 -2
  15. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
  16. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
  17. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +68 -6
  18. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
  19. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +8 -15
  20. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
  21. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
  22. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +26 -21
  23. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  Command,
19
19
  clearInvoiceTokenForSession
20
- } from "./chunk-GR76ZDDX.js";
20
+ } from "./chunk-LIEQJIGM.js";
21
21
  import {
22
22
  refsDir
23
23
  } from "./chunk-AJ62BGAW.js";
@@ -3748,6 +3748,9 @@ function createInvoiceHost(ctx, dependencies = {}) {
3748
3748
  invalidateToken() {
3749
3749
  invoiceToken = null;
3750
3750
  void clearCachedInvoiceToken();
3751
+ },
3752
+ debug(message) {
3753
+ ctx.logger?.debug?.(message);
3751
3754
  }
3752
3755
  };
3753
3756
  }
@@ -8,7 +8,7 @@ import {
8
8
  invoicePartialError,
9
9
  invoiceValidationError,
10
10
  isInvoiceNetworkError
11
- } from "./chunk-GR76ZDDX.js";
11
+ } from "./chunk-LIEQJIGM.js";
12
12
  import {
13
13
  reportPlatformError
14
14
  } from "./chunk-6N4JPNFL.js";
@@ -1311,6 +1311,67 @@ var invoiceOperations = [
1311
1311
  },
1312
1312
  outputSchema: reimCandidatesOutputSchema
1313
1313
  },
1314
+ {
1315
+ name: "invoice.reim.subsidy.submit",
1316
+ risk: "high-risk-write",
1317
+ fixed: {
1318
+ path: "/api/secondev/fna/expense/reimbursement/aiCreateWf",
1319
+ autoCommit: "1",
1320
+ currentEmpId: "session.userId",
1321
+ detailList: "invoices \u6BCF\u5F20\u4E00\u884C {relatedProcessId, relatedInvoiceId, reimbursedAmount}\uFF0CrelatedProcessId \u5168\u90E8\u76F8\u540C\uFF1BreimbursedAmount \u53D6\u8BE5\u53D1\u7968 total\uFF0C\u5408\u8BA1\u4E0D\u8D85\u8FC7 monthlyAllowance\uFF0C\u8D85\u989D\u90A3\u884C\u62A5\u300C\u989D\u5EA6 \u2212 \u524D\u9762\u884C\u7D2F\u52A0\u300D\uFF0C\u989D\u5EA6\u7528\u5B8C\u540E\u5269\u4E0B\u7684\u53D1\u7968\u4E0D\u8FDB\u660E\u7EC6"
1322
+ },
1323
+ inputSchema: {
1324
+ type: "object",
1325
+ additionalProperties: false,
1326
+ required: ["processTitle", "reason", "relatedProcessId", "invoices"],
1327
+ properties: {
1328
+ processTitle: { type: "string", minLength: 1, description: "\u62A5\u9500\u6D41\u7A0B\u6807\u9898\uFF0C\u5982\u300C\u9F9A\u4E3A\u660E10\u6708\u8BDD\u8D39\u62A5\u9500\u300D" },
1329
+ reason: { type: "string", minLength: 1, description: "\u62A5\u9500\u4E8B\u7531\uFF0C\u5982\u300C10\u6708\u8BDD\u8D39\u300D" },
1330
+ relatedProcessId: { ...positiveId, description: "\u8BDD\u8D39 / \u6CB9\u8D39\u4E8B\u524D\u7533\u8BF7\u7684 requestId" },
1331
+ invoices: {
1332
+ type: "array",
1333
+ minItems: 1,
1334
+ maxItems: 100,
1335
+ description: "\u672C\u6B21\u62A5\u9500\u7684\u53D1\u7968\uFF0C\u6BCF\u5F20\u751F\u6210\u4E00\u884C\u660E\u7EC6\uFF1B\u987A\u5E8F\u5373\u989D\u5EA6\u6263\u51CF\u987A\u5E8F",
1336
+ items: {
1337
+ type: "object",
1338
+ additionalProperties: false,
1339
+ required: ["fid", "total"],
1340
+ properties: {
1341
+ fid: { ...positiveId, description: "\u7968\u5939\u53D1\u7968 fid" },
1342
+ total: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$", description: "\u8FD9\u5F20\u53D1\u7968\u7684\u4EF7\u7A0E\u5408\u8BA1\uFF08invoice.list \u7684 total\uFF09" }
1343
+ }
1344
+ }
1345
+ },
1346
+ monthlyAllowance: { type: "string", pattern: "^\\d+(\\.\\d{1,2})?$", description: "\u4E8B\u524D\u7533\u8BF7\u7684\u300C\u6708\u8865\u8D34\u989D\u5EA6\u300D\uFF1B\u4E0D\u4F20\u8868\u793A\u4E0D\u5C01\u9876" },
1347
+ customerId: { ...positiveId, default: "100504500000311504", description: "\u76F8\u5173\u5BA2\u6237 ID\uFF1B\u4E0D\u4F20\u9ED8\u8BA4\u6CDB\u5FAE\u4E0A\u6D77 100504500000311504" },
1348
+ projectId: { type: "string", pattern: "^([1-9]\\d*)?$", default: "", description: "\u76F8\u5173\u9879\u76EE ID\uFF1B\u6CA1\u6709\u6307\u5B9A\u65F6\u4E0D\u4F20\u6216\u4F20\u7A7A\u5B57\u7B26\u4E32" }
1349
+ }
1350
+ },
1351
+ outputSchema: objectSchema({
1352
+ requestId: { type: "string", description: "\u521B\u5EFA\u5E76\u63D0\u4EA4\u6210\u529F\u7684\u62A5\u9500\u6D41\u7A0B requestId" },
1353
+ url: { type: "string", description: "\u62A5\u9500\u6D41\u7A0B\u8BE6\u60C5\u9875\uFF1A{baseUrl}/sp/workflow/flowpage/view/{requestId}" },
1354
+ processTitle: { type: "string" },
1355
+ invoiceCount: { type: "integer", description: "\u5B9E\u9645\u8FDB\u5165\u660E\u7EC6\u7684\u53D1\u7968\u5F20\u6570" },
1356
+ reimbursedAmount: { type: "string", description: "\u5404\u884C reimbursedAmount \u4E4B\u548C" },
1357
+ invoiceTotal: { type: "string", description: "\u4F20\u5165\u7684\u5168\u90E8\u53D1\u7968 total \u4E4B\u548C\uFF08\u542B\u6CA1\u8FDB\u660E\u7EC6\u7684\uFF09" },
1358
+ monthlyAllowance: { type: ["string", "null"] },
1359
+ capped: { type: "boolean", description: "\u662F\u5426\u6309\u6708\u8865\u8D34\u989D\u5EA6\u5C01\u9876" },
1360
+ details: arrayOf(objectSchema({
1361
+ relatedInvoiceId: { type: "string" },
1362
+ invoiceTotal: { type: "string" },
1363
+ reimbursedAmount: { type: "string" }
1364
+ }, ["relatedInvoiceId", "invoiceTotal", "reimbursedAmount"])),
1365
+ skippedInvoices: arrayOf(objectSchema({
1366
+ relatedInvoiceId: { type: "string" },
1367
+ invoiceTotal: { type: "string" }
1368
+ }, ["relatedInvoiceId", "invoiceTotal"]), { description: "\u989D\u5EA6\u7528\u5B8C\u540E\u6CA1\u8FDB\u660E\u7EC6\u3001\u7559\u5728\u7968\u5939\u7684\u53D1\u7968" }),
1369
+ debugTrace: { type: "array", description: "\u6392\u67E5\u7528\uFF1A\u5165\u53C2\u3001\u6BCF\u884C\u91D1\u989D\u5206\u644A\u3001\u8BF7\u6C42\u4F53\u3001\u63A5\u53E3\u8FD4\u56DE" },
1370
+ finalMarkdown: { type: "string", description: "[processTitle](url)\uFF0C\u76F4\u63A5\u5C55\u793A\u7ED9\u7528\u6237" },
1371
+ result: rawObject,
1372
+ workflow: workflowSchema
1373
+ }, ["requestId", "url", "processTitle", "invoiceCount", "reimbursedAmount", "invoiceTotal", "monthlyAllowance", "capped", "details", "skippedInvoices", "finalMarkdown", "result", "workflow"])
1374
+ },
1314
1375
  {
1315
1376
  name: "invoice.issuing.contracts.list",
1316
1377
  risk: "read",
@@ -3498,6 +3559,222 @@ var InvoiceReimCandidatesListOperation = class {
3498
3559
  }
3499
3560
  };
3500
3561
 
3562
+ // src/shortcuts/invoice/operations/reim-subsidy.ts
3563
+ var SUBSIDY_SUBMIT_PATH = "/api/secondev/fna/expense/reimbursement/aiCreateWf";
3564
+ var DEFAULT_CUSTOMER_ID = "100504500000311504";
3565
+ function longId(id) {
3566
+ const rawJSON = JSON.rawJSON;
3567
+ return typeof rawJSON === "function" ? rawJSON(id) : id;
3568
+ }
3569
+ function optionalId(value, name) {
3570
+ return value === void 0 || value === null || value === "" ? "" : asPositiveString(value, name);
3571
+ }
3572
+ function amountCents2(value, name) {
3573
+ if (value === void 0 || value === null || value === "") return null;
3574
+ const text3 = typeof value === "number" ? String(value) : value;
3575
+ const match = typeof text3 === "string" ? /^(\d+)(?:\.(\d{1,2}))?$/u.exec(text3.trim()) : null;
3576
+ const cents2 = match ? Number(match[1]) * 100 + Number((match[2] ?? "").padEnd(2, "0")) : NaN;
3577
+ if (!Number.isSafeInteger(cents2) || cents2 <= 0) {
3578
+ throw invoiceValidationError("input_invalid", `${name} \u5FC5\u987B\u662F\u5927\u4E8E 0\u3001\u6700\u591A\u4E24\u4F4D\u5C0F\u6570\u7684\u91D1\u989D`);
3579
+ }
3580
+ return cents2;
3581
+ }
3582
+ function formatCents2(cents2) {
3583
+ return cents2 % 100 === 0 ? String(cents2 / 100) : (cents2 / 100).toFixed(2);
3584
+ }
3585
+ function normalizeInvoices(value) {
3586
+ if (!Array.isArray(value) || value.length === 0) throw invoiceValidationError("input_invalid", "invoices \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4");
3587
+ if (value.length > 100) throw invoiceValidationError("input_invalid", "invoices \u5355\u6B21\u6700\u591A\u652F\u6301 100 \u5F20");
3588
+ const invoices = value.map((item, index) => {
3589
+ if (!item || typeof item !== "object") throw invoiceValidationError("input_invalid", `invoices[${index}] \u5FC5\u987B\u662F {fid,total}`);
3590
+ const fid = asPositiveString(String(item.fid ?? ""), `invoices[${index}].fid`);
3591
+ const cents2 = amountCents2(item.total, `invoices[${index}].total`);
3592
+ if (cents2 === null) throw invoiceValidationError("input_invalid", `invoices[${index}].total \u5FC5\u586B\uFF1A\u8FD9\u5F20\u53D1\u7968\u7684\u4EF7\u7A0E\u5408\u8BA1`);
3593
+ return { fid, cents: cents2 };
3594
+ });
3595
+ if (new Set(invoices.map((item) => item.fid)).size !== invoices.length) {
3596
+ throw invoiceValidationError("input_invalid", "invoices \u4E0D\u80FD\u5305\u542B\u91CD\u590D fid");
3597
+ }
3598
+ return invoices;
3599
+ }
3600
+ function formatRemaining(cents2) {
3601
+ return Number.isFinite(cents2) ? formatCents2(cents2) : "\u4E0D\u5C01\u9876";
3602
+ }
3603
+ function workflowViewUrl(baseUrl, requestId) {
3604
+ return `${baseUrl.replace(/\/+$/, "")}/sp/workflow/flowpage/view/${requestId}`;
3605
+ }
3606
+ var InvoiceReimSubsidySubmitOperation = class {
3607
+ name = "invoice.reim.subsidy.submit";
3608
+ async execute(input, { host }) {
3609
+ const debugTrace = [];
3610
+ const debug = (step, detail) => {
3611
+ debugTrace.push({ step, detail });
3612
+ const message = `[${this.name}] ${step} ${typeof detail === "string" ? detail : JSON.stringify(detail)}`;
3613
+ host.debug?.(message);
3614
+ if (!process.env.NODE_TEST_CONTEXT) console.error(message);
3615
+ };
3616
+ debugger;
3617
+ const processTitle = asNonEmptyString(input.processTitle, "processTitle");
3618
+ const reason = asNonEmptyString(input.reason, "reason");
3619
+ const relatedProcessId = asPositiveString(input.relatedProcessId, "relatedProcessId");
3620
+ const invoices = normalizeInvoices(input.invoices);
3621
+ const customerId = optionalId(input.customerId, "customerId") || DEFAULT_CUSTOMER_ID;
3622
+ const projectId = optionalId(input.projectId, "projectId");
3623
+ const allowanceCents = amountCents2(input.monthlyAllowance, "monthlyAllowance");
3624
+ debug("1/5 \u5165\u53C2", {
3625
+ processTitle,
3626
+ reason,
3627
+ relatedProcessId,
3628
+ invoices: invoices.map((item) => ({ fid: item.fid, total: formatCents2(item.cents) })),
3629
+ monthlyAllowance: allowanceCents === null ? null : formatCents2(allowanceCents),
3630
+ customerId,
3631
+ projectId
3632
+ });
3633
+ let remainingCents = allowanceCents ?? Number.POSITIVE_INFINITY;
3634
+ const details = [];
3635
+ const skipped = [];
3636
+ for (const item of invoices) {
3637
+ if (remainingCents <= 0) {
3638
+ skipped.push(item);
3639
+ debug("2/5 \u989D\u5EA6\u5DF2\u7528\u5B8C\uFF0C\u4E0D\u8FDB\u660E\u7EC6", { fid: item.fid, total: formatCents2(item.cents) });
3640
+ continue;
3641
+ }
3642
+ const remainingBefore = remainingCents;
3643
+ const reimbursedCents = Math.min(item.cents, remainingCents);
3644
+ remainingCents -= reimbursedCents;
3645
+ details.push({ ...item, reimbursedCents });
3646
+ debug("2/5 \u660E\u7EC6\u884C", {
3647
+ fid: item.fid,
3648
+ total: formatCents2(item.cents),
3649
+ remainingBefore: formatRemaining(remainingBefore),
3650
+ reimbursedAmount: formatCents2(reimbursedCents),
3651
+ remainingAfter: formatRemaining(remainingCents)
3652
+ });
3653
+ }
3654
+ const relatedInvoiceIds = details.map((item) => item.fid);
3655
+ const invoiceTotalCents = invoices.reduce((sum, item) => sum + item.cents, 0);
3656
+ const reimbursedTotalCents = details.reduce((sum, item) => sum + item.reimbursedCents, 0);
3657
+ const capped = reimbursedTotalCents < invoiceTotalCents;
3658
+ debug("2/5 \u91D1\u989D\u6C47\u603B", {
3659
+ invoiceTotal: formatCents2(invoiceTotalCents),
3660
+ reimbursedAmount: formatCents2(reimbursedTotalCents),
3661
+ capped,
3662
+ detailCount: details.length,
3663
+ skippedCount: skipped.length,
3664
+ details: details.map((item) => ({
3665
+ fid: item.fid,
3666
+ total: formatCents2(item.cents),
3667
+ reimbursedAmount: formatCents2(item.reimbursedCents)
3668
+ })),
3669
+ skipped: skipped.map((item) => ({ fid: item.fid, total: formatCents2(item.cents) }))
3670
+ });
3671
+ debugger;
3672
+ const session = await host.getSession();
3673
+ const currentEmpId = asPositiveString(session.userId, "\u5F53\u524D\u4EBA\u5458 ID");
3674
+ const body = {
3675
+ autoCommit: "1",
3676
+ projectId: projectId ? longId(projectId) : "",
3677
+ customerId: longId(customerId),
3678
+ currentEmpId: longId(currentEmpId),
3679
+ processTitle,
3680
+ reason,
3681
+ detailList: details.map((item) => ({
3682
+ relatedProcessId: longId(relatedProcessId),
3683
+ relatedInvoiceId: longId(item.fid),
3684
+ reimbursedAmount: formatCents2(item.reimbursedCents)
3685
+ }))
3686
+ };
3687
+ debug("3/5 \u8BF7\u6C42\u4F53", {
3688
+ path: SUBSIDY_SUBMIT_PATH,
3689
+ autoCommit: body.autoCommit,
3690
+ processTitle: body.processTitle,
3691
+ reason: body.reason,
3692
+ currentEmpId,
3693
+ customerId,
3694
+ projectId,
3695
+ detailList: details.map((item) => ({
3696
+ relatedProcessId,
3697
+ relatedInvoiceId: item.fid,
3698
+ reimbursedAmount: formatCents2(item.reimbursedCents)
3699
+ }))
3700
+ });
3701
+ debugger;
3702
+ let result;
3703
+ try {
3704
+ result = await host.invoiceRequest({
3705
+ path: SUBSIDY_SUBMIT_PATH,
3706
+ method: "POST",
3707
+ body,
3708
+ operation: this.name,
3709
+ timeoutMs: 9e4
3710
+ });
3711
+ debug("4/5 \u63A5\u53E3\u8FD4\u56DE", result);
3712
+ debugger;
3713
+ } catch (error) {
3714
+ const failure = error;
3715
+ debug("4/5 \u8BF7\u6C42\u5F02\u5E38", { type: failure?.type, subtype: failure?.subtype, code: failure?.code, message: failure?.message });
3716
+ debugger;
3717
+ if (isInvoiceNetworkError(error)) {
3718
+ throw invoicePartialError("\u62A5\u9500\u63D0\u4EA4\u8BF7\u6C42\u53D1\u51FA\u540E\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u7981\u6B62\u81EA\u52A8\u91CD\u8BD5", {
3719
+ processTitle,
3720
+ relatedProcessId,
3721
+ relatedInvoiceIds,
3722
+ debugTrace,
3723
+ workflow: workflow(this.name, "EXECUTING")
3724
+ }, { stage: "submit" });
3725
+ }
3726
+ throw error;
3727
+ }
3728
+ const data = result?.data && typeof result.data === "object" ? result.data : {};
3729
+ const dataCode = data.code;
3730
+ if (result?.status === false || result?.fail === true || dataCode !== void 0 && Number(dataCode) !== 0) {
3731
+ debug("4/5 \u4E1A\u52A1\u5931\u8D25", { dataCode, msg: data.msg || result?.msg });
3732
+ throw new InvoiceCliError("api", "reim_subsidy_submit_failed", data.msg || result?.msg || "\u8BDD\u8D39 / \u6CB9\u8D39\u62A5\u9500\u63D0\u4EA4\u5931\u8D25", {
3733
+ code: dataCode ?? result?.code,
3734
+ details: { result, debugTrace },
3735
+ exitCode: 1
3736
+ });
3737
+ }
3738
+ const requestId = String(data.requestId ?? "").trim();
3739
+ if (!/^\d+$/u.test(requestId)) {
3740
+ throw invoicePartialError("\u62A5\u9500\u63D0\u4EA4\u63A5\u53E3\u8FD4\u56DE\u6210\u529F\u4F46\u6CA1\u6709\u6D41\u7A0B ID\uFF0C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u7981\u6B62\u81EA\u52A8\u91CD\u8BD5", {
3741
+ processTitle,
3742
+ result,
3743
+ debugTrace,
3744
+ workflow: workflow(this.name, "VERIFYING")
3745
+ }, { stage: "submit-response" });
3746
+ }
3747
+ const url = workflowViewUrl(session.baseUrl, requestId);
3748
+ debug("5/5 \u5B8C\u6210", { requestId, url });
3749
+ return {
3750
+ status: "COMPLETE",
3751
+ data: {
3752
+ requestId,
3753
+ url,
3754
+ processTitle,
3755
+ invoiceCount: relatedInvoiceIds.length,
3756
+ reimbursedAmount: formatCents2(reimbursedTotalCents),
3757
+ invoiceTotal: formatCents2(invoiceTotalCents),
3758
+ monthlyAllowance: allowanceCents === null ? null : formatCents2(allowanceCents),
3759
+ capped,
3760
+ details: details.map((item) => ({
3761
+ relatedInvoiceId: item.fid,
3762
+ invoiceTotal: formatCents2(item.cents),
3763
+ reimbursedAmount: formatCents2(item.reimbursedCents)
3764
+ })),
3765
+ skippedInvoices: skipped.map((item) => ({
3766
+ relatedInvoiceId: item.fid,
3767
+ invoiceTotal: formatCents2(item.cents)
3768
+ })),
3769
+ debugTrace,
3770
+ finalMarkdown: `[${processTitle}](${url})`,
3771
+ result,
3772
+ workflow: workflow(this.name, "COMPLETE")
3773
+ }
3774
+ };
3775
+ }
3776
+ };
3777
+
3501
3778
  // src/shortcuts/invoice/operations/update.ts
3502
3779
  var InvoiceUpdatePrepareOperation = class {
3503
3780
  name = "invoice.update.prepare";
@@ -3757,6 +4034,7 @@ function buildRegistry() {
3757
4034
  new InvoiceReimCandidatesListOperation(),
3758
4035
  new InvoiceReimEmployeeSuperiorsOperation(),
3759
4036
  new InvoiceReimFieldSearchOperation(),
4037
+ new InvoiceReimSubsidySubmitOperation(),
3760
4038
  new InvoiceIssuingContractsListOperation(),
3761
4039
  new InvoiceIssuingContractDetailOperation()
3762
4040
  ];
@@ -5,9 +5,9 @@ import {
5
5
  createProgram,
6
6
  registerCommands,
7
7
  toCommandMetadata
8
- } from "./chunk-UFIFZ4YC.js";
8
+ } from "./chunk-J2VEB5K3.js";
9
9
  import "./chunk-727FH2NI.js";
10
- import "./chunk-GR76ZDDX.js";
10
+ import "./chunk-LIEQJIGM.js";
11
11
  import "./chunk-AJ62BGAW.js";
12
12
  import "./chunk-6N4JPNFL.js";
13
13
  import "./chunk-6NXT4ICB.js";
package/dist/index.js CHANGED
@@ -7,9 +7,9 @@ import {
7
7
  firstPositionalToken,
8
8
  registerCommands,
9
9
  toCommandMetadata
10
- } from "./chunks/chunk-UFIFZ4YC.js";
10
+ } from "./chunks/chunk-J2VEB5K3.js";
11
11
  import "./chunks/chunk-727FH2NI.js";
12
- import "./chunks/chunk-GR76ZDDX.js";
12
+ import "./chunks/chunk-LIEQJIGM.js";
13
13
  import "./chunks/chunk-AJ62BGAW.js";
14
14
  import "./chunks/chunk-6N4JPNFL.js";
15
15
  import "./chunks/chunk-6NXT4ICB.js";
@@ -30,7 +30,7 @@ function lazyShortcut(definition) {
30
30
  placeholder.allowExcessArguments(true);
31
31
  placeholder.helpOption(false);
32
32
  placeholder.action(async () => {
33
- const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-DD6ULZ3I.js");
33
+ const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-25XGTXLM.js");
34
34
  await dispatchLazyShortcut(definition, shortcutMetadata());
35
35
  });
36
36
  }
@@ -40,7 +40,7 @@ var builtinShortcuts = [
40
40
  lazyShortcut({
41
41
  name: "invoice",
42
42
  description: "E10 \u4E1A\u7968\u901A\u53D1\u7968\u7BA1\u7406 CLI",
43
- load: async () => (await import("./chunks/invoice-OQP3TMKQ.js")).invoiceShortcut
43
+ load: async () => (await import("./chunks/invoice-UEAHSYAE.js")).invoiceShortcut
44
44
  }),
45
45
  lazyShortcut({
46
46
  name: "ehr",
@@ -369,5 +369,8 @@ export function createInvoiceHost(ctx, dependencies = {}) {
369
369
  invoiceToken = null;
370
370
  void clearCachedInvoiceToken();
371
371
  },
372
+ debug(message) {
373
+ ctx.logger?.debug?.(message);
374
+ },
372
375
  };
373
376
  }
@@ -931,6 +931,67 @@ export const invoiceOperations = [
931
931
  },
932
932
  outputSchema: reimCandidatesOutputSchema,
933
933
  },
934
+ {
935
+ name: 'invoice.reim.subsidy.submit',
936
+ risk: 'high-risk-write',
937
+ fixed: {
938
+ path: '/api/secondev/fna/expense/reimbursement/aiCreateWf',
939
+ autoCommit: '1',
940
+ currentEmpId: 'session.userId',
941
+ detailList: 'invoices 每张一行 {relatedProcessId, relatedInvoiceId, reimbursedAmount},relatedProcessId 全部相同;reimbursedAmount 取该发票 total,合计不超过 monthlyAllowance,超额那行报「额度 − 前面行累加」,额度用完后剩下的发票不进明细',
942
+ },
943
+ inputSchema: {
944
+ type: 'object',
945
+ additionalProperties: false,
946
+ required: ['processTitle', 'reason', 'relatedProcessId', 'invoices'],
947
+ properties: {
948
+ processTitle: { type: 'string', minLength: 1, description: '报销流程标题,如「龚为明10月话费报销」' },
949
+ reason: { type: 'string', minLength: 1, description: '报销事由,如「10月话费」' },
950
+ relatedProcessId: { ...positiveId, description: '话费 / 油费事前申请的 requestId' },
951
+ invoices: {
952
+ type: 'array',
953
+ minItems: 1,
954
+ maxItems: 100,
955
+ description: '本次报销的发票,每张生成一行明细;顺序即额度扣减顺序',
956
+ items: {
957
+ type: 'object',
958
+ additionalProperties: false,
959
+ required: ['fid', 'total'],
960
+ properties: {
961
+ fid: { ...positiveId, description: '票夹发票 fid' },
962
+ total: { type: 'string', pattern: '^\\d+(\\.\\d{1,2})?$', description: '这张发票的价税合计(invoice.list 的 total)' },
963
+ },
964
+ },
965
+ },
966
+ monthlyAllowance: { type: 'string', pattern: '^\\d+(\\.\\d{1,2})?$', description: '事前申请的「月补贴额度」;不传表示不封顶' },
967
+ customerId: { ...positiveId, default: '100504500000311504', description: '相关客户 ID;不传默认泛微上海 100504500000311504' },
968
+ projectId: { type: 'string', pattern: '^([1-9]\\d*)?$', default: '', description: '相关项目 ID;没有指定时不传或传空字符串' },
969
+ },
970
+ },
971
+ outputSchema: objectSchema({
972
+ requestId: { type: 'string', description: '创建并提交成功的报销流程 requestId' },
973
+ url: { type: 'string', description: '报销流程详情页:{baseUrl}/sp/workflow/flowpage/view/{requestId}' },
974
+ processTitle: { type: 'string' },
975
+ invoiceCount: { type: 'integer', description: '实际进入明细的发票张数' },
976
+ reimbursedAmount: { type: 'string', description: '各行 reimbursedAmount 之和' },
977
+ invoiceTotal: { type: 'string', description: '传入的全部发票 total 之和(含没进明细的)' },
978
+ monthlyAllowance: { type: ['string', 'null'] },
979
+ capped: { type: 'boolean', description: '是否按月补贴额度封顶' },
980
+ details: arrayOf(objectSchema({
981
+ relatedInvoiceId: { type: 'string' },
982
+ invoiceTotal: { type: 'string' },
983
+ reimbursedAmount: { type: 'string' },
984
+ }, ['relatedInvoiceId', 'invoiceTotal', 'reimbursedAmount'])),
985
+ skippedInvoices: arrayOf(objectSchema({
986
+ relatedInvoiceId: { type: 'string' },
987
+ invoiceTotal: { type: 'string' },
988
+ }, ['relatedInvoiceId', 'invoiceTotal']), { description: '额度用完后没进明细、留在票夹的发票' }),
989
+ debugTrace: { type: 'array', description: '排查用:入参、每行金额分摊、请求体、接口返回' },
990
+ finalMarkdown: { type: 'string', description: '[processTitle](url),直接展示给用户' },
991
+ result: rawObject,
992
+ workflow: workflowSchema,
993
+ }, ['requestId', 'url', 'processTitle', 'invoiceCount', 'reimbursedAmount', 'invoiceTotal', 'monthlyAllowance', 'capped', 'details', 'skippedInvoices', 'finalMarkdown', 'result', 'workflow']),
994
+ },
934
995
  {
935
996
  name: 'invoice.issuing.contracts.list',
936
997
  risk: 'read',
@@ -12,6 +12,7 @@ import { InvoiceListOperation } from './list.js';
12
12
  import { InvoiceOcrPreviewOperation } from './ocr-preview.js';
13
13
  import { InvoiceReimEmployeeSuperiorsOperation, InvoiceReimFieldSearchOperation, InvoiceReimFileOcrPreviewOperation, InvoiceReimRequestsListOperation, InvoiceReimWorkflowResolveOperation, } from './reim.js';
14
14
  import { InvoiceReimCandidatesListOperation } from './reim-auto.js';
15
+ import { InvoiceReimSubsidySubmitOperation } from './reim-subsidy.js';
15
16
  import { InvoiceUpdateApplyOperation, InvoiceUpdatePrepareOperation } from './update.js';
16
17
  import { InvoiceUploadOperation } from './upload.js';
17
18
  import { InvoiceUploadAndValidateOperation } from './upload-and-validate.js';
@@ -42,6 +43,7 @@ function buildRegistry() {
42
43
  new InvoiceReimCandidatesListOperation(),
43
44
  new InvoiceReimEmployeeSuperiorsOperation(),
44
45
  new InvoiceReimFieldSearchOperation(),
46
+ new InvoiceReimSubsidySubmitOperation(),
45
47
  new InvoiceIssuingContractsListOperation(),
46
48
  new InvoiceIssuingContractDetailOperation(),
47
49
  ];