@taxdao/fintax-mcp 0.2.0
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 +220 -0
- package/dist/app/create-server.d.ts +18 -0
- package/dist/app/create-server.js +80 -0
- package/dist/app/create-server.js.map +1 -0
- package/dist/app/register-tools.d.ts +4 -0
- package/dist/app/register-tools.js +18 -0
- package/dist/app/register-tools.js.map +1 -0
- package/dist/audit/audit-context.d.ts +38 -0
- package/dist/audit/audit-context.js +167 -0
- package/dist/audit/audit-context.js.map +1 -0
- package/dist/audit/audit-sink.d.ts +20 -0
- package/dist/audit/audit-sink.js +6 -0
- package/dist/audit/audit-sink.js.map +1 -0
- package/dist/audit/file-audit-sink.d.ts +6 -0
- package/dist/audit/file-audit-sink.js +18 -0
- package/dist/audit/file-audit-sink.js.map +1 -0
- package/dist/auth/auth-session.d.ts +63 -0
- package/dist/auth/auth-session.js +226 -0
- package/dist/auth/auth-session.js.map +1 -0
- package/dist/auth/credentials.d.ts +6 -0
- package/dist/auth/credentials.js +12 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/org-token-provider.d.ts +15 -0
- package/dist/auth/org-token-provider.js +62 -0
- package/dist/auth/org-token-provider.js.map +1 -0
- package/dist/capabilities/capability.d.ts +100 -0
- package/dist/capabilities/capability.js +26 -0
- package/dist/capabilities/capability.js.map +1 -0
- package/dist/capabilities/create-capabilities.d.ts +2 -0
- package/dist/capabilities/create-capabilities.js +37 -0
- package/dist/capabilities/create-capabilities.js.map +1 -0
- package/dist/capabilities/define-capability.d.ts +39 -0
- package/dist/capabilities/define-capability.js +64 -0
- package/dist/capabilities/define-capability.js.map +1 -0
- package/dist/capabilities/definitions/accounting-balances.d.ts +4 -0
- package/dist/capabilities/definitions/accounting-balances.js +98 -0
- package/dist/capabilities/definitions/accounting-balances.js.map +1 -0
- package/dist/capabilities/definitions/accounting-context.d.ts +2 -0
- package/dist/capabilities/definitions/accounting-context.js +17 -0
- package/dist/capabilities/definitions/accounting-context.js.map +1 -0
- package/dist/capabilities/definitions/assets.d.ts +2 -0
- package/dist/capabilities/definitions/assets.js +367 -0
- package/dist/capabilities/definitions/assets.js.map +1 -0
- package/dist/capabilities/definitions/business-documents.d.ts +9 -0
- package/dist/capabilities/definitions/business-documents.js +386 -0
- package/dist/capabilities/definitions/business-documents.js.map +1 -0
- package/dist/capabilities/definitions/dashboard.d.ts +2 -0
- package/dist/capabilities/definitions/dashboard.js +153 -0
- package/dist/capabilities/definitions/dashboard.js.map +1 -0
- package/dist/capabilities/definitions/extended-operation-contracts.d.ts +597 -0
- package/dist/capabilities/definitions/extended-operation-contracts.js +1180 -0
- package/dist/capabilities/definitions/extended-operation-contracts.js.map +1 -0
- package/dist/capabilities/definitions/extended-operations.d.ts +2 -0
- package/dist/capabilities/definitions/extended-operations.js +699 -0
- package/dist/capabilities/definitions/extended-operations.js.map +1 -0
- package/dist/capabilities/definitions/financial-reports.d.ts +2 -0
- package/dist/capabilities/definitions/financial-reports.js +100 -0
- package/dist/capabilities/definitions/financial-reports.js.map +1 -0
- package/dist/capabilities/definitions/fnd-import.d.ts +34 -0
- package/dist/capabilities/definitions/fnd-import.js +282 -0
- package/dist/capabilities/definitions/fnd-import.js.map +1 -0
- package/dist/capabilities/definitions/fund-accounts.d.ts +2 -0
- package/dist/capabilities/definitions/fund-accounts.js +188 -0
- package/dist/capabilities/definitions/fund-accounts.js.map +1 -0
- package/dist/capabilities/definitions/fund-balances.d.ts +2 -0
- package/dist/capabilities/definitions/fund-balances.js +84 -0
- package/dist/capabilities/definitions/fund-balances.js.map +1 -0
- package/dist/capabilities/definitions/journals.d.ts +10 -0
- package/dist/capabilities/definitions/journals.js +224 -0
- package/dist/capabilities/definitions/journals.js.map +1 -0
- package/dist/capabilities/definitions/master-data.d.ts +2 -0
- package/dist/capabilities/definitions/master-data.js +451 -0
- package/dist/capabilities/definitions/master-data.js.map +1 -0
- package/dist/capabilities/definitions/pnl.d.ts +2 -0
- package/dist/capabilities/definitions/pnl.js +139 -0
- package/dist/capabilities/definitions/pnl.js.map +1 -0
- package/dist/capabilities/definitions/reference-data.d.ts +2 -0
- package/dist/capabilities/definitions/reference-data.js +169 -0
- package/dist/capabilities/definitions/reference-data.js.map +1 -0
- package/dist/capabilities/definitions/transaction-drafts.d.ts +2 -0
- package/dist/capabilities/definitions/transaction-drafts.js +157 -0
- package/dist/capabilities/definitions/transaction-drafts.js.map +1 -0
- package/dist/capabilities/definitions/transactions.d.ts +168 -0
- package/dist/capabilities/definitions/transactions.js +79 -0
- package/dist/capabilities/definitions/transactions.js.map +1 -0
- package/dist/capabilities/executor.d.ts +19 -0
- package/dist/capabilities/executor.js +134 -0
- package/dist/capabilities/executor.js.map +1 -0
- package/dist/capabilities/registry.d.ts +7 -0
- package/dist/capabilities/registry.js +51 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/clients/base-client.d.ts +5 -0
- package/dist/clients/base-client.js +13 -0
- package/dist/clients/base-client.js.map +1 -0
- package/dist/clients/http-client.d.ts +29 -0
- package/dist/clients/http-client.js +167 -0
- package/dist/clients/http-client.js.map +1 -0
- package/dist/clients/suite-client.d.ts +5 -0
- package/dist/clients/suite-client.js +5 -0
- package/dist/clients/suite-client.js.map +1 -0
- package/dist/concurrency/lock-manager.d.ts +4 -0
- package/dist/concurrency/lock-manager.js +23 -0
- package/dist/concurrency/lock-manager.js.map +1 -0
- package/dist/config/load-config.d.ts +2 -0
- package/dist/config/load-config.js +18 -0
- package/dist/config/load-config.js.map +1 -0
- package/dist/config/schema.d.ts +24 -0
- package/dist/config/schema.js +85 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/errors/fintax-error.d.ts +24 -0
- package/dist/errors/fintax-error.js +21 -0
- package/dist/errors/fintax-error.js.map +1 -0
- package/dist/errors/normalize-error.d.ts +3 -0
- package/dist/errors/normalize-error.js +67 -0
- package/dist/errors/normalize-error.js.map +1 -0
- package/dist/files/artifact-store.d.ts +17 -0
- package/dist/files/artifact-store.js +74 -0
- package/dist/files/artifact-store.js.map +1 -0
- package/dist/files/input-policy.d.ts +28 -0
- package/dist/files/input-policy.js +109 -0
- package/dist/files/input-policy.js.map +1 -0
- package/dist/files/roots-provider.d.ts +14 -0
- package/dist/files/roots-provider.js +47 -0
- package/dist/files/roots-provider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +3 -0
- package/dist/logging/logger.js +13 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/policies/idempotency.d.ts +32 -0
- package/dist/policies/idempotency.js +155 -0
- package/dist/policies/idempotency.js.map +1 -0
- package/dist/policies/job-reference.d.ts +16 -0
- package/dist/policies/job-reference.js +62 -0
- package/dist/policies/job-reference.js.map +1 -0
- package/dist/policies/operation-plan.d.ts +27 -0
- package/dist/policies/operation-plan.js +99 -0
- package/dist/policies/operation-plan.js.map +1 -0
- package/dist/policies/redaction.d.ts +2 -0
- package/dist/policies/redaction.js +29 -0
- package/dist/policies/redaction.js.map +1 -0
- package/dist/policies/retry.d.ts +8 -0
- package/dist/policies/retry.js +19 -0
- package/dist/policies/retry.js.map +1 -0
- package/dist/responses/tool-response.d.ts +4 -0
- package/dist/responses/tool-response.js +24 -0
- package/dist/responses/tool-response.js.map +1 -0
- package/dist/schemas/common.d.ts +226 -0
- package/dist/schemas/common.js +133 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/domains/accounting-balances.d.ts +497 -0
- package/dist/schemas/domains/accounting-balances.js +226 -0
- package/dist/schemas/domains/accounting-balances.js.map +1 -0
- package/dist/schemas/domains/accounting-context.d.ts +118 -0
- package/dist/schemas/domains/accounting-context.js +54 -0
- package/dist/schemas/domains/accounting-context.js.map +1 -0
- package/dist/schemas/domains/assets.d.ts +2508 -0
- package/dist/schemas/domains/assets.js +960 -0
- package/dist/schemas/domains/assets.js.map +1 -0
- package/dist/schemas/domains/business-documents.d.ts +4406 -0
- package/dist/schemas/domains/business-documents.js +1153 -0
- package/dist/schemas/domains/business-documents.js.map +1 -0
- package/dist/schemas/domains/configuration.d.ts +518 -0
- package/dist/schemas/domains/configuration.js +504 -0
- package/dist/schemas/domains/configuration.js.map +1 -0
- package/dist/schemas/domains/dashboard.d.ts +339 -0
- package/dist/schemas/domains/dashboard.js +211 -0
- package/dist/schemas/domains/dashboard.js.map +1 -0
- package/dist/schemas/domains/extended-operation-results.d.ts +1588 -0
- package/dist/schemas/domains/extended-operation-results.js +275 -0
- package/dist/schemas/domains/extended-operation-results.js.map +1 -0
- package/dist/schemas/domains/extended-operations.d.ts +1061 -0
- package/dist/schemas/domains/extended-operations.js +567 -0
- package/dist/schemas/domains/extended-operations.js.map +1 -0
- package/dist/schemas/domains/extended-query-results.d.ts +1688 -0
- package/dist/schemas/domains/extended-query-results.js +337 -0
- package/dist/schemas/domains/extended-query-results.js.map +1 -0
- package/dist/schemas/domains/financial-reports.d.ts +540 -0
- package/dist/schemas/domains/financial-reports.js +206 -0
- package/dist/schemas/domains/financial-reports.js.map +1 -0
- package/dist/schemas/domains/fnd-import.d.ts +912 -0
- package/dist/schemas/domains/fnd-import.js +396 -0
- package/dist/schemas/domains/fnd-import.js.map +1 -0
- package/dist/schemas/domains/fund-accounts.d.ts +1092 -0
- package/dist/schemas/domains/fund-accounts.js +410 -0
- package/dist/schemas/domains/fund-accounts.js.map +1 -0
- package/dist/schemas/domains/fund-balances.d.ts +476 -0
- package/dist/schemas/domains/fund-balances.js +233 -0
- package/dist/schemas/domains/fund-balances.js.map +1 -0
- package/dist/schemas/domains/journals.d.ts +1619 -0
- package/dist/schemas/domains/journals.js +615 -0
- package/dist/schemas/domains/journals.js.map +1 -0
- package/dist/schemas/domains/master-data.d.ts +2010 -0
- package/dist/schemas/domains/master-data.js +799 -0
- package/dist/schemas/domains/master-data.js.map +1 -0
- package/dist/schemas/domains/pnl.d.ts +837 -0
- package/dist/schemas/domains/pnl.js +469 -0
- package/dist/schemas/domains/pnl.js.map +1 -0
- package/dist/schemas/domains/reference-data.d.ts +227 -0
- package/dist/schemas/domains/reference-data.js +144 -0
- package/dist/schemas/domains/reference-data.js.map +1 -0
- package/dist/schemas/domains/transaction-drafts.d.ts +903 -0
- package/dist/schemas/domains/transaction-drafts.js +242 -0
- package/dist/schemas/domains/transaction-drafts.js.map +1 -0
- package/dist/schemas/domains/transactions.d.ts +910 -0
- package/dist/schemas/domains/transactions.js +266 -0
- package/dist/schemas/domains/transactions.js.map +1 -0
- package/dist/schemas/primitives.d.ts +6 -0
- package/dist/schemas/primitives.js +11 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/public-input.d.ts +3 -0
- package/dist/schemas/public-input.js +524 -0
- package/dist/schemas/public-input.js.map +1 -0
- package/dist/tools/core-edit/idempotent-write.d.ts +23 -0
- package/dist/tools/core-edit/idempotent-write.js +58 -0
- package/dist/tools/core-edit/idempotent-write.js.map +1 -0
- package/dist/tools/core-edit/save-asset.d.ts +5 -0
- package/dist/tools/core-edit/save-asset.js +334 -0
- package/dist/tools/core-edit/save-asset.js.map +1 -0
- package/dist/tools/core-edit/save-business-document-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-business-document-draft.js +128 -0
- package/dist/tools/core-edit/save-business-document-draft.js.map +1 -0
- package/dist/tools/core-edit/save-fund-account.d.ts +2 -0
- package/dist/tools/core-edit/save-fund-account.js +138 -0
- package/dist/tools/core-edit/save-fund-account.js.map +1 -0
- package/dist/tools/core-edit/save-journal-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-journal-draft.js +122 -0
- package/dist/tools/core-edit/save-journal-draft.js.map +1 -0
- package/dist/tools/core-edit/save-master-data.d.ts +2 -0
- package/dist/tools/core-edit/save-master-data.js +153 -0
- package/dist/tools/core-edit/save-master-data.js.map +1 -0
- package/dist/tools/core-edit/save-transaction-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-transaction-draft.js +128 -0
- package/dist/tools/core-edit/save-transaction-draft.js.map +1 -0
- package/dist/tools/core-read/export-business-documents.d.ts +2 -0
- package/dist/tools/core-read/export-business-documents.js +67 -0
- package/dist/tools/core-read/export-business-documents.js.map +1 -0
- package/dist/tools/core-read/export-journals.d.ts +2 -0
- package/dist/tools/core-read/export-journals.js +56 -0
- package/dist/tools/core-read/export-journals.js.map +1 -0
- package/dist/tools/core-read/export-transactions.d.ts +2 -0
- package/dist/tools/core-read/export-transactions.js +67 -0
- package/dist/tools/core-read/export-transactions.js.map +1 -0
- package/dist/tools/core-read/query-accounting-balances.d.ts +2 -0
- package/dist/tools/core-read/query-accounting-balances.js +135 -0
- package/dist/tools/core-read/query-accounting-balances.js.map +1 -0
- package/dist/tools/core-read/query-accounting-context.d.ts +2 -0
- package/dist/tools/core-read/query-accounting-context.js +76 -0
- package/dist/tools/core-read/query-accounting-context.js.map +1 -0
- package/dist/tools/core-read/query-assets.d.ts +2 -0
- package/dist/tools/core-read/query-assets.js +425 -0
- package/dist/tools/core-read/query-assets.js.map +1 -0
- package/dist/tools/core-read/query-business-documents.d.ts +9 -0
- package/dist/tools/core-read/query-business-documents.js +620 -0
- package/dist/tools/core-read/query-business-documents.js.map +1 -0
- package/dist/tools/core-read/query-dashboard.d.ts +2 -0
- package/dist/tools/core-read/query-dashboard.js +144 -0
- package/dist/tools/core-read/query-dashboard.js.map +1 -0
- package/dist/tools/core-read/query-financial-reports.d.ts +2 -0
- package/dist/tools/core-read/query-financial-reports.js +171 -0
- package/dist/tools/core-read/query-financial-reports.js.map +1 -0
- package/dist/tools/core-read/query-fund-accounts.d.ts +2 -0
- package/dist/tools/core-read/query-fund-accounts.js +140 -0
- package/dist/tools/core-read/query-fund-accounts.js.map +1 -0
- package/dist/tools/core-read/query-fund-balances.d.ts +2 -0
- package/dist/tools/core-read/query-fund-balances.js +150 -0
- package/dist/tools/core-read/query-fund-balances.js.map +1 -0
- package/dist/tools/core-read/query-journals.d.ts +2 -0
- package/dist/tools/core-read/query-journals.js +277 -0
- package/dist/tools/core-read/query-journals.js.map +1 -0
- package/dist/tools/core-read/query-master-data.d.ts +2 -0
- package/dist/tools/core-read/query-master-data.js +363 -0
- package/dist/tools/core-read/query-master-data.js.map +1 -0
- package/dist/tools/core-read/query-pnl.d.ts +2 -0
- package/dist/tools/core-read/query-pnl.js +244 -0
- package/dist/tools/core-read/query-pnl.js.map +1 -0
- package/dist/tools/core-read/query-reference-data.d.ts +2 -0
- package/dist/tools/core-read/query-reference-data.js +293 -0
- package/dist/tools/core-read/query-reference-data.js.map +1 -0
- package/dist/tools/core-read/query-transactions.d.ts +2 -0
- package/dist/tools/core-read/query-transactions.js +58 -0
- package/dist/tools/core-read/query-transactions.js.map +1 -0
- package/dist/tools/create-tools.d.ts +3 -0
- package/dist/tools/create-tools.js +88 -0
- package/dist/tools/create-tools.js.map +1 -0
- package/dist/tools/extended/asset-operation-tools.d.ts +9 -0
- package/dist/tools/extended/asset-operation-tools.js +419 -0
- package/dist/tools/extended/asset-operation-tools.js.map +1 -0
- package/dist/tools/extended/automation-tools.d.ts +7 -0
- package/dist/tools/extended/automation-tools.js +333 -0
- package/dist/tools/extended/automation-tools.js.map +1 -0
- package/dist/tools/extended/configuration-tools.d.ts +14 -0
- package/dist/tools/extended/configuration-tools.js +871 -0
- package/dist/tools/extended/configuration-tools.js.map +1 -0
- package/dist/tools/extended/period-end-tools.d.ts +11 -0
- package/dist/tools/extended/period-end-tools.js +480 -0
- package/dist/tools/extended/period-end-tools.js.map +1 -0
- package/dist/tools/extended/query-output.d.ts +2589 -0
- package/dist/tools/extended/query-output.js +610 -0
- package/dist/tools/extended/query-output.js.map +1 -0
- package/dist/tools/extended/tool-support.d.ts +56 -0
- package/dist/tools/extended/tool-support.js +198 -0
- package/dist/tools/extended/tool-support.js.map +1 -0
- package/dist/tools/extended/workflow-tools.d.ts +10 -0
- package/dist/tools/extended/workflow-tools.js +678 -0
- package/dist/tools/extended/workflow-tools.js.map +1 -0
- package/dist/tools/fnd-import/execute-import.d.ts +2 -0
- package/dist/tools/fnd-import/execute-import.js +201 -0
- package/dist/tools/fnd-import/execute-import.js.map +1 -0
- package/dist/tools/fnd-import/get-import-template.d.ts +2 -0
- package/dist/tools/fnd-import/get-import-template.js +66 -0
- package/dist/tools/fnd-import/get-import-template.js.map +1 -0
- package/dist/tools/fnd-import/get-job-status.d.ts +8 -0
- package/dist/tools/fnd-import/get-job-status.js +201 -0
- package/dist/tools/fnd-import/get-job-status.js.map +1 -0
- package/dist/tools/fnd-import/prepare-import.d.ts +31 -0
- package/dist/tools/fnd-import/prepare-import.js +214 -0
- package/dist/tools/fnd-import/prepare-import.js.map +1 -0
- package/dist/tools/fnd-import/public-import-result.d.ts +18 -0
- package/dist/tools/fnd-import/public-import-result.js +35 -0
- package/dist/tools/fnd-import/public-import-result.js.map +1 -0
- package/dist/tools/tool-definition.d.ts +45 -0
- package/dist/tools/tool-definition.js +11 -0
- package/dist/tools/tool-definition.js.map +1 -0
- package/dist/tools/tool-handler.d.ts +27 -0
- package/dist/tools/tool-handler.js +196 -0
- package/dist/tools/tool-handler.js.map +1 -0
- package/dist/tools/transaction-item.d.ts +225 -0
- package/dist/tools/transaction-item.js +109 -0
- package/dist/tools/transaction-item.js.map +1 -0
- package/dist/transport/draining-transport.d.ts +14 -0
- package/dist/transport/draining-transport.js +36 -0
- package/dist/transport/draining-transport.js.map +1 -0
- package/dist/transport/stdio.d.ts +2 -0
- package/dist/transport/stdio.js +5 -0
- package/dist/transport/stdio.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { executeBusinessDocumentOffsetInputSchema, executeBusinessDocumentPostInputSchema, operationPlanOutputSchema, prepareBusinessDocumentPostInputSchema, prepareJournalSubmissionInputSchema, previewBusinessDocumentOffsetInputSchema, previewBusinessDocumentOffsetOutputSchema, queryBusinessDocumentOffsetCandidatesInputSchema, queryBusinessDocumentOffsetCandidatesOutputSchema, submitBusinessDocumentInputSchema, submitJournalsInputSchema, } from '../../schemas/domains/extended-operations.js';
|
|
2
|
+
import { operationResultSchemas } from '../../schemas/domains/extended-operation-results.js';
|
|
3
|
+
import { createPublicInputSchema } from '../../schemas/public-input.js';
|
|
4
|
+
import { FinTaxError } from '../../errors/fintax-error.js';
|
|
5
|
+
import { hashOperationValue } from '../../policies/operation-plan.js';
|
|
6
|
+
import { journalDocumentsUpstreamSchema } from '../../schemas/domains/journals.js';
|
|
7
|
+
import { executeIdempotentWrite } from '../core-edit/idempotent-write.js';
|
|
8
|
+
import { executePlannedOperation, issueOperationPlan, operationResult, planSummary, requiredUpstreamArray, resultSummary, } from './tool-support.js';
|
|
9
|
+
const workflowAnnotations = {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: false,
|
|
13
|
+
openWorldHint: false,
|
|
14
|
+
};
|
|
15
|
+
const prepareAnnotations = {
|
|
16
|
+
...workflowAnnotations,
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
};
|
|
20
|
+
function documentCapabilities(type) {
|
|
21
|
+
const prefix = type === 'payable' ? 'suite.ap.payable' : 'suite.ar.receivable';
|
|
22
|
+
return {
|
|
23
|
+
detail: `${prefix}.detail`,
|
|
24
|
+
submit: `${prefix}.verify_submit`,
|
|
25
|
+
post: `${prefix}.post`,
|
|
26
|
+
candidates: `${prefix}.offset_candidates`,
|
|
27
|
+
internalCandidates: `${prefix}.internal_offset_candidates`,
|
|
28
|
+
offset: `${prefix}.offset_apply`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function sourceOperation(capabilityId) {
|
|
32
|
+
return capabilityId.replace(/^suite\./, '');
|
|
33
|
+
}
|
|
34
|
+
function recordValue(value) {
|
|
35
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
36
|
+
? value
|
|
37
|
+
: {};
|
|
38
|
+
}
|
|
39
|
+
function submissionResult(value) {
|
|
40
|
+
const raw = recordValue(value);
|
|
41
|
+
if (typeof raw.submitted === 'number') {
|
|
42
|
+
const failed = requiredUpstreamArray(raw.failed);
|
|
43
|
+
return {
|
|
44
|
+
submitted: raw.submitted,
|
|
45
|
+
failed: failed.map((item) => {
|
|
46
|
+
const record = recordValue(item);
|
|
47
|
+
return {
|
|
48
|
+
journal_id: record.journal_id,
|
|
49
|
+
journal_number: record.journal_number ?? null,
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const verifyResult = raw.verify_result === null || raw.verify_result === undefined
|
|
55
|
+
? null
|
|
56
|
+
: recordValue(raw.verify_result);
|
|
57
|
+
const submitResult = raw.submit_result === null || raw.submit_result === undefined
|
|
58
|
+
? null
|
|
59
|
+
: recordValue(raw.submit_result);
|
|
60
|
+
return {
|
|
61
|
+
verified: raw.verified,
|
|
62
|
+
submitted: raw.submitted,
|
|
63
|
+
verify_result: verifyResult === null
|
|
64
|
+
? null
|
|
65
|
+
: {
|
|
66
|
+
...(typeof verifyResult.journal_id === 'string'
|
|
67
|
+
? { journal_id: verifyResult.journal_id }
|
|
68
|
+
: {}),
|
|
69
|
+
verification_status: verifyResult.verification_status,
|
|
70
|
+
},
|
|
71
|
+
submit_result: submitResult === null
|
|
72
|
+
? null
|
|
73
|
+
: {
|
|
74
|
+
approval_status: submitResult.approval_status,
|
|
75
|
+
current_node_name: submitResult.current_node_name ?? null,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function documentPostResult(value) {
|
|
80
|
+
const raw = recordValue(value);
|
|
81
|
+
const items = requiredUpstreamArray(raw.items);
|
|
82
|
+
return {
|
|
83
|
+
requested: raw.requested,
|
|
84
|
+
posted: raw.posted,
|
|
85
|
+
journals: raw.journals,
|
|
86
|
+
items: items.map((item) => {
|
|
87
|
+
const record = recordValue(item);
|
|
88
|
+
return { status: record.status, journals: record.journals };
|
|
89
|
+
}),
|
|
90
|
+
attachments_copied: raw.attachments_copied,
|
|
91
|
+
attachments_skipped: raw.attachments_skipped,
|
|
92
|
+
attachments_failed: raw.attachments_failed,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function documentOffsetResult(value) {
|
|
96
|
+
const raw = recordValue(value);
|
|
97
|
+
const offsetLines = requiredUpstreamArray(raw.offset_lines);
|
|
98
|
+
const diffLines = requiredUpstreamArray(raw.diff_lines);
|
|
99
|
+
const remaining = requiredUpstreamArray(raw.invoice_remaining);
|
|
100
|
+
return {
|
|
101
|
+
offset_lines: offsetLines.map((item) => {
|
|
102
|
+
const record = recordValue(item);
|
|
103
|
+
return {
|
|
104
|
+
offset_line_id: record.offset_line_id,
|
|
105
|
+
source_type: record.source_type,
|
|
106
|
+
source_id: record.source_id,
|
|
107
|
+
quantity: record.quantity,
|
|
108
|
+
symbol: record.symbol,
|
|
109
|
+
base_amount: record.base_amount ?? null,
|
|
110
|
+
};
|
|
111
|
+
}),
|
|
112
|
+
diff_lines: diffLines.map((item) => ({
|
|
113
|
+
offset_line_id: recordValue(item).offset_line_id,
|
|
114
|
+
})),
|
|
115
|
+
invoice_remaining: remaining.map((item) => {
|
|
116
|
+
const record = recordValue(item);
|
|
117
|
+
return { symbol: record.symbol, remaining: record.remaining };
|
|
118
|
+
}),
|
|
119
|
+
offset_date: raw.offset_date,
|
|
120
|
+
gl_date: raw.gl_date,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function journalSubmissionSnapshot(value) {
|
|
124
|
+
const parsed = journalDocumentsUpstreamSchema.parse(value);
|
|
125
|
+
return {
|
|
126
|
+
recommended_rule_h_id: parsed.recommended_rule_h_id,
|
|
127
|
+
matched_rules: parsed.matched_rules.map((rule) => ({
|
|
128
|
+
rule_h_id: rule.rule_h_id,
|
|
129
|
+
rule_code: rule.rule_code,
|
|
130
|
+
rule_name: rule.rule_name,
|
|
131
|
+
is_balanced: rule.is_balanced,
|
|
132
|
+
unavailable_reason: rule.unavailable_reason,
|
|
133
|
+
journals: rule.journals.map((journal) => ({
|
|
134
|
+
id: journal.id,
|
|
135
|
+
journal_number: journal.journal_number,
|
|
136
|
+
period_name: journal.period_name,
|
|
137
|
+
entry_source: journal.entry_source,
|
|
138
|
+
source_type: journal.source_type,
|
|
139
|
+
journal_type: journal.journal_type,
|
|
140
|
+
biz_date: journal.biz_date,
|
|
141
|
+
gl_date: journal.gl_date,
|
|
142
|
+
description: journal.description,
|
|
143
|
+
org_id: journal.org_id,
|
|
144
|
+
ledger_id: journal.ledger_id,
|
|
145
|
+
version: journal.version,
|
|
146
|
+
approval_status: journal.approval_status,
|
|
147
|
+
verification_status: journal.verification_status,
|
|
148
|
+
lines: journal.lines.map((line) => ({
|
|
149
|
+
id: line.id,
|
|
150
|
+
coa_code: line.coa_code,
|
|
151
|
+
coa_name: line.coa_name,
|
|
152
|
+
description: line.description,
|
|
153
|
+
base_currency: line.base_currency,
|
|
154
|
+
base_debit: line.base_debit,
|
|
155
|
+
base_credit: line.base_credit,
|
|
156
|
+
origin_currency: line.origin_currency,
|
|
157
|
+
origin_debit: line.origin_debit,
|
|
158
|
+
origin_credit: line.origin_credit,
|
|
159
|
+
attributes: line.attributes.map((attribute) => ({
|
|
160
|
+
slot: attribute.slot,
|
|
161
|
+
code: attribute.code,
|
|
162
|
+
value: attribute.value,
|
|
163
|
+
})),
|
|
164
|
+
source_id: line.source_id,
|
|
165
|
+
source_type: line.source_type,
|
|
166
|
+
rate_amount: line.rate_amount,
|
|
167
|
+
rate_time: line.rate_time,
|
|
168
|
+
})),
|
|
169
|
+
})),
|
|
170
|
+
})),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function journalSnapshots(value) {
|
|
174
|
+
return value.matched_rules.flatMap((matchedRule) => matchedRule.journals);
|
|
175
|
+
}
|
|
176
|
+
function assertCurrentVersion(value, objectId, version, objectName) {
|
|
177
|
+
const record = recordValue(value);
|
|
178
|
+
if (record.id !== objectId || record.version !== version) {
|
|
179
|
+
throw new FinTaxError('CONFLICT', `${objectName} state or version changed; query it again before preparing the operation`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function offsetCandidate(value) {
|
|
183
|
+
const candidate = recordValue(value);
|
|
184
|
+
return {
|
|
185
|
+
source_type: candidate.source_type,
|
|
186
|
+
source_id: candidate.source_id,
|
|
187
|
+
symbol: candidate.symbol,
|
|
188
|
+
quantity: candidate.quantity,
|
|
189
|
+
base_amount: candidate.base_amount ?? null,
|
|
190
|
+
base_currency: candidate.base_currency ?? null,
|
|
191
|
+
base_rate: candidate.base_rate ?? null,
|
|
192
|
+
biz_date: candidate.biz_date ?? null,
|
|
193
|
+
source_ref: candidate.source_ref ?? null,
|
|
194
|
+
main_account_name: candidate.main_account_name ?? null,
|
|
195
|
+
sub_account_code: candidate.sub_account_code ?? null,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function offsetCandidatesSnapshot(value) {
|
|
199
|
+
const record = recordValue(value);
|
|
200
|
+
return {
|
|
201
|
+
invoice_symbols: requiredUpstreamArray(record.invoice_symbols),
|
|
202
|
+
groups: requiredUpstreamArray(record.groups).map((group) => {
|
|
203
|
+
const item = recordValue(group);
|
|
204
|
+
return {
|
|
205
|
+
symbol: item.symbol,
|
|
206
|
+
candidates: requiredUpstreamArray(item.candidates).map(offsetCandidate),
|
|
207
|
+
};
|
|
208
|
+
}),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function candidateRecords(value) {
|
|
212
|
+
return new Map(value.groups.flatMap((group) => group.candidates.flatMap((candidate) => typeof candidate.source_type === 'string' &&
|
|
213
|
+
typeof candidate.source_id === 'string'
|
|
214
|
+
? [
|
|
215
|
+
[
|
|
216
|
+
`${candidate.source_type}:${candidate.source_id}`,
|
|
217
|
+
candidate,
|
|
218
|
+
],
|
|
219
|
+
]
|
|
220
|
+
: [])));
|
|
221
|
+
}
|
|
222
|
+
function offsetCandidatesSummary(output) {
|
|
223
|
+
const parsed = queryBusinessDocumentOffsetCandidatesOutputSchema.parse(output);
|
|
224
|
+
const count = parsed.data.groups.reduce((total, group) => total + group.candidates.length, 0);
|
|
225
|
+
return `Returned ${count} available offset candidates.`;
|
|
226
|
+
}
|
|
227
|
+
function offsetPlanSummary(output) {
|
|
228
|
+
const parsed = previewBusinessDocumentOffsetOutputSchema.parse(output);
|
|
229
|
+
return `The offset preview selected ${parsed.data.preview.selected_candidates.length} transactions with offset date ${parsed.data.preview.offset_date} and general-ledger date ${parsed.data.preview.gl_date}; user confirmation is required before execution.`;
|
|
230
|
+
}
|
|
231
|
+
export const prepareJournalSubmissionTool = {
|
|
232
|
+
name: 'prepare_journal_submission',
|
|
233
|
+
title: 'Prepare Batch Journal Submission',
|
|
234
|
+
description: 'Read the current state and version of two or more journals and create a single-use batch-submission plan without submitting them. Use this Tool only for batch submission; submit one journal directly with submit_journals in single mode.',
|
|
235
|
+
risk: 'R0',
|
|
236
|
+
exposurePack: 'workflow',
|
|
237
|
+
capabilityIds: ['suite.acct.journal.detail'],
|
|
238
|
+
fileAccess: 'none',
|
|
239
|
+
inputSchema: prepareJournalSubmissionInputSchema,
|
|
240
|
+
outputSchema: operationPlanOutputSchema,
|
|
241
|
+
annotations: prepareAnnotations,
|
|
242
|
+
async execute(rawInput, context) {
|
|
243
|
+
const input = prepareJournalSubmissionInputSchema.parse(rawInput);
|
|
244
|
+
const details = await Promise.all(input.journals.map((journal) => context.callCapability('suite.acct.journal.detail', { journal_id: journal.journal_id }, input.context.org_id)));
|
|
245
|
+
const snapshots = details.map(journalSubmissionSnapshot);
|
|
246
|
+
input.journals.forEach((journal, index) => {
|
|
247
|
+
const snapshot = journalSnapshots(snapshots[index]).find((item) => item.id === journal.journal_id);
|
|
248
|
+
assertCurrentVersion(snapshot, journal.journal_id, journal.version, 'Journal');
|
|
249
|
+
});
|
|
250
|
+
return issueOperationPlan({
|
|
251
|
+
context,
|
|
252
|
+
executeTool: 'submit_journals',
|
|
253
|
+
targetType: 'journal',
|
|
254
|
+
targetIds: input.journals.map((journal) => journal.journal_id),
|
|
255
|
+
targetVersions: input.journals.map((journal) => journal.version),
|
|
256
|
+
orgId: input.context.org_id,
|
|
257
|
+
parameters: input,
|
|
258
|
+
preview: snapshots,
|
|
259
|
+
operation: 'acct.journal.detail',
|
|
260
|
+
privatePayload: {
|
|
261
|
+
journal_ids: input.journals.map((journal) => journal.journal_id),
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
summarize: planSummary,
|
|
266
|
+
};
|
|
267
|
+
async function submitSingleJournal(input, context) {
|
|
268
|
+
return executeIdempotentWrite({
|
|
269
|
+
toolName: 'submit_journals',
|
|
270
|
+
idempotencyKey: input.idempotency_key,
|
|
271
|
+
orgId: input.context.org_id,
|
|
272
|
+
fingerprintValue: input,
|
|
273
|
+
capabilityId: 'suite.acct.journal.verify_submit',
|
|
274
|
+
capabilityInput: {
|
|
275
|
+
journal_id: input.journal_id,
|
|
276
|
+
version: input.version,
|
|
277
|
+
},
|
|
278
|
+
context,
|
|
279
|
+
outputSchema: operationResultSchemas.submit_journals,
|
|
280
|
+
recovery: {
|
|
281
|
+
tool: 'query_journals',
|
|
282
|
+
input: {
|
|
283
|
+
view: 'detail',
|
|
284
|
+
journal_id: input.journal_id,
|
|
285
|
+
context: { org_id: input.context.org_id },
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
target: { field: 'journal_id', id: input.journal_id },
|
|
289
|
+
buildOutput: (raw) => operationResult({
|
|
290
|
+
operation: 'submit_journals',
|
|
291
|
+
targetType: 'journal',
|
|
292
|
+
targetIds: [input.journal_id],
|
|
293
|
+
result: submissionResult(raw),
|
|
294
|
+
outputSchema: operationResultSchemas.submit_journals,
|
|
295
|
+
context,
|
|
296
|
+
sourceOperation: 'acct.journal.verifyAndSubmit',
|
|
297
|
+
}),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
export const submitJournalsTool = {
|
|
301
|
+
name: 'submit_journals',
|
|
302
|
+
title: 'Submit Journals',
|
|
303
|
+
description: 'Submit one journal or a batch of journals for approval. Use single mode for one journal. For two or more journals, call prepare_journal_submission first and use batch mode only after the user confirms the plan summary. This Tool does not post, reverse, or delete journals.',
|
|
304
|
+
risk: 'R2',
|
|
305
|
+
exposurePack: 'workflow',
|
|
306
|
+
capabilityIds: [
|
|
307
|
+
'suite.acct.journal.verify_submit',
|
|
308
|
+
'suite.acct.journal.batch_submit',
|
|
309
|
+
'suite.acct.journal.detail',
|
|
310
|
+
],
|
|
311
|
+
fileAccess: 'none',
|
|
312
|
+
publicInputSchema: createPublicInputSchema(submitJournalsInputSchema),
|
|
313
|
+
inputSchema: submitJournalsInputSchema,
|
|
314
|
+
outputSchema: operationResultSchemas.submit_journals,
|
|
315
|
+
annotations: workflowAnnotations,
|
|
316
|
+
async execute(rawInput, context) {
|
|
317
|
+
const input = submitJournalsInputSchema.parse(rawInput);
|
|
318
|
+
if (input.mode === 'single') {
|
|
319
|
+
return context.withResourceLock(`journal:${input.journal_id}`, () => submitSingleJournal(input, context));
|
|
320
|
+
}
|
|
321
|
+
return executePlannedOperation({
|
|
322
|
+
toolName: 'submit_journals',
|
|
323
|
+
operationPlanId: input.operation_plan_id,
|
|
324
|
+
confirmationToken: input.confirmation_token,
|
|
325
|
+
idempotencyKey: input.idempotency_key,
|
|
326
|
+
orgId: input.context.org_id,
|
|
327
|
+
capabilityId: 'suite.acct.journal.batch_submit',
|
|
328
|
+
context,
|
|
329
|
+
sourceOperation: 'acct.journal.submitApprovalBatch',
|
|
330
|
+
targetType: 'journal',
|
|
331
|
+
outputSchema: operationResultSchemas.submit_journals,
|
|
332
|
+
projectResult: submissionResult,
|
|
333
|
+
validatePlan: async (binding) => {
|
|
334
|
+
const details = await Promise.all(binding.subject_id
|
|
335
|
+
.split(',')
|
|
336
|
+
.filter(Boolean)
|
|
337
|
+
.map((journalId) => context.callCapability('suite.acct.journal.detail', { journal_id: journalId }, input.context.org_id)));
|
|
338
|
+
const snapshots = details.map(journalSubmissionSnapshot);
|
|
339
|
+
if (hashOperationValue(snapshots) !== binding.preview_hash) {
|
|
340
|
+
throw new FinTaxError('CONFIRMATION_REQUIRED', 'The journal state changed; run the preparation step again');
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
buildCapabilityInput: (binding) => ({
|
|
344
|
+
journal_ids: binding.payload?.journal_ids,
|
|
345
|
+
}),
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
summarize: resultSummary,
|
|
349
|
+
};
|
|
350
|
+
export const submitBusinessDocumentTool = {
|
|
351
|
+
name: 'submit_business_document',
|
|
352
|
+
title: 'Submit Receivable or Payable Document',
|
|
353
|
+
description: 'Validate and submit one receivable or payable document for approval. It accepts only one document and its current version; it does not perform batch submission, posting, or offsetting.',
|
|
354
|
+
risk: 'R2',
|
|
355
|
+
exposurePack: 'workflow',
|
|
356
|
+
capabilityIds: [
|
|
357
|
+
'suite.ap.payable.verify_submit',
|
|
358
|
+
'suite.ar.receivable.verify_submit',
|
|
359
|
+
],
|
|
360
|
+
fileAccess: 'none',
|
|
361
|
+
inputSchema: submitBusinessDocumentInputSchema,
|
|
362
|
+
outputSchema: operationResultSchemas.submit_business_document,
|
|
363
|
+
annotations: workflowAnnotations,
|
|
364
|
+
async execute(rawInput, context) {
|
|
365
|
+
const input = submitBusinessDocumentInputSchema.parse(rawInput);
|
|
366
|
+
const capability = documentCapabilities(input.document_type).submit;
|
|
367
|
+
return context.withResourceLock(`${input.document_type}:${input.document_id}`, () => executeIdempotentWrite({
|
|
368
|
+
toolName: 'submit_business_document',
|
|
369
|
+
idempotencyKey: input.idempotency_key,
|
|
370
|
+
orgId: input.context.org_id,
|
|
371
|
+
fingerprintValue: input,
|
|
372
|
+
capabilityId: capability,
|
|
373
|
+
capabilityInput: {
|
|
374
|
+
document_id: input.document_id,
|
|
375
|
+
version: input.version,
|
|
376
|
+
},
|
|
377
|
+
context,
|
|
378
|
+
outputSchema: operationResultSchemas.submit_business_document,
|
|
379
|
+
recovery: {
|
|
380
|
+
tool: input.document_type === 'payable'
|
|
381
|
+
? 'get_payable_document'
|
|
382
|
+
: 'get_receivable_document',
|
|
383
|
+
input: {
|
|
384
|
+
document_id: input.document_id,
|
|
385
|
+
context: { org_id: input.context.org_id },
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
target: { field: 'document_id', id: input.document_id },
|
|
389
|
+
buildOutput: (raw) => operationResult({
|
|
390
|
+
operation: 'submit_business_document',
|
|
391
|
+
targetType: input.document_type,
|
|
392
|
+
targetIds: [input.document_id],
|
|
393
|
+
result: submissionResult(raw),
|
|
394
|
+
outputSchema: operationResultSchemas.submit_business_document,
|
|
395
|
+
context,
|
|
396
|
+
sourceOperation: sourceOperation(capability),
|
|
397
|
+
}),
|
|
398
|
+
}));
|
|
399
|
+
},
|
|
400
|
+
summarize: resultSummary,
|
|
401
|
+
};
|
|
402
|
+
export const prepareBusinessDocumentPostTool = {
|
|
403
|
+
name: 'prepare_business_document_post',
|
|
404
|
+
title: 'Prepare Receivable or Payable Document Posting',
|
|
405
|
+
description: 'Read the current state and version of one receivable or payable document and create a posting plan without posting it. Call execute_business_document_post only after the plan summary has been confirmed.',
|
|
406
|
+
risk: 'R0',
|
|
407
|
+
exposurePack: 'workflow',
|
|
408
|
+
capabilityIds: ['suite.ap.payable.detail', 'suite.ar.receivable.detail'],
|
|
409
|
+
fileAccess: 'none',
|
|
410
|
+
inputSchema: prepareBusinessDocumentPostInputSchema,
|
|
411
|
+
outputSchema: operationPlanOutputSchema,
|
|
412
|
+
annotations: prepareAnnotations,
|
|
413
|
+
async execute(rawInput, context) {
|
|
414
|
+
const input = prepareBusinessDocumentPostInputSchema.parse(rawInput);
|
|
415
|
+
const capability = documentCapabilities(input.document_type).detail;
|
|
416
|
+
const detail = await context.callCapability(capability, { document_id: input.document_id }, input.context.org_id);
|
|
417
|
+
assertCurrentVersion(detail, input.document_id, input.version, input.document_type === 'payable'
|
|
418
|
+
? 'Payable document'
|
|
419
|
+
: 'Receivable document');
|
|
420
|
+
return issueOperationPlan({
|
|
421
|
+
context,
|
|
422
|
+
executeTool: 'execute_business_document_post',
|
|
423
|
+
targetType: input.document_type,
|
|
424
|
+
targetIds: [input.document_id],
|
|
425
|
+
targetVersions: [input.version],
|
|
426
|
+
orgId: input.context.org_id,
|
|
427
|
+
parameters: input,
|
|
428
|
+
preview: detail,
|
|
429
|
+
operation: sourceOperation(capability),
|
|
430
|
+
privatePayload: {
|
|
431
|
+
document_type: input.document_type,
|
|
432
|
+
document_id: input.document_id,
|
|
433
|
+
version: input.version,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
summarize: planSummary,
|
|
438
|
+
};
|
|
439
|
+
export const executeBusinessDocumentPostTool = {
|
|
440
|
+
name: 'execute_business_document_post',
|
|
441
|
+
title: 'Post Receivable or Payable Document',
|
|
442
|
+
description: 'Consume a user-confirmed plan issued by prepare_business_document_post and post one document. After a timeout, do not blindly retry with a new plan.',
|
|
443
|
+
risk: 'R3',
|
|
444
|
+
exposurePack: 'workflow',
|
|
445
|
+
capabilityIds: [
|
|
446
|
+
'suite.ap.payable.post',
|
|
447
|
+
'suite.ar.receivable.post',
|
|
448
|
+
'suite.ap.payable.detail',
|
|
449
|
+
'suite.ar.receivable.detail',
|
|
450
|
+
],
|
|
451
|
+
fileAccess: 'none',
|
|
452
|
+
inputSchema: executeBusinessDocumentPostInputSchema,
|
|
453
|
+
outputSchema: operationResultSchemas.execute_business_document_post,
|
|
454
|
+
annotations: workflowAnnotations,
|
|
455
|
+
async execute(rawInput, context) {
|
|
456
|
+
const input = executeBusinessDocumentPostInputSchema.parse(rawInput);
|
|
457
|
+
const binding = context.operationPlans.inspect(input.operation_plan_id, input.confirmation_token, 'execute_business_document_post');
|
|
458
|
+
const type = binding.payload?.document_type;
|
|
459
|
+
const capability = documentCapabilities(type).post;
|
|
460
|
+
return executePlannedOperation({
|
|
461
|
+
toolName: 'execute_business_document_post',
|
|
462
|
+
operationPlanId: input.operation_plan_id,
|
|
463
|
+
confirmationToken: input.confirmation_token,
|
|
464
|
+
idempotencyKey: input.idempotency_key,
|
|
465
|
+
orgId: input.context.org_id,
|
|
466
|
+
capabilityId: capability,
|
|
467
|
+
context,
|
|
468
|
+
sourceOperation: sourceOperation(capability),
|
|
469
|
+
targetType: type,
|
|
470
|
+
outputSchema: operationResultSchemas.execute_business_document_post,
|
|
471
|
+
projectResult: documentPostResult,
|
|
472
|
+
recovery: {
|
|
473
|
+
tool: type === 'payable'
|
|
474
|
+
? 'get_payable_document'
|
|
475
|
+
: 'get_receivable_document',
|
|
476
|
+
input: {
|
|
477
|
+
document_id: binding.subject_id,
|
|
478
|
+
context: { org_id: input.context.org_id },
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
validatePlan: async (plan) => {
|
|
482
|
+
const detail = await context.callCapability(documentCapabilities(type).detail, { document_id: plan.payload?.document_id }, input.context.org_id);
|
|
483
|
+
if (hashOperationValue(detail) !== plan.preview_hash) {
|
|
484
|
+
throw new FinTaxError('CONFIRMATION_REQUIRED', 'The document state changed; run the preparation step again');
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
buildCapabilityInput: (plan) => ({
|
|
488
|
+
document_id: plan.payload?.document_id,
|
|
489
|
+
}),
|
|
490
|
+
});
|
|
491
|
+
},
|
|
492
|
+
summarize: resultSummary,
|
|
493
|
+
};
|
|
494
|
+
export const queryBusinessDocumentOffsetCandidatesTool = {
|
|
495
|
+
name: 'query_business_document_offset_candidates',
|
|
496
|
+
title: 'Query Receivable or Payable Offset Candidates',
|
|
497
|
+
description: 'Query the external or internal transactions currently available to offset a specified receivable or payable document. Returns transaction IDs, currencies, amounts, business dates, and account summaries without creating an operation plan.',
|
|
498
|
+
risk: 'R0',
|
|
499
|
+
exposurePack: 'workflow',
|
|
500
|
+
capabilityIds: [
|
|
501
|
+
'suite.ap.payable.offset_candidates',
|
|
502
|
+
'suite.ap.payable.internal_offset_candidates',
|
|
503
|
+
'suite.ar.receivable.offset_candidates',
|
|
504
|
+
'suite.ar.receivable.internal_offset_candidates',
|
|
505
|
+
],
|
|
506
|
+
fileAccess: 'none',
|
|
507
|
+
inputSchema: queryBusinessDocumentOffsetCandidatesInputSchema,
|
|
508
|
+
outputSchema: queryBusinessDocumentOffsetCandidatesOutputSchema,
|
|
509
|
+
annotations: prepareAnnotations,
|
|
510
|
+
async execute(rawInput, context) {
|
|
511
|
+
const input = queryBusinessDocumentOffsetCandidatesInputSchema.parse(rawInput);
|
|
512
|
+
const capabilities = documentCapabilities(input.document_type);
|
|
513
|
+
const capability = input.candidate_scope === 'internal'
|
|
514
|
+
? capabilities.internalCandidates
|
|
515
|
+
: capabilities.candidates;
|
|
516
|
+
const candidates = offsetCandidatesSnapshot(await context.callCapability(capability, { document_id: input.document_id }, input.context.org_id));
|
|
517
|
+
return queryBusinessDocumentOffsetCandidatesOutputSchema.parse({
|
|
518
|
+
ok: true,
|
|
519
|
+
data: {
|
|
520
|
+
document_type: input.document_type,
|
|
521
|
+
document_id: input.document_id,
|
|
522
|
+
candidate_scope: input.candidate_scope,
|
|
523
|
+
...candidates,
|
|
524
|
+
},
|
|
525
|
+
warnings: [],
|
|
526
|
+
trace_id: context.traceId,
|
|
527
|
+
source_refs: [
|
|
528
|
+
{ service: 'suite', operation: sourceOperation(capability) },
|
|
529
|
+
],
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
summarize: offsetCandidatesSummary,
|
|
533
|
+
};
|
|
534
|
+
export const previewBusinessDocumentOffsetTool = {
|
|
535
|
+
name: 'preview_business_document_offset',
|
|
536
|
+
title: 'Preview Receivable or Payable Offset',
|
|
537
|
+
description: 'Reload the current offset candidates and bind the transactions explicitly selected through query_business_document_offset_candidates into a single-use offset plan without writing an offset result. Call execute_business_document_offset only after confirming the candidates and dates.',
|
|
538
|
+
risk: 'R0',
|
|
539
|
+
exposurePack: 'workflow',
|
|
540
|
+
capabilityIds: [
|
|
541
|
+
'suite.ap.payable.offset_candidates',
|
|
542
|
+
'suite.ap.payable.internal_offset_candidates',
|
|
543
|
+
'suite.ar.receivable.offset_candidates',
|
|
544
|
+
'suite.ar.receivable.internal_offset_candidates',
|
|
545
|
+
],
|
|
546
|
+
fileAccess: 'none',
|
|
547
|
+
inputSchema: previewBusinessDocumentOffsetInputSchema,
|
|
548
|
+
outputSchema: previewBusinessDocumentOffsetOutputSchema,
|
|
549
|
+
annotations: prepareAnnotations,
|
|
550
|
+
async execute(rawInput, context) {
|
|
551
|
+
const input = previewBusinessDocumentOffsetInputSchema.parse(rawInput);
|
|
552
|
+
const capabilities = documentCapabilities(input.document_type);
|
|
553
|
+
const capability = input.candidate_scope === 'internal'
|
|
554
|
+
? capabilities.internalCandidates
|
|
555
|
+
: capabilities.candidates;
|
|
556
|
+
const candidates = await context.callCapability(capability, { document_id: input.document_id }, input.context.org_id);
|
|
557
|
+
const candidateSnapshot = offsetCandidatesSnapshot(candidates);
|
|
558
|
+
const available = candidateRecords(candidateSnapshot);
|
|
559
|
+
const selectedCandidates = input.allocations.map((allocation) => {
|
|
560
|
+
const candidate = available.get(`${allocation.source_type}:${allocation.transaction_id}`);
|
|
561
|
+
if (candidate === undefined) {
|
|
562
|
+
throw new FinTaxError('CONFLICT', 'The selected offset transaction is no longer in the current candidate list; select it again');
|
|
563
|
+
}
|
|
564
|
+
return candidate;
|
|
565
|
+
});
|
|
566
|
+
return issueOperationPlan({
|
|
567
|
+
context,
|
|
568
|
+
executeTool: 'execute_business_document_offset',
|
|
569
|
+
targetType: `${input.document_type}_offset`,
|
|
570
|
+
targetIds: [input.document_id],
|
|
571
|
+
targetVersions: [],
|
|
572
|
+
orgId: input.context.org_id,
|
|
573
|
+
parameters: input,
|
|
574
|
+
preview: candidateSnapshot,
|
|
575
|
+
operation: sourceOperation(capability),
|
|
576
|
+
publicPreview: {
|
|
577
|
+
document_type: input.document_type,
|
|
578
|
+
document_id: input.document_id,
|
|
579
|
+
candidate_scope: input.candidate_scope,
|
|
580
|
+
selected_candidates: selectedCandidates,
|
|
581
|
+
offset_date: input.offset_date,
|
|
582
|
+
gl_date: input.gl_date,
|
|
583
|
+
period: input.period ?? null,
|
|
584
|
+
},
|
|
585
|
+
outputSchema: previewBusinessDocumentOffsetOutputSchema,
|
|
586
|
+
privatePayload: {
|
|
587
|
+
document_type: input.document_type,
|
|
588
|
+
document_id: input.document_id,
|
|
589
|
+
candidate_scope: input.candidate_scope,
|
|
590
|
+
body: {
|
|
591
|
+
txnRefs: input.allocations.map((allocation) => ({
|
|
592
|
+
sourceType: allocation.source_type,
|
|
593
|
+
sourceId: allocation.transaction_id,
|
|
594
|
+
})),
|
|
595
|
+
offsetDate: input.offset_date,
|
|
596
|
+
glDate: input.gl_date,
|
|
597
|
+
mode: 'APPEND',
|
|
598
|
+
periodName: input.period,
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
},
|
|
603
|
+
summarize: offsetPlanSummary,
|
|
604
|
+
};
|
|
605
|
+
export const executeBusinessDocumentOffsetTool = {
|
|
606
|
+
name: 'execute_business_document_offset',
|
|
607
|
+
title: 'Execute Receivable or Payable Offset',
|
|
608
|
+
description: 'Consume a user-confirmed plan issued by preview_business_document_offset and apply the offset. It does not clear existing offsets and never uses a REPLACE deletion path.',
|
|
609
|
+
risk: 'R2',
|
|
610
|
+
exposurePack: 'workflow',
|
|
611
|
+
capabilityIds: [
|
|
612
|
+
'suite.ap.payable.offset_apply',
|
|
613
|
+
'suite.ar.receivable.offset_apply',
|
|
614
|
+
'suite.ap.payable.offset_candidates',
|
|
615
|
+
'suite.ap.payable.internal_offset_candidates',
|
|
616
|
+
'suite.ar.receivable.offset_candidates',
|
|
617
|
+
'suite.ar.receivable.internal_offset_candidates',
|
|
618
|
+
],
|
|
619
|
+
fileAccess: 'none',
|
|
620
|
+
inputSchema: executeBusinessDocumentOffsetInputSchema,
|
|
621
|
+
outputSchema: operationResultSchemas.execute_business_document_offset,
|
|
622
|
+
annotations: workflowAnnotations,
|
|
623
|
+
async execute(rawInput, context) {
|
|
624
|
+
const input = executeBusinessDocumentOffsetInputSchema.parse(rawInput);
|
|
625
|
+
const binding = context.operationPlans.inspect(input.operation_plan_id, input.confirmation_token, 'execute_business_document_offset');
|
|
626
|
+
const type = binding.payload?.document_type;
|
|
627
|
+
const capability = documentCapabilities(type).offset;
|
|
628
|
+
return executePlannedOperation({
|
|
629
|
+
toolName: 'execute_business_document_offset',
|
|
630
|
+
operationPlanId: input.operation_plan_id,
|
|
631
|
+
confirmationToken: input.confirmation_token,
|
|
632
|
+
idempotencyKey: input.idempotency_key,
|
|
633
|
+
orgId: input.context.org_id,
|
|
634
|
+
capabilityId: capability,
|
|
635
|
+
context,
|
|
636
|
+
sourceOperation: sourceOperation(capability),
|
|
637
|
+
targetType: `${type}_offset`,
|
|
638
|
+
outputSchema: operationResultSchemas.execute_business_document_offset,
|
|
639
|
+
projectResult: documentOffsetResult,
|
|
640
|
+
recovery: {
|
|
641
|
+
tool: type === 'payable'
|
|
642
|
+
? 'get_payable_document'
|
|
643
|
+
: 'get_receivable_document',
|
|
644
|
+
input: {
|
|
645
|
+
document_id: binding.subject_id,
|
|
646
|
+
context: { org_id: input.context.org_id },
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
validatePlan: async (plan) => {
|
|
650
|
+
const capabilities = documentCapabilities(type);
|
|
651
|
+
const candidateCapability = plan.payload?.candidate_scope === 'internal'
|
|
652
|
+
? capabilities.internalCandidates
|
|
653
|
+
: capabilities.candidates;
|
|
654
|
+
const candidates = await context.callCapability(candidateCapability, { document_id: plan.payload?.document_id }, input.context.org_id);
|
|
655
|
+
if (hashOperationValue(offsetCandidatesSnapshot(candidates)) !==
|
|
656
|
+
plan.preview_hash) {
|
|
657
|
+
throw new FinTaxError('CONFIRMATION_REQUIRED', 'The offset candidates changed; run the preview again');
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
buildCapabilityInput: (plan) => ({
|
|
661
|
+
document_id: plan.payload?.document_id,
|
|
662
|
+
body: plan.payload?.body,
|
|
663
|
+
}),
|
|
664
|
+
});
|
|
665
|
+
},
|
|
666
|
+
summarize: resultSummary,
|
|
667
|
+
};
|
|
668
|
+
export const workflowTools = [
|
|
669
|
+
prepareJournalSubmissionTool,
|
|
670
|
+
submitJournalsTool,
|
|
671
|
+
submitBusinessDocumentTool,
|
|
672
|
+
prepareBusinessDocumentPostTool,
|
|
673
|
+
executeBusinessDocumentPostTool,
|
|
674
|
+
queryBusinessDocumentOffsetCandidatesTool,
|
|
675
|
+
previewBusinessDocumentOffsetTool,
|
|
676
|
+
executeBusinessDocumentOffsetTool,
|
|
677
|
+
];
|
|
678
|
+
//# sourceMappingURL=workflow-tools.js.map
|