weaver-work-cli 0.1.75 → 0.1.78
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/README.md +3 -1
- package/dist/chunks/{archive-OZJ6PYUR.js → archive-ENBSUMHV.js} +1 -1
- package/dist/chunks/{archive-oa-BHL5RK2F.js → archive-oa-7BFPQ6M5.js} +1 -1
- package/dist/chunks/{asset-HKRFRQR2.js → asset-V5SUD3PW.js} +1 -1
- package/dist/chunks/{asset-idle-GGIR4KE7.js → asset-idle-3CEL7WFX.js} +1 -1
- package/dist/chunks/{attachment-content-4OV65NK5.js → attachment-content-TFOC3Y3X.js} +3 -3
- package/dist/chunks/{blog-HYDP4DV3.js → blog-FLI4SS3P.js} +1 -1
- package/dist/chunks/{caizhilian-JS4RQZ6Z.js → caizhilian-7WCTKCCP.js} +3 -3
- package/dist/chunks/{calendar-SWRY4DIT.js → calendar-G726HUUH.js} +1 -1
- package/dist/chunks/{chunk-5ZJGPEIB.js → chunk-2KW7AI6P.js} +1 -1
- package/dist/chunks/{chunk-JOY3HZXL.js → chunk-2UV4IZIT.js} +21 -15
- package/dist/chunks/{chunk-FEZK536Z.js → chunk-4PBN7NJY.js} +353 -43
- package/dist/chunks/{chunk-VOMDD2C5.js → chunk-5E2FDXBU.js} +1 -1
- package/dist/chunks/{chunk-ZUB4M4N3.js → chunk-5VQ7JHV4.js} +134 -49
- package/dist/chunks/{chunk-I6NOHKEK.js → chunk-7SQN5IZR.js} +1 -1
- package/dist/chunks/{chunk-4FCBEWNB.js → chunk-BP7BONZO.js} +675 -86
- package/dist/chunks/{chunk-U6Y32KEV.js → chunk-BWFCTE43.js} +1 -1
- package/dist/chunks/{chunk-PG5YSNYY.js → chunk-DACQKJ6O.js} +3 -3
- package/dist/chunks/{chunk-KWJEICD4.js → chunk-E2EY3DMS.js} +2 -2
- package/dist/chunks/{chunk-KEA4XQPO.js → chunk-FAC4IFGQ.js} +4 -4
- package/dist/chunks/{chunk-MXCRKXOP.js → chunk-FPWCCRKT.js} +1 -1
- package/dist/chunks/{minute-doc-OQUMDTKG.js → chunk-IBTGXLOT.js} +101 -18
- package/dist/chunks/{chunk-OJ4JPD25.js → chunk-LQLIXBJF.js} +6 -8
- package/dist/chunks/{chunk-BNKUHN4N.js → chunk-OVTCWLNQ.js} +2 -2
- package/dist/chunks/{chunk-5D2V7ZAN.js → chunk-PMRNIGKZ.js} +1 -1
- package/dist/chunks/{chunk-OQCK5SAU.js → chunk-RVEKGVZU.js} +1 -1
- package/dist/chunks/{chunk-2AUFKU2D.js → chunk-SWFTWNWL.js} +11 -11
- package/dist/chunks/{chunk-TA2RBUTH.js → chunk-TBCKK6LH.js} +1 -1
- package/dist/chunks/{chunk-SU6IJD6D.js → chunk-TD5IOEGN.js} +1 -1
- package/dist/chunks/{chunk-J7FAAHWH.js → chunk-UDBQJLQF.js} +1 -1
- package/dist/chunks/{chunk-BSR5TM7U.js → chunk-USYFVIUR.js} +22 -7
- package/dist/chunks/{chunk-ERZY6GYL.js → chunk-UZ2E3VNI.js} +1 -1
- package/dist/chunks/{chunk-NWYHCZTY.js → chunk-VNEU7OUN.js} +1 -1
- package/dist/chunks/{chunk-5QUTQHXF.js → chunk-WNFDR5PC.js} +198 -80
- package/dist/chunks/{chunk-LJI4N6FV.js → chunk-XNN5PZTI.js} +1 -1
- package/dist/chunks/{chunk-QJWVYOOV.js → chunk-Z44YFIN6.js} +2 -2
- package/dist/chunks/{chunk-ZWIMLT6P.js → chunk-ZOTXXGUM.js} +7 -7
- package/dist/chunks/{cli-FULPXIKJ.js → cli-WA7FOQKC.js} +35 -35
- package/dist/chunks/{commands-BNWFNTD3.js → commands-J52MJ6NF.js} +3 -3
- package/dist/chunks/{conflict-5BKCDV2F.js → conflict-D4GVAURN.js} +2 -2
- package/dist/chunks/{contract-WI23OXVC.js → contract-GW7US3UF.js} +4400 -3548
- package/dist/chunks/{cowork-DZBBVNMQ.js → cowork-GZDODGKF.js} +1 -1
- package/dist/chunks/{create-flow-7ZRBRKX7.js → create-flow-ERDGW3FZ.js} +10 -6
- package/dist/chunks/{data-PAZVE6QE.js → data-HTQZRPPI.js} +1 -1
- package/dist/chunks/{ebuilder-form-5SQXIGXN.js → ebuilder-form-GHNIZ7ET.js} +2 -2
- package/dist/chunks/{ehr-CX5F4ZAU.js → ehr-P6T7OAAV.js} +2 -2
- package/dist/chunks/{entry-mode-I2BYNONZ.js → entry-mode-SQU5WTX6.js} +3 -3
- package/dist/chunks/{env-ZAQZ7EHN.js → env-DASBNSEM.js} +2 -2
- package/dist/chunks/{esb-DQTXDIBF.js → esb-ATRKVHCD.js} +3 -3
- package/dist/chunks/{factory-XRI6KZ7H.js → factory-A3NAKZAA.js} +1 -1
- package/dist/chunks/{fna-FK6HQVJL.js → fna-IKYI3SST.js} +1 -1
- package/dist/chunks/{group-chat-MLWNYM2P.js → group-chat-7SEAVAJR.js} +3 -3
- package/dist/chunks/{host-MEC4VQZA.js → host-6UOXYOOY.js} +2 -2
- package/dist/chunks/{host-KUMU3DDK.js → host-EJSJSLVK.js} +2 -2
- package/dist/chunks/{host-3EPREGXS.js → host-EYNLB6S4.js} +2 -2
- package/dist/chunks/{host-T6NNQGVZ.js → host-OT4KNR3G.js} +2 -2
- package/dist/chunks/{host-VI7Q45PM.js → host-UY4LQPN4.js} +2 -2
- package/dist/chunks/{host-J74JGYAW.js → host-XXGDQM7D.js} +2 -2
- package/dist/chunks/{hrm-KKVAW4P5.js → hrm-5JQ7QZ6A.js} +2 -2
- package/dist/chunks/{im-47CIWQNL.js → im-2YJW3EI5.js} +2 -2
- package/dist/chunks/{invoice-CDYRBNIG.js → invoice-37HR6L3W.js} +937 -552
- package/dist/chunks/{jiuchuanhui-M7QTRHZK.js → jiuchuanhui-KBWUZ7WT.js} +1 -1
- package/dist/chunks/{lazy-dispatch-FKQJZFI5.js → lazy-dispatch-ZDKLS5MR.js} +6 -6
- package/dist/chunks/{mail-NRBS5N6Y.js → mail-YBKUM6HM.js} +1 -1
- package/dist/chunks/{meeting-WC5LD3IO.js → meeting-7AEQGBAT.js} +19 -13
- package/dist/chunks/minute-doc-REI6RUE4.js +20 -0
- package/dist/chunks/{okr-EHKSKMPL.js → okr-HW7IULIR.js} +1 -1
- package/dist/chunks/{operations-V5VM5MS2.js → operations-4P2UYVLH.js} +3 -3
- package/dist/chunks/{performance-ZJADXJPN.js → performance-PM2G6L3E.js} +1 -1
- package/dist/chunks/{plan-OTDNBDJ7.js → plan-3YYGZ7ZM.js} +1 -1
- package/dist/chunks/{project-4XVBQ3HX.js → project-6PRGBLO2.js} +39 -15
- package/dist/chunks/{reception-3FAHOOH7.js → reception-7G3J2MA6.js} +1 -1
- package/dist/chunks/{recruit-stage-3WTVWW2K.js → recruit-stage-TLZJUFHD.js} +544 -464
- package/dist/chunks/{registry-TJGCVRCW.js → registry-3VTB3KLV.js} +3 -3
- package/dist/chunks/{registry-F4YFZLOD.js → registry-KQ4TNUWO.js} +1 -1
- package/dist/chunks/{registry-NBTBXR4L.js → registry-UVTI323K.js} +12 -11
- package/dist/chunks/{room-recommend-KL62XB2Y.js → room-recommend-ELEJUYBN.js} +4 -4
- package/dist/chunks/{schedule-XOISYUPB.js → schedule-XBKY7VEA.js} +4 -4
- package/dist/chunks/{smart-extract-UYGNV3BM.js → smart-extract-T5Z4AULN.js} +1 -1
- package/dist/chunks/{update-AV5VOXGY.js → update-77ZUIYSG.js} +2 -2
- package/dist/chunks/{workflow-V54LJPXL.js → workflow-SYCBS5XD.js} +3 -3
- package/dist/index.js +3 -3
- package/dist/internal/update/service.js +9 -8
- package/dist/shortcuts/contract/data/collection-ledger-html.js +109 -33
- package/dist/shortcuts/contract/data/collection-node-catalog.js +26 -2
- package/dist/shortcuts/contract/data/report-renderers.js +75 -31
- package/dist/shortcuts/contract/data/report-spec.js +17 -3
- package/dist/shortcuts/contract/manifest.js +20 -3
- package/dist/shortcuts/contract/operations/bizreview-report.js +23 -2
- package/dist/shortcuts/contract/operations/collection-node.js +116 -1
- package/dist/shortcuts/contract/operations/compare-report.js +27 -5
- package/dist/shortcuts/contract/operations/credit-page.js +11 -2
- package/dist/shortcuts/contract/operations/docx-slots.js +27 -2
- package/dist/shortcuts/contract/operations/draft-submit.js +9 -6
- package/dist/shortcuts/contract/operations/elements-build.js +162 -30
- package/dist/shortcuts/contract/operations/elements-spec.js +50 -0
- package/dist/shortcuts/contract/operations/generated-submit.js +35 -0
- package/dist/shortcuts/contract/operations/ledger-card.js +32 -2
- package/dist/shortcuts/contract/operations/ledger-stat.js +17 -5
- package/dist/shortcuts/contract/operations/ledger.js +88 -16
- package/dist/shortcuts/contract/operations/metrics.js +16 -3
- package/dist/shortcuts/contract/operations/ops-draft.js +359 -27
- package/dist/shortcuts/contract/operations/page.js +23 -0
- package/dist/shortcuts/contract/operations/quote-recognize.js +91 -13
- package/dist/shortcuts/contract/operations/quote-submit.js +16 -0
- package/dist/shortcuts/contract/operations/review-report.js +11 -3
- package/dist/shortcuts/contract/operations/save-recognize.js +62 -1
- package/dist/shortcuts/contract/operations/triage.js +18 -3
- package/dist/shortcuts/contract/operations/viewlink.js +17 -1
- package/dist/shortcuts/ehr/operations/recruit.js +255 -90
- package/dist/shortcuts/invoice/business-response.js +13 -0
- package/dist/shortcuts/invoice/calendar.js +24 -0
- package/dist/shortcuts/invoice/host.js +26 -15
- package/dist/shortcuts/invoice/index.js +2 -2
- package/dist/shortcuts/invoice/invoice-record.js +7 -2
- package/dist/shortcuts/invoice/manifest.js +179 -155
- package/dist/shortcuts/invoice/operations/get.js +9 -3
- package/dist/shortcuts/invoice/operations/issuing-red-requests.js +138 -0
- package/dist/shortcuts/invoice/operations/registry.js +4 -5
- package/dist/shortcuts/invoice/operations/reim-auto.js +40 -2
- package/dist/shortcuts/invoice/operations/reim-customer-projects.js +79 -0
- package/dist/shortcuts/invoice/operations/reim-customer.js +79 -30
- package/dist/shortcuts/invoice/operations/reim-relation.js +0 -146
- package/dist/shortcuts/invoice/operations/reim.js +2 -126
- package/dist/shortcuts/invoice/operations/shared.js +15 -17
- package/dist/shortcuts/invoice/preapproval-enrichment.js +180 -0
- package/dist/shortcuts/invoice/projection.js +14 -0
- package/dist/shortcuts/invoice/read-enrichment.js +123 -0
- package/dist/shortcuts/meeting/confirm-gate.js +42 -0
- package/dist/shortcuts/meeting/continuation.js +6 -2
- package/dist/shortcuts/meeting/minute-doc.js +119 -12
- package/dist/shortcuts/meeting/operations/attachment.js +19 -0
- package/dist/shortcuts/meeting/operations/compose-outcome.js +24 -2
- package/dist/shortcuts/meeting/operations/eb/conflict.js +2 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +162 -19
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +22 -3
- package/dist/shortcuts/meeting/operations/group-share.js +268 -0
- package/dist/shortcuts/meeting/operations/minute-content.js +58 -1
- package/dist/shortcuts/meeting/operations/minute-export.js +295 -0
- package/dist/shortcuts/meeting/operations/registry.js +4 -0
- package/dist/shortcuts/project/operations/read.js +40 -15
- package/dist/shortcuts/recruit-stage/context.js +16 -81
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +89 -53
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +15 -5
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +46 -108
- package/dist/shortcuts/recruit-stage/operations/list.js +203 -74
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -85
- package/dist/shortcuts/recruit-stage/operations/search.js +113 -53
- package/dist/shortcuts/recruit-stage/shared.js +153 -4
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/operations/form.js +11 -0
- package/dist/shortcuts/workflow/operations/read.js +24 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +2 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +2 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +28 -4
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.node.js +198 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subordinate.js +70 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/workflowClarification.js +15 -5
- package/docs/agent-invoice.md +28 -2
- package/docs/invoice.md +60 -9
- package/docs/project.md +1 -1
- package/package.json +1 -1
- package/skill-template/domains/yepiaotong.md +36 -7
- package/skills/weaver-e10-jinchengda/SKILL.md +64 -28
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +26 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +9 -8
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +47 -52
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +7 -1
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -12
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +44 -1
- package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +8 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +33 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +17 -3
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +12 -12
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +18 -10
- package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +77 -37
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +7 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +55 -12
- package/skills/weaver-e10-jinchengda/references/contract-review-todo.md +102 -0
- package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +1 -17
- package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +11 -8
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +2 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +6 -6
- package/skills/weaver-e10-meeting/SKILL.md +203 -80
- package/skills/weaver-e10-meeting/references/create-quickstart.md +98 -0
- package/skills/weaver-e10-meeting/references/delivery-checklist.md +34 -0
- package/skills/weaver-e10-meeting/references/error-codes.md +44 -0
- package/skills/weaver-e10-meeting/references/minutes-pipeline.md +56 -3
- package/skills/weaver-e10-meeting/references/room-recommend.md +2 -0
- package/skills/weaver-e10-recruit-stage/SKILL.md +158 -146
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +64 -51
- package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +56 -18
- package/skills/weaver-e10-recruit-stage/lib/recruit-attach-probe.mjs +127 -0
- package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +217 -30
- package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +39 -7
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +2 -2
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +10 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +18 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +29 -31
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +2 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +4 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +19 -20
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +3 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +10 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +4 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +21 -25
- package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +19 -7
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +31 -58
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +3 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +2 -2
- package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +2 -2
- package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +1 -1
- package/skills/weaver-e10-recruit-stage/templates/match-report.html +25 -15
- package/skills/weaver-e10-shijingran/SKILL.md +2 -2
- package/skills/weaver-e10-shijingran/references/operations.md +5 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
- package/skills/weaver-e10-workflow/SKILL.md +13 -9
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +33 -8
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +19 -14
- package/skills/weaver-e10-workflow/references/workflow-create.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +4 -2
- package/skills/weaver-e10-workflow/references/workflow-view.md +3 -3
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +132 -42
- package/skills/weaver-e10-yepiaotong/SKILL.md +133 -61
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +18 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +3 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-download.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +13 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +6 -4
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +42 -45
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +18 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +14 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-red-workflow.md +96 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +56 -369
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +16 -6
- package/skills/weaver-e10-yepiaotong/references/name-fuzzy-search.md +38 -0
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +163 -646
- package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +90 -44
- package/skills/weaver-e10-yepiaotong/references/reim-eligibility-rules.md +85 -0
- package/skills/weaver-e10-yepiaotong/references/reim-fill-validation.md +61 -0
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +91 -280
- package/skills/weaver-e10-yepiaotong/references/reim-preapproval-rules.md +98 -0
- package/skills/weaver-e10-yepiaotong/references/reim-travel-invoice-matching.md +48 -0
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +234 -695
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +395 -204
- package/skills/weaver-e10-yepiaotong/references/travel-application-fill.md +84 -0
- package/skills/weaver-e10-yepiaotong/references/workflow-direct-fill.md +165 -0
- package/templates/meeting/minute.docx +0 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +0 -93
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +0 -774
- package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +0 -111
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +0 -360
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +0 -167
|
@@ -19,26 +19,6 @@ const RELATION_FIELD = {
|
|
|
19
19
|
projectName: '1336526894274510992',
|
|
20
20
|
preApproval: '1336156560590790875',
|
|
21
21
|
};
|
|
22
|
-
const RELATION_SEARCH_PAGE_SIZE = 20;
|
|
23
|
-
const CUSTOMER_SEARCH_PATH = '/api/ebuilder/coms/nlist/getData';
|
|
24
|
-
const CUSTOMER_SEARCH_PAGE_ID = '1218181956452048911';
|
|
25
|
-
const CUSTOMER_SEARCH_COMP_ID = 'c39b9e14c0034336adf9e9bc39aeed75';
|
|
26
|
-
const CUSTOMER_SEARCH_WORKFLOW_ID = '100003460000000060';
|
|
27
|
-
const CUSTOMER_OBJ_ID = '1173221220888059964';
|
|
28
|
-
/** 客户表「名称」字段 id,返回行里也用它作客户名称的键。 */
|
|
29
|
-
const CUSTOMER_NAME_FIELD = '1173221220888062665';
|
|
30
|
-
const PROJECT_SEARCH_PATH = '/api/ebuilder/form/common/browser/data/ebuilder';
|
|
31
|
-
/** 项目浏览框「项目名称」列的 id,快速搜索用 `field_` 前缀。 */
|
|
32
|
-
const PROJECT_NAME_FIELD = '1020275734718578690';
|
|
33
|
-
const PROJECT_FORM_PARAM = JSON.stringify({
|
|
34
|
-
formId: '100003660000000007',
|
|
35
|
-
layoutId: '925333107626672135',
|
|
36
|
-
fieldId: '100003720000006720',
|
|
37
|
-
filterItems: [],
|
|
38
|
-
module: 'workflow',
|
|
39
|
-
dataDetails: [],
|
|
40
|
-
templateId: '',
|
|
41
|
-
});
|
|
42
22
|
/** 浏览按钮展示名末尾的摘要,如「 (相关客户:, 相关项目:, 起始日期:…)」,不属于流程标题。 */
|
|
43
23
|
const BROWSE_SUMMARY_SUFFIX = /\s+\([^()]*[::][^()]*\)\s*$/u;
|
|
44
24
|
function asRecord(value) {
|
|
@@ -274,132 +254,6 @@ async function relationRows(host, fid, operation) {
|
|
|
274
254
|
throw new Error(`发票 ${fid} 的关联信息返回缺少 data.list`);
|
|
275
255
|
return list;
|
|
276
256
|
}
|
|
277
|
-
function relationSearchTarget(value) {
|
|
278
|
-
if (value === 'customer' || value === 'project')
|
|
279
|
-
return value;
|
|
280
|
-
throw invoiceValidationError('input_invalid', 'target 只能是 customer(相关客户)或 project(相关项目)');
|
|
281
|
-
}
|
|
282
|
-
function customerFilter(keywords) {
|
|
283
|
-
return [
|
|
284
|
-
{
|
|
285
|
-
conditionType: 'or',
|
|
286
|
-
dataType: 'field',
|
|
287
|
-
id: 'd030a0a7b33e48e697277d30086126dc',
|
|
288
|
-
conditionComId: `${CUSTOMER_SEARCH_COMP_ID}_quick_EXCLUDECACHE`,
|
|
289
|
-
filterFields: [{
|
|
290
|
-
compId: CUSTOMER_SEARCH_COMP_ID,
|
|
291
|
-
compType: 'Text',
|
|
292
|
-
dataset: {
|
|
293
|
-
isPhysical: true,
|
|
294
|
-
ebuilderDataConfig: { dataSetup: {}, type: 'FORM' },
|
|
295
|
-
detailTable: false,
|
|
296
|
-
groupId: 'weaver-ebuilder-form-service',
|
|
297
|
-
usage: 'all',
|
|
298
|
-
appId: '980180677416657173',
|
|
299
|
-
id: CUSTOMER_OBJ_ID,
|
|
300
|
-
text: '客户',
|
|
301
|
-
type: 'LOGIC',
|
|
302
|
-
objType: 'physical',
|
|
303
|
-
},
|
|
304
|
-
fieldName: `field_${CUSTOMER_NAME_FIELD}`,
|
|
305
|
-
id: CUSTOMER_NAME_FIELD,
|
|
306
|
-
objId: CUSTOMER_OBJ_ID,
|
|
307
|
-
type: 'String',
|
|
308
|
-
text: '名称',
|
|
309
|
-
}],
|
|
310
|
-
value: keywords,
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
conditionComId: `${CUSTOMER_SEARCH_COMP_ID}_filter_EXCLUDECACHE`,
|
|
314
|
-
conditionType: 'and',
|
|
315
|
-
dataType: 'classification',
|
|
316
|
-
id: 'f27488c792f44756b7ef1065f7735fc1',
|
|
317
|
-
useConfig: true,
|
|
318
|
-
},
|
|
319
|
-
];
|
|
320
|
-
}
|
|
321
|
-
async function searchCustomers(host, keywords, operation) {
|
|
322
|
-
const result = await host.invoiceMultipartRequest({
|
|
323
|
-
path: CUSTOMER_SEARCH_PATH,
|
|
324
|
-
method: 'POST',
|
|
325
|
-
headers: { ebbusinessid: CUSTOMER_SEARCH_PAGE_ID },
|
|
326
|
-
fields: {
|
|
327
|
-
workflowId: CUSTOMER_SEARCH_WORKFLOW_ID,
|
|
328
|
-
isCreate: '1',
|
|
329
|
-
filter: customerFilter(keywords),
|
|
330
|
-
compId: CUSTOMER_SEARCH_COMP_ID,
|
|
331
|
-
pageId: CUSTOMER_SEARCH_PAGE_ID,
|
|
332
|
-
pageNo: '1',
|
|
333
|
-
pageSize: String(RELATION_SEARCH_PAGE_SIZE),
|
|
334
|
-
},
|
|
335
|
-
operation,
|
|
336
|
-
});
|
|
337
|
-
assertBusinessSuccess(result, 'reim_relation_search_failed', '搜索相关客户失败');
|
|
338
|
-
const list = asRecord(asRecord(result).data).list;
|
|
339
|
-
return (Array.isArray(list) ? list : []).map((row) => {
|
|
340
|
-
const record = asRecord(row);
|
|
341
|
-
return { id: text(record.id), name: text(record[CUSTOMER_NAME_FIELD]) };
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
async function searchProjects(host, keywords, operation) {
|
|
345
|
-
const result = await host.invoiceRequest({
|
|
346
|
-
path: PROJECT_SEARCH_PATH,
|
|
347
|
-
method: 'POST',
|
|
348
|
-
body: {
|
|
349
|
-
browserMultiple: false,
|
|
350
|
-
current: 1,
|
|
351
|
-
pageSize: RELATION_SEARCH_PAGE_SIZE,
|
|
352
|
-
quickSearchDatas: { [`field_${PROJECT_NAME_FIELD}`]: keywords },
|
|
353
|
-
formParam: PROJECT_FORM_PARAM,
|
|
354
|
-
},
|
|
355
|
-
operation,
|
|
356
|
-
});
|
|
357
|
-
assertBusinessSuccess(result, 'reim_relation_search_failed', '搜索相关项目失败');
|
|
358
|
-
const rows = asRecord(asRecord(result).data).data;
|
|
359
|
-
return (Array.isArray(rows) ? rows : [])
|
|
360
|
-
.map(asRecord)
|
|
361
|
-
.filter((row) => row.disabled !== true)
|
|
362
|
-
.map((row) => ({ id: text(row.id), name: text(row.content) || text(row[PROJECT_NAME_FIELD]) }));
|
|
363
|
-
}
|
|
364
|
-
function uniqueValidItems(items) {
|
|
365
|
-
const seen = new Set();
|
|
366
|
-
return items.filter((item) => {
|
|
367
|
-
if (!/^\d+$/u.test(item.id) || !item.name || seen.has(item.id))
|
|
368
|
-
return false;
|
|
369
|
-
seen.add(item.id);
|
|
370
|
-
return true;
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* 上传发票登记关联信息时,按用户说的名称模糊搜索相关客户 / 相关项目,只返回 id 和名称。
|
|
375
|
-
* 不依赖报销表单:客户走客户列表,项目走项目浏览框。
|
|
376
|
-
*/
|
|
377
|
-
export class InvoiceReimRelationSearchOperation {
|
|
378
|
-
name = 'invoice.reim.relation.search';
|
|
379
|
-
async execute(input, { host }) {
|
|
380
|
-
const target = relationSearchTarget(input.target);
|
|
381
|
-
const keywords = optionalText(input.keywords, 'keywords');
|
|
382
|
-
if (!keywords)
|
|
383
|
-
throw invoiceValidationError('input_invalid', 'keywords 必须是非空字符串');
|
|
384
|
-
const found = target === 'customer'
|
|
385
|
-
? await searchCustomers(host, keywords, this.name)
|
|
386
|
-
: await searchProjects(host, keywords, this.name);
|
|
387
|
-
const items = uniqueValidItems(found);
|
|
388
|
-
const exact = items.filter((item) => item.name === keywords);
|
|
389
|
-
const match = items.length === 0 ? 'none' : items.length === 1 ? 'unique' : 'multiple';
|
|
390
|
-
return {
|
|
391
|
-
status: 'COMPLETE',
|
|
392
|
-
data: {
|
|
393
|
-
target,
|
|
394
|
-
keywords,
|
|
395
|
-
match,
|
|
396
|
-
items,
|
|
397
|
-
selected: items.length === 1 ? items[0] : exact.length === 1 ? exact[0] : null,
|
|
398
|
-
workflow: workflow(this.name, 'COMPLETE'),
|
|
399
|
-
},
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
257
|
/**
|
|
404
258
|
* AI 报销时按发票读回上传时登记的相关客户 / 相关项目 / 事前申请。
|
|
405
259
|
* 单张查询失败记在 failed 里,不抛错;调用方按「没有登记」处理。
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { InvoiceCliError, invoiceValidationError } from '../errors.js';
|
|
2
|
+
import { addCalendarDays, addCalendarMonths, shanghaiCalendarDate } from '../calendar.js';
|
|
3
|
+
export { addCalendarDays, addCalendarMonths, shanghaiCalendarDate } from '../calendar.js';
|
|
2
4
|
import { asNonEmptyString, assertBusinessSuccess, normalizeIdList, workflow, } from './shared.js';
|
|
3
5
|
function integerInput(value, name, options = {}) {
|
|
4
6
|
const min = options.min ?? 1;
|
|
@@ -24,30 +26,6 @@ function optionalDate(value, name) {
|
|
|
24
26
|
}
|
|
25
27
|
return text;
|
|
26
28
|
}
|
|
27
|
-
function formatUtcDate(date) {
|
|
28
|
-
const y = date.getUTCFullYear();
|
|
29
|
-
const m = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
30
|
-
const d = String(date.getUTCDate()).padStart(2, '0');
|
|
31
|
-
return `${y}-${m}-${d}`;
|
|
32
|
-
}
|
|
33
|
-
/** 按日历日加减,跨月、跨年按公历进位。 */
|
|
34
|
-
export function addCalendarDays(isoDate, offsetDays) {
|
|
35
|
-
const [year, month, day] = isoDate.split('-').map(Number);
|
|
36
|
-
return formatUtcDate(new Date(Date.UTC(year, (month ?? 1) - 1, (day ?? 1) + offsetDays)));
|
|
37
|
-
}
|
|
38
|
-
/** 按日历月加减;目标月没有这一天时取该月最后一天。 */
|
|
39
|
-
export function addCalendarMonths(isoDate, offsetMonths) {
|
|
40
|
-
const [year, month, day] = isoDate.split('-').map(Number);
|
|
41
|
-
const target = new Date(Date.UTC(year, (month ?? 1) - 1 + offsetMonths, 1));
|
|
42
|
-
const lastDay = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate();
|
|
43
|
-
target.setUTCDate(Math.min(day ?? 1, lastDay));
|
|
44
|
-
return formatUtcDate(target);
|
|
45
|
-
}
|
|
46
|
-
/** 东八区日历日。 */
|
|
47
|
-
export function shanghaiCalendarDate(offsetDays = 0, now = new Date()) {
|
|
48
|
-
const today = new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Shanghai' }).format(now);
|
|
49
|
-
return offsetDays === 0 ? today : addCalendarDays(today, offsetDays);
|
|
50
|
-
}
|
|
51
29
|
const REQUEST_DEFAULT_LOOKBACK_DAYS = 7;
|
|
52
30
|
const REQUEST_PHONE_LOOKBACK_DAYS = 90;
|
|
53
31
|
const REQUEST_SCENES = new Set(['phone']);
|
|
@@ -98,48 +76,6 @@ function projectRequestListResult(value) {
|
|
|
98
76
|
return value;
|
|
99
77
|
return { ...record, data: record.data.map(projectRequestListItem) };
|
|
100
78
|
}
|
|
101
|
-
const UNSAFE_JSON_INTEGER_ID = /("id"\s*:\s*)(-?\d{16,})(?=\s*[,}\]])/g;
|
|
102
|
-
function quoteEmployeeIdsInJsonText(text) {
|
|
103
|
-
return text.replace(UNSAFE_JSON_INTEGER_ID, '$1"$2"');
|
|
104
|
-
}
|
|
105
|
-
function employeeIdString(value) {
|
|
106
|
-
if (typeof value === 'bigint')
|
|
107
|
-
return value.toString();
|
|
108
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
109
|
-
return String(Math.trunc(value));
|
|
110
|
-
if (typeof value === 'string')
|
|
111
|
-
return value;
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
function stringifyEmployeeRecordId(employee) {
|
|
115
|
-
if (!employee || typeof employee !== 'object' || Array.isArray(employee))
|
|
116
|
-
return employee;
|
|
117
|
-
const record = employee;
|
|
118
|
-
if (!('id' in record))
|
|
119
|
-
return employee;
|
|
120
|
-
return { ...record, id: employeeIdString(record.id) };
|
|
121
|
-
}
|
|
122
|
-
function stringifyEmployeeSuperiorsPayload(payload) {
|
|
123
|
-
if ('currentEmployee' in payload) {
|
|
124
|
-
payload.currentEmployee = stringifyEmployeeRecordId(payload.currentEmployee);
|
|
125
|
-
}
|
|
126
|
-
if (Array.isArray(payload.allSuperiors)) {
|
|
127
|
-
payload.allSuperiors = payload.allSuperiors.map(stringifyEmployeeRecordId);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function stringifyEmployeeSuperiorsIds(value) {
|
|
131
|
-
if (!value || typeof value !== 'object')
|
|
132
|
-
return value;
|
|
133
|
-
const cloned = structuredClone(value);
|
|
134
|
-
stringifyEmployeeSuperiorsPayload(cloned);
|
|
135
|
-
if (cloned.data && typeof cloned.data === 'object' && !Array.isArray(cloned.data)) {
|
|
136
|
-
stringifyEmployeeSuperiorsPayload(cloned.data);
|
|
137
|
-
}
|
|
138
|
-
return cloned;
|
|
139
|
-
}
|
|
140
|
-
function employeeSuperiorsEnvelope(value) {
|
|
141
|
-
return resultEnvelope(stringifyEmployeeSuperiorsIds(value), 'invoice.reim.employee-superiors');
|
|
142
|
-
}
|
|
143
79
|
export class InvoiceReimFileOcrPreviewOperation {
|
|
144
80
|
name = 'invoice.reim.file-ocr.preview';
|
|
145
81
|
async execute(input, { host }) {
|
|
@@ -236,63 +172,3 @@ export class InvoiceReimWorkflowResolveOperation {
|
|
|
236
172
|
return resultEnvelope(result, 'invoice.reim.workflow.resolve');
|
|
237
173
|
}
|
|
238
174
|
}
|
|
239
|
-
export class InvoiceReimEmployeeSuperiorsOperation {
|
|
240
|
-
name = 'invoice.reim.employee-superiors';
|
|
241
|
-
async execute(_input, { host }) {
|
|
242
|
-
const result = await host.invoiceRequest({
|
|
243
|
-
path: '/api/inc/book/getEmployeeSuperiors',
|
|
244
|
-
method: 'GET',
|
|
245
|
-
operation: this.name,
|
|
246
|
-
rewriteJsonText: quoteEmployeeIdsInJsonText,
|
|
247
|
-
});
|
|
248
|
-
return employeeSuperiorsEnvelope(result);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function projectFieldSearchItems(value) {
|
|
252
|
-
const raw = Array.isArray(value) ? value : [];
|
|
253
|
-
const items = [];
|
|
254
|
-
const seen = new Set();
|
|
255
|
-
for (const item of raw) {
|
|
256
|
-
const record = item && typeof item === 'object' && !Array.isArray(item) ? item : {};
|
|
257
|
-
const id = String(record.id ?? record.value ?? '').trim();
|
|
258
|
-
const name = String(record.name ?? '').trim();
|
|
259
|
-
if (!id || !name || seen.has(id))
|
|
260
|
-
continue;
|
|
261
|
-
seen.add(id);
|
|
262
|
-
items.push({ id, name, value: id });
|
|
263
|
-
}
|
|
264
|
-
return items;
|
|
265
|
-
}
|
|
266
|
-
export class InvoiceReimFieldSearchOperation {
|
|
267
|
-
name = 'invoice.reim.field.search';
|
|
268
|
-
async execute(input, { host }) {
|
|
269
|
-
const keywords = asNonEmptyString(input.keywords, 'keywords');
|
|
270
|
-
const result = await host.invoiceRequest({
|
|
271
|
-
path: '/api/government/formStructure/fieldRelateSearch',
|
|
272
|
-
method: 'GET',
|
|
273
|
-
query: {
|
|
274
|
-
keywords,
|
|
275
|
-
fieldId: asNonEmptyString(input.fieldId, 'fieldId'),
|
|
276
|
-
formModeType: 'wf',
|
|
277
|
-
workflowId: asNonEmptyString(input.workflowId, 'workflowId'),
|
|
278
|
-
nodeId: optionalString(input.nodeId, 'nodeId') || '100004140000000271',
|
|
279
|
-
},
|
|
280
|
-
operation: this.name,
|
|
281
|
-
});
|
|
282
|
-
assertBusinessSuccess(result, 'invoice.reim.field.search_failed', '搜索关联字段失败');
|
|
283
|
-
const items = projectFieldSearchItems(responseData(result));
|
|
284
|
-
const match = items.length === 0 ? 'none' : items.length === 1 ? 'unique' : 'multiple';
|
|
285
|
-
return {
|
|
286
|
-
status: 'COMPLETE',
|
|
287
|
-
data: {
|
|
288
|
-
result,
|
|
289
|
-
data: items,
|
|
290
|
-
keywords,
|
|
291
|
-
match,
|
|
292
|
-
items,
|
|
293
|
-
selected: match === 'unique' ? items[0] : null,
|
|
294
|
-
workflow: workflow(this.name, 'COMPLETE'),
|
|
295
|
-
},
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
}
|
|
@@ -4,6 +4,8 @@ import { readFile, stat, writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { dirname, extname, basename, resolve } from 'node:path';
|
|
5
5
|
import { InvoiceCliError, invoiceValidationError, } from '../errors.js';
|
|
6
6
|
import { FULL_EXT_MASK, invoiceExtInfo, invoiceRecordOf } from '../invoice-record.js';
|
|
7
|
+
import { readInvoicesWithMetadata } from '../read-enrichment.js';
|
|
8
|
+
export { assertBusinessSuccess } from '../business-response.js';
|
|
7
9
|
const LIST_FIELDS = new Set([
|
|
8
10
|
'page_size',
|
|
9
11
|
'start_pos',
|
|
@@ -237,7 +239,7 @@ export function detailInfo(value) {
|
|
|
237
239
|
}
|
|
238
240
|
return item.info;
|
|
239
241
|
}
|
|
240
|
-
export
|
|
242
|
+
export function invoiceDetailRequest(input) {
|
|
241
243
|
const body = {};
|
|
242
244
|
if (input.fid !== undefined)
|
|
243
245
|
body.ids = [asPositiveString(input.fid, 'fid')];
|
|
@@ -249,11 +251,14 @@ export async function getDetail(input, host) {
|
|
|
249
251
|
}
|
|
250
252
|
if (!body.ids && !body.number)
|
|
251
253
|
throw invoiceValidationError('input_invalid', '必须提供 fid 或 number');
|
|
252
|
-
return
|
|
254
|
+
return {
|
|
253
255
|
path: '/api/inc/get',
|
|
254
256
|
method: 'POST',
|
|
255
257
|
body: { ...body, userFlag: '1', isDelFlag: '1', req_base: reqBase() },
|
|
256
|
-
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export async function getDetail(input, host) {
|
|
261
|
+
return host.invoiceRequest(invoiceDetailRequest(input));
|
|
257
262
|
}
|
|
258
263
|
export function invoiceDetailUrl(baseUrl, fid) {
|
|
259
264
|
return `${baseUrl.replace(/\/+$/, '')}/sp/inc/incDetail?fid=${fid}`;
|
|
@@ -284,18 +289,6 @@ export function numberOrZero(value) {
|
|
|
284
289
|
const parsed = Number(value);
|
|
285
290
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
286
291
|
}
|
|
287
|
-
export function assertBusinessSuccess(value, subtype, fallbackMessage) {
|
|
288
|
-
const result = value && typeof value === 'object' ? value : {};
|
|
289
|
-
const code = result.code ?? result.res_base?.ret;
|
|
290
|
-
const failed = result.fail === true || result.status === false || (code !== undefined && code !== 0 && code !== 200);
|
|
291
|
-
if (!failed)
|
|
292
|
-
return;
|
|
293
|
-
throw new InvoiceCliError('api', subtype, result.message || result.msg || result.res_base?.message || fallbackMessage, {
|
|
294
|
-
code,
|
|
295
|
-
details: { result },
|
|
296
|
-
exitCode: 1,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
292
|
function uploadSource(input) {
|
|
300
293
|
const { file, url } = input;
|
|
301
294
|
if (file !== undefined && url !== undefined)
|
|
@@ -550,14 +543,16 @@ export async function listInvoices(input, host, flag) {
|
|
|
550
543
|
req_base: reqBase(),
|
|
551
544
|
};
|
|
552
545
|
for (const [key, value] of Object.entries(input)) {
|
|
553
|
-
if (key === 'flag')
|
|
546
|
+
if (key === 'flag' || key === 'includePreApprovals')
|
|
554
547
|
continue;
|
|
555
548
|
if (!LIST_FIELDS.has(key))
|
|
556
549
|
throw invoiceValidationError('input_field_unsupported', `列表查询不支持字段:${key}`);
|
|
557
550
|
body[key] = normalizeListField(key, value);
|
|
558
551
|
}
|
|
559
552
|
const session = await host.getSession();
|
|
560
|
-
const
|
|
553
|
+
const { response: result, employeeInfo, preApprovals, warnings } = await readInvoicesWithMetadata(host, {
|
|
554
|
+
path: '/api/inc/sync', method: 'POST', body, operation: flag === 6 ? 'invoice.enterprise.list' : 'invoice.list',
|
|
555
|
+
}, { includePreApprovals: input.includePreApprovals });
|
|
561
556
|
const items = (result.infos || []).filter((item) => !isRedReversedInvoice(invoiceRecordOf(item))).map((item) => {
|
|
562
557
|
const record = invoiceRecordOf(item);
|
|
563
558
|
if (record.fid !== undefined)
|
|
@@ -570,7 +565,10 @@ export async function listInvoices(input, host, flag) {
|
|
|
570
565
|
});
|
|
571
566
|
return {
|
|
572
567
|
status: 'COMPLETE',
|
|
568
|
+
warnings,
|
|
573
569
|
data: {
|
|
570
|
+
employeeInfo,
|
|
571
|
+
preApprovals,
|
|
574
572
|
items,
|
|
575
573
|
total: result.total ?? 0,
|
|
576
574
|
totalAmount: result.totalTn ?? '0',
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { assertBusinessSuccess } from './business-response.js';
|
|
2
|
+
import { addCalendarDays, addCalendarMonths, shanghaiCalendarDate } from './calendar.js';
|
|
3
|
+
import { invoiceExtInfo, invoiceRecordOf, parseInvoiceExt } from './invoice-record.js';
|
|
4
|
+
const REQUEST_PATH = '/api/inc/book/getRequestListByTabId';
|
|
5
|
+
const PAGE_SIZE = 100;
|
|
6
|
+
const MAX_PAGES = 20;
|
|
7
|
+
const REQUEST_TIMEOUT_MS = 5_000;
|
|
8
|
+
const WORKFLOW_IDS = [
|
|
9
|
+
'100003460000000746',
|
|
10
|
+
'100003460000000046',
|
|
11
|
+
'100003460000000418',
|
|
12
|
+
'100003460000000045',
|
|
13
|
+
];
|
|
14
|
+
const ORDINARY_WORKFLOWS = new Set(WORKFLOW_IDS);
|
|
15
|
+
const OPTIONAL_FIELDS = ['flowStatus', 'creatorId', 'creatorName', 'createTime'];
|
|
16
|
+
function record(value) {
|
|
17
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
18
|
+
}
|
|
19
|
+
function text(value) {
|
|
20
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
21
|
+
}
|
|
22
|
+
/** 只有消费类别 / 内容明确时才跳过,普通电子发票票种本身不是话费或油费证据。 */
|
|
23
|
+
function phoneOrFuelOnly(invoice) {
|
|
24
|
+
const info = invoiceRecordOf(invoice);
|
|
25
|
+
const pro = record(info.comm_info?.pro) ?? {};
|
|
26
|
+
const ext = parseInvoiceExt(info.ext);
|
|
27
|
+
const primary = [info.fyn, pro.kind, pro.content, invoiceExtInfo(info).content, ext.service_name]
|
|
28
|
+
.map(text).filter(Boolean);
|
|
29
|
+
const evidence = primary.join(' ');
|
|
30
|
+
const subsidy = /话费|电话费|手机账单|电信服务|通讯|通信|流量(?:费|套餐)|汽油|柴油|加油费|燃油|油费|成品油/u;
|
|
31
|
+
const ordinary = /餐饮|餐费|吃饭|住宿|酒店|客运|运输|机票|火车|通行|过路|停车|办公|招待|团建|聚餐|借款|垫付|设备|维修|矿泉水|食品|食用油|粮油|润滑油/u;
|
|
32
|
+
if (ordinary.test(evidence))
|
|
33
|
+
return false;
|
|
34
|
+
if (Array.isArray(ext.products) && ext.products.some((product) => {
|
|
35
|
+
const name = text(record(product)?.name);
|
|
36
|
+
return name !== '' && !subsidy.test(name);
|
|
37
|
+
}))
|
|
38
|
+
return false;
|
|
39
|
+
if (subsidy.test(evidence))
|
|
40
|
+
return true;
|
|
41
|
+
// 销方只在没有具体消费内容时作明确服务线索;有其他未知商品内容时仍取普通候选池。
|
|
42
|
+
if (primary.some(value => !/^(?:其他|其它|其他费用|其它费用|未分类|未知)$/u.test(value)))
|
|
43
|
+
return false;
|
|
44
|
+
const seller = [info.comm_info?.payer?.company, info.sellerName, info.payer].map(text).join(' ');
|
|
45
|
+
return /中国移动|中国联通|中国电信|中国广电|电信服务|通信服务|通讯服务|加油站|汽柴油销售/u.test(seller);
|
|
46
|
+
}
|
|
47
|
+
function assertRequestListSuccess(response) {
|
|
48
|
+
const envelope = record(response);
|
|
49
|
+
if (!envelope)
|
|
50
|
+
throw new Error('事前申请接口响应结构异常');
|
|
51
|
+
const code = envelope.code ?? record(envelope.res_base)?.ret;
|
|
52
|
+
assertBusinessSuccess({ ...envelope, ...(code !== undefined ? { code: typeof code === 'string' && code.trim() !== '' ? Number(code) : code } : {}) }, 'preapprovals_query_failed', '读取普通事前申请失败');
|
|
53
|
+
const errcode = record(envelope.message)?.errcode;
|
|
54
|
+
if (errcode !== undefined && errcode !== null && errcode !== '') {
|
|
55
|
+
if (!['string', 'number'].includes(typeof errcode) || ![0, 200].includes(Number(errcode))) {
|
|
56
|
+
throw new Error('事前申请接口返回业务失败');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function skipped(reason) {
|
|
61
|
+
return { preApprovals: { status: 'skipped', items: null, hasMore: null, reason }, warnings: [] };
|
|
62
|
+
}
|
|
63
|
+
function requiredId(value) {
|
|
64
|
+
const id = typeof value === 'string' ? value
|
|
65
|
+
: typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? String(value) : '';
|
|
66
|
+
if (!/^\d+$/u.test(id) || !/[1-9]/u.test(id))
|
|
67
|
+
throw new Error('事前申请记录缺少可靠 ID');
|
|
68
|
+
return id;
|
|
69
|
+
}
|
|
70
|
+
function candidate(row, requestid, workflowid) {
|
|
71
|
+
const requestname = row.requestname ?? '';
|
|
72
|
+
if (typeof requestname !== 'string')
|
|
73
|
+
throw new Error('事前申请名称格式异常');
|
|
74
|
+
const result = { requestid, workflowid, requestname };
|
|
75
|
+
for (const key of OPTIONAL_FIELDS) {
|
|
76
|
+
const value = row[key];
|
|
77
|
+
if (value === undefined)
|
|
78
|
+
continue;
|
|
79
|
+
const valid = value === null || typeof value === 'string'
|
|
80
|
+
|| key !== 'creatorName' && typeof value === 'number' && Number.isSafeInteger(value);
|
|
81
|
+
if (!valid)
|
|
82
|
+
throw new Error('事前申请元数据格式异常');
|
|
83
|
+
result[key] = value;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
/** 只读取候选池;不按标题猜流程类型,不把状态或读取完整性解释为已提交。 */
|
|
88
|
+
export async function readInvoicePreApprovals(host, options) {
|
|
89
|
+
if (options.includePreApprovals === false)
|
|
90
|
+
return skipped('disabled');
|
|
91
|
+
if (options.invoices.length === 0)
|
|
92
|
+
return skipped('no_invoices');
|
|
93
|
+
if (options.invoices.every(phoneOrFuelOnly))
|
|
94
|
+
return skipped('phone_fuel_only');
|
|
95
|
+
const items = new Map();
|
|
96
|
+
const seenPages = new Set();
|
|
97
|
+
let query;
|
|
98
|
+
let completedPages = 0;
|
|
99
|
+
let received = 0;
|
|
100
|
+
const partial = (reason) => ({
|
|
101
|
+
preApprovals: { status: 'partial', items: [...items.values()], query, hasMore: true, reason },
|
|
102
|
+
warnings: ['普通事前申请候选尚未完整读取,不能据此判断唯一或没有申请;已取得的候选及发票结果保留。'],
|
|
103
|
+
});
|
|
104
|
+
try {
|
|
105
|
+
const today = shanghaiCalendarDate(0, options.now ?? new Date());
|
|
106
|
+
query = {
|
|
107
|
+
cusCreateDateStart: addCalendarMonths(today, -1),
|
|
108
|
+
cusCreateDateEnd: today,
|
|
109
|
+
workflowIds: [...WORKFLOW_IDS],
|
|
110
|
+
};
|
|
111
|
+
const session = await host.getSession();
|
|
112
|
+
const currentUserId = typeof session.userId === 'string' ? session.userId.trim()
|
|
113
|
+
: typeof session.userId === 'number' && Number.isSafeInteger(session.userId) ? String(session.userId) : '';
|
|
114
|
+
if (currentUserId)
|
|
115
|
+
query.currentUserId = currentUserId;
|
|
116
|
+
for (let pageNo = 1; pageNo <= MAX_PAGES; pageNo += 1) {
|
|
117
|
+
const response = await host.invoiceRequest({
|
|
118
|
+
path: REQUEST_PATH, method: 'POST', operation: options.operation, timeoutMs: REQUEST_TIMEOUT_MS,
|
|
119
|
+
body: {
|
|
120
|
+
pageNo, pageSize: PAGE_SIZE,
|
|
121
|
+
cusCreateDateStart: query.cusCreateDateStart,
|
|
122
|
+
cusCreateDateEnd: addCalendarDays(query.cusCreateDateEnd, 1),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
assertRequestListSuccess(response);
|
|
126
|
+
const raw = record(response)?.data;
|
|
127
|
+
if (!Array.isArray(raw))
|
|
128
|
+
throw new Error('事前申请接口未返回 data 数组');
|
|
129
|
+
const pageRows = raw.map((value) => {
|
|
130
|
+
const row = record(value);
|
|
131
|
+
if (!row)
|
|
132
|
+
throw new Error('事前申请记录结构异常');
|
|
133
|
+
return { row, requestid: requiredId(row.requestid), workflowid: requiredId(row.workflowid) };
|
|
134
|
+
});
|
|
135
|
+
// 检查过滤前的原始页,避免不相关工作流被过滤后误判末页或漏识别重复页。
|
|
136
|
+
const signature = JSON.stringify(pageRows.map((row) => row.requestid).sort());
|
|
137
|
+
if (seenPages.has(signature))
|
|
138
|
+
return partial('repeated_page');
|
|
139
|
+
const pageItems = pageRows.filter((row) => ORDINARY_WORKFLOWS.has(row.workflowid))
|
|
140
|
+
.map(({ row, requestid, workflowid }) => candidate(row, requestid, workflowid));
|
|
141
|
+
seenPages.add(signature);
|
|
142
|
+
for (const item of pageItems) {
|
|
143
|
+
if (!items.has(item.requestid))
|
|
144
|
+
items.set(item.requestid, item);
|
|
145
|
+
}
|
|
146
|
+
completedPages += 1;
|
|
147
|
+
received += raw.length;
|
|
148
|
+
const envelope = record(response);
|
|
149
|
+
const explicitMore = envelope.hasMore;
|
|
150
|
+
if (explicitMore !== undefined && typeof explicitMore !== 'boolean')
|
|
151
|
+
return partial('pagination_inconsistent');
|
|
152
|
+
const rawTotal = envelope.total;
|
|
153
|
+
const total = typeof rawTotal === 'string' && /^\d+$/u.test(rawTotal) ? Number(rawTotal) : rawTotal;
|
|
154
|
+
if (total !== undefined && (!Number.isSafeInteger(total) || total < received))
|
|
155
|
+
return partial('pagination_inconsistent');
|
|
156
|
+
const totalHasMore = total !== undefined && received < total;
|
|
157
|
+
if (explicitMore === false && totalHasMore)
|
|
158
|
+
return partial('pagination_inconsistent');
|
|
159
|
+
if (explicitMore === true || totalHasMore) {
|
|
160
|
+
if (raw.length === 0)
|
|
161
|
+
return partial('pagination_inconsistent');
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (explicitMore === false || total !== undefined || raw.length < PAGE_SIZE) {
|
|
165
|
+
return { preApprovals: { status: 'complete', items: [...items.values()], query, hasMore: false }, warnings: [] };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return partial('page_limit');
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (error && typeof error === 'object' && 'type' in error && error.type === 'authentication')
|
|
172
|
+
throw error;
|
|
173
|
+
if (completedPages > 0)
|
|
174
|
+
return partial('query_failed');
|
|
175
|
+
return {
|
|
176
|
+
preApprovals: { status: 'unavailable', items: null, ...(query ? { query } : {}), hasMore: null, reason: 'query_failed' },
|
|
177
|
+
warnings: ['普通事前申请候选暂不可用,不能视为没有申请;发票结果仍正常返回。'],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -16,6 +16,8 @@ export const SUMMARY_ITEM_FIELDS = [
|
|
|
16
16
|
'number',
|
|
17
17
|
'code',
|
|
18
18
|
'typeName',
|
|
19
|
+
'fyn',
|
|
20
|
+
'travel_ids',
|
|
19
21
|
'date',
|
|
20
22
|
'amount',
|
|
21
23
|
'total',
|
|
@@ -63,6 +65,8 @@ export function summarizeInvoiceItem(raw) {
|
|
|
63
65
|
number: text(item.number),
|
|
64
66
|
code: text(item.code),
|
|
65
67
|
typeName: text(pro.cname),
|
|
68
|
+
fyn: typeof item.fyn === 'string' ? item.fyn : null,
|
|
69
|
+
travel_ids: Array.isArray(item.travel_ids) ? item.travel_ids : [],
|
|
66
70
|
date: text(pro.date),
|
|
67
71
|
amount: text(price.amount),
|
|
68
72
|
total: text(price.total),
|
|
@@ -80,6 +84,8 @@ export function summarizeInvoiceItem(raw) {
|
|
|
80
84
|
detailUrl: text(item.detailUrl),
|
|
81
85
|
};
|
|
82
86
|
for (const [key, value] of Object.entries(summary)) {
|
|
87
|
+
if (key === 'fyn' || key === 'travel_ids')
|
|
88
|
+
continue;
|
|
83
89
|
if (value === '' || value === undefined || value === null)
|
|
84
90
|
delete summary[key];
|
|
85
91
|
else if (Array.isArray(value) && value.length === 0)
|
|
@@ -91,6 +97,10 @@ export function summarizeInvoiceItem(raw) {
|
|
|
91
97
|
export function summarizeListData(data) {
|
|
92
98
|
const items = Array.isArray(data.items) ? data.items : [];
|
|
93
99
|
const summary = {};
|
|
100
|
+
if (data.employeeInfo !== undefined)
|
|
101
|
+
summary.employeeInfo = data.employeeInfo;
|
|
102
|
+
if (data.preApprovals !== undefined)
|
|
103
|
+
summary.preApprovals = data.preApprovals;
|
|
94
104
|
for (const key of ['total', 'totalAmount', 'totalAmountExcludingTax', 'hasMore', 'scope']) {
|
|
95
105
|
if (data[key] !== undefined && data[key] !== null)
|
|
96
106
|
summary[key] = data[key];
|
|
@@ -146,6 +156,10 @@ export function summarizeInvoiceDetailItem(wrapper) {
|
|
|
146
156
|
export function summarizeDetailData(data) {
|
|
147
157
|
const infos = Array.isArray(data.infos) ? data.infos : [];
|
|
148
158
|
const detail = {};
|
|
159
|
+
if (data.employeeInfo !== undefined)
|
|
160
|
+
detail.employeeInfo = data.employeeInfo;
|
|
161
|
+
if (data.preApprovals !== undefined)
|
|
162
|
+
detail.preApprovals = data.preApprovals;
|
|
149
163
|
if (data.scope !== undefined && data.scope !== null)
|
|
150
164
|
detail.scope = data.scope;
|
|
151
165
|
detail.items = infos.map((entry) => summarizeInvoiceDetailItem(asRecord(entry)));
|