@aurorajs.dev/catalyst-cli 3.1.2 → 3.1.3
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 +1 -1
- package/dist/ai/domain/skills-scanner.js +7 -2
- package/dist/deploy/domain/curl-config.js +1 -1
- package/dist/deploy/domain/playbook-vars.js +1 -1
- package/dist/generator/domain/frontend-composition.js +4 -4
- package/dist/generator/domain/property-filters.d.ts +8 -0
- package/dist/generator/domain/property-filters.js +17 -6
- package/dist/generator/handlers/front.handler.js +10 -1
- package/dist/sheets/domain/auth.js +10 -5
- package/dist/sheets/sync/sheet-to-yaml.d.ts +1 -0
- package/dist/sheets/sync/sheet-to-yaml.js +19 -3
- package/dist/templates/backend/application/.claude/skills/catalyst-tools/SKILL.md +5 -3
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-catalog-section-reader.spec.ts +4 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.spec.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.ts +2 -1
- package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual-section-reader.port.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual.types.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual-graphql-schema.spec.ts +10 -2
- package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual.graphql +4 -0
- package/dist/templates/backend/business-rules/business-partner-portal/supplier-document.md +96 -6
- package/dist/templates/backend/business-rules/tools/assistant-usage.md +60 -0
- package/dist/templates/backend/manual/business-partner-portal/CONTEXT.md +5 -5
- package/dist/templates/backend/manual/business-partner-portal/en/purchase-invoice-header.md +5 -1
- package/dist/templates/backend/manual/business-partner-portal/es/purchase-invoice-header.md +5 -1
- package/dist/templates/backend/manual/production-planning/en/planner.md +1 -1
- package/dist/templates/backend/manual/production-planning/en/production-order-position-event.md +8 -5
- package/dist/templates/backend/manual/production-planning/es/planner.md +1 -1
- package/dist/templates/backend/manual/production-planning/es/production-order-position-event.md +8 -5
- package/dist/templates/backend/manual/reporting/en/report.md +40 -0
- package/dist/templates/backend/manual/reporting/es/report.md +40 -0
- package/dist/templates/backend/manual/tools/CONTEXT.md +1 -0
- package/dist/templates/backend/manual/tools/actions.yaml +11 -0
- package/dist/templates/backend/manual/tools/en/assistant-conversation.md +38 -0
- package/dist/templates/backend/manual/tools/en/assistant-usage-policy.md +46 -0
- package/dist/templates/backend/manual/tools/en/assistant-usage.md +28 -0
- package/dist/templates/backend/manual/tools/en/file-storage.md +83 -0
- package/dist/templates/backend/manual/tools/es/assistant-conversation.md +38 -0
- package/dist/templates/backend/manual/tools/es/assistant-usage-policy.md +46 -0
- package/dist/templates/backend/manual/tools/es/assistant-usage.md +28 -0
- package/dist/templates/backend/manual/tools/es/file-storage.md +83 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/infrastructure/business-partner-portal-anthropic-extraction-step-two.service.spec.ts +2 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-one-request.function.spec.ts +9 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-one-request.function.ts +6 -3
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-two-request.function.spec.ts +19 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-two-request.function.ts +15 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-map-step-one-answer.function.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/types/business-partner-portal-anthropic-step-one-answer.types.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-context.service.spec.ts +63 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-context.service.ts +25 -3
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-empty.service.spec.ts +1 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two.types.ts +5 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/purchase-invoice-extraction/business-partner-portal-map-invoice-ocr-result-to-purchase-invoice.function.spec.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/purchase-invoice-extraction/business-partner-portal-map-invoice-ocr-result-to-purchase-invoice.function.ts +1 -1
- package/dist/templates/backend/packages/production-planning/src/@app/production-planning/production-order-position/application/get-processes/production-planning-get-processes-production-order-position.handler.spec.ts +5 -2
- package/dist/templates/backend/packages/production-planning/src/@app/production-planning/production-order-position/application/get-processes/production-planning-get-processes-production-order-position.handler.ts +4 -0
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-create-report.dto.ts +0 -21
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-report.dto.ts +3 -3
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-report-by-id.dto.ts +0 -48
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-reports.dto.ts +0 -48
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/graphql/reporting-report.graphql +3 -20
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/create/reporting-create-report.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/reporting-report.payload-types.ts +33 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.handler.spec.ts +77 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-reports.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update-execution-cache/reporting-update-report-execution-cache.handler.spec.ts +35 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/domain/reporting-report.field-schema.ts +7 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/index.ts +5 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-assistant-conversation.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversation-by-id.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversations.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/graphql/tools-assistant-conversation.graphql +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/controllers/tools-ask-assistant-assistant-usage.controller.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-ask-assistant.dto.ts +47 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-answer.dto.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-usage.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usage-by-id.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usages.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/graphql/tools-assistant-usage.graphql +45 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/resolvers/tools-ask-assistant-assistant-usage.resolver.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/infrastructure/tools-anthropic-assistant-model.service.spec.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.spec.ts +145 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.ts +44 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/types/tools-anthropic-assistant-answer.types.ts +3 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/domain/tools-assistant-conversation.field-schema.ts +6 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/infrastructure/drizzle/tools-drizzle-assistant-conversation.schema.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.spec.ts +105 -5
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.ts +40 -23
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-errors.function.ts +8 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.spec.ts +257 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.ts +200 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.spec.ts +7 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.ts +7 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-model.port.ts +44 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-usage.field-schema.ts +6 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.spec.ts +25 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.ts +3 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.schema.ts +1 -0
- package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-ask.e2e-spec.ts +16 -1
- package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-usage-increment.e2e-spec.ts +52 -5
- package/dist/templates/codegen/frontend/module/__module_name__/features/__module_name__-list.component.ts.eta +7 -1
- package/dist/templates/codegen/frontend/module/__module_name__/features/index.ts.eta +1 -1
- package/dist/templates/frontend/application/.claude/skills/catalyst-project-structure/SKILL.md +3 -0
- package/dist/templates/frontend/application/libs/ui/command/src/lib/hlm-command-item.ts +1 -1
- package/dist/templates/frontend/application/src/@aurora/modules/assisted-form/README.md +2 -0
- package/dist/templates/frontend/application/src/@aurora/modules/command-palette/command-palette-trigger.component.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/README.md +4 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.spec.ts +69 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.ts +13 -4
- package/dist/templates/frontend/application/src/@aurora/modules/index.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/manual/manual.graphql.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/README.md +36 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/index.ts +2 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.spec.ts +137 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.ts +60 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.types.ts +47 -0
- package/dist/templates/frontend/application/src/app/domains/admin/layout/site-header.ts +1 -1
- package/dist/templates/frontend/application/tsconfig.json +1 -0
- package/dist/templates/frontend/navigation-i18n/reporting/en.json +1 -1
- package/dist/templates/frontend/navigation-i18n/reporting/es.json +1 -1
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/index.ts +0 -1
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/state-machine-history-list.component.ts +0 -13
- package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/en.json +11 -0
- package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/es.json +11 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review-context.derive.spec.ts +420 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review-context.derive.ts +237 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review.derive.spec.ts +181 -26
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review.derive.ts +143 -25
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-detail.component.spec.ts +42 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-detail.component.ts +32 -8
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-form.component.ts +32 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-list-actions-cell.component.ts +4 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/ui/purchase-invoice-breakdown.component.ts +7 -32
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/ui/purchase-invoice-lines-grid.component.ts +12 -8
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/index.ts +0 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/purchase-invoice-trace-list.component.ts +0 -13
- package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.spec.ts +26 -1
- package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.ts +45 -0
- package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/en.json +15 -4
- package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/es.json +15 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/index.ts +1 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner-process-weights.derive.spec.ts +57 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner-process-weights.derive.ts +39 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.spec.ts +15 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.ts +7 -3
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.graphql.ts +23 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner-process-weights-dialog.component.ts +137 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner.component.ts +41 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.derive.spec.ts +0 -30
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.derive.ts +0 -21
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.resolvers.spec.ts +24 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.resolvers.ts +3 -1
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/batch-detail-sheet.component.ts +22 -10
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-form-sheet.component.spec.ts +142 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-form-sheet.component.ts +95 -59
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-list.component.ts +121 -123
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/production-dashboard.component.ts +52 -19
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position/features/production-order-position-list.component.ts +8 -2
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/features/production-order-position-event-list.component.ts +4 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/production-order-position-event.columns.spec.ts +104 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/production-order-position-event.columns.ts +121 -69
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/finish-event-dialog.component.ts +3 -3
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/weight-input-dialog.component.ts +3 -3
- package/dist/templates/frontend/packages/reporting/public/i18n/reporting/en.json +1 -1
- package/dist/templates/frontend/packages/reporting/public/i18n/reporting/es.json +1 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.detail-config.ts +1 -2
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.graphql.ts +0 -14
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.spec.ts +96 -0
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.ts +46 -69
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-list.component.ts +2 -22
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/report.columns.ts +0 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting-icons.providers.ts +2 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting.navigation.ts +7 -0
- package/dist/templates/frontend/packages/tools/public/i18n/tools/en.json +4 -2
- package/dist/templates/frontend/packages/tools/public/i18n/tools/es.json +4 -2
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.spec.ts +82 -7
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.ts +12 -2
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/assistant-conversation.columns.ts +13 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/data-access/assistant-conversation.graphql.ts +1 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-form.component.ts +18 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list.component.ts +0 -13
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/index.ts +0 -1
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/assistant-usage.columns.ts +13 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/data-access/assistant-usage.graphql.ts +2 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-form.component.ts +18 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list.component.ts +0 -13
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/index.ts +0 -1
- package/dist/templates/monorepo/.claude/commands/business-rules/promote.md +5 -1
- package/dist/templates/monorepo/.claude/hooks/__fixtures__/br-hr-regression-baseline.txt +2 -2
- package/dist/templates/monorepo/.claude/hooks/check-required-setup.ts +4 -4
- package/dist/templates/monorepo/.claude/hooks/inject-prompt-context.ts +1 -1
- package/dist/templates/monorepo/.claude/scripts/generate-skills-index.test.ts +29 -1
- package/dist/templates/monorepo/.claude/scripts/generate-skills-index.ts +7 -1
- package/dist/templates/monorepo/.claude/skills/REGISTRY.md +2 -2
- package/dist/templates/monorepo/.claude/skills/catalyst-backlog/SKILL.md +19 -4
- package/dist/templates/monorepo/.claude/skills/catalyst-backlog/frontier-worker-addendum.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/SKILL.md +8 -5
- package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/references/workflow.md +10 -6
- package/dist/templates/monorepo/.claude/skills/catalyst-delegation/SKILL.md +1 -1
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/SKILL.md +6 -6
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/enforcement.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/format.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-update-skill-registry/SKILL.md +4 -4
- package/dist/templates/monorepo/.claude/skills/catalyst-user-manual/SKILL.md +48 -2
- package/dist/templates/monorepo/.claude/skills/openspec-apply-change/SKILL.md +28 -10
- package/dist/templates/monorepo/.claude/skills/openspec-archive-change/SKILL.md +52 -13
- package/dist/templates/monorepo/.claude/skills/openspec-explore/SKILL.md +59 -14
- package/dist/templates/monorepo/.claude/skills/openspec-propose/SKILL.md +38 -12
- package/dist/templates/monorepo/.claude/skills/openspec-sync-specs/SKILL.md +31 -3
- package/dist/templates/monorepo/CLAUDE.md +14 -14
- package/dist/templates/monorepo/docs/business-rules/ARCHITECTURE.md +16 -13
- package/dist/templates/monorepo/docs/business-rules/MIGRATION.md +5 -5
- package/dist/templates/monorepo/docs/manual/en/04-asistente.md +71 -0
- package/dist/templates/monorepo/docs/manual/es/04-asistente.md +71 -0
- package/dist/templates/monorepo/openspec/config.yaml +25 -5
- package/dist/templates/monorepo/package.json +3 -1
- package/dist/templates/monorepo/scripts/backlog/prompt.test.ts +5 -5
- package/dist/templates/monorepo/scripts/backlog/prompt.ts +1 -1
- package/dist/templates/monorepo/scripts/business-rules/audit.ts +1 -1
- package/dist/templates/monorepo/scripts/manual/compile.test.ts +78 -0
- package/dist/templates/monorepo/scripts/manual/compile.ts +36 -9
- package/dist/templates/monorepo/scripts/worktree/prune.test.ts +517 -0
- package/dist/templates/monorepo/scripts/worktree/prune.ts +331 -0
- package/oclif.manifest.json +85 -85
- package/package.json +15 -17
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/state-machine-history-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/purchase-invoice-trace-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list-actions-cell.component.ts +0 -43
- package/dist/templates/monorepo/.claude/commands/opsx/apply.md +0 -184
- package/dist/templates/monorepo/.claude/commands/opsx/archive.md +0 -225
- package/dist/templates/monorepo/.claude/commands/opsx/explore.md +0 -196
- package/dist/templates/monorepo/.claude/commands/opsx/propose.md +0 -145
- package/dist/templates/monorepo/.claude/commands/opsx/sync.md +0 -258
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { type BusinessPartnerPortalPurchaseInvoiceHeader } from '@src/src/app/aurora.types';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import {
|
|
4
|
+
reviewScreenActions,
|
|
5
|
+
reviewScreenActionsOf,
|
|
6
|
+
reviewScreenFacts,
|
|
7
|
+
reviewScreenIssues,
|
|
8
|
+
reviewScreenRows,
|
|
9
|
+
reviewScreenStatus,
|
|
10
|
+
type ReviewFactsSource,
|
|
11
|
+
type ReviewRowsSource,
|
|
12
|
+
} from './purchase-invoice-review-context.derive';
|
|
13
|
+
import {
|
|
14
|
+
type PurchaseInvoiceReviewView,
|
|
15
|
+
type PurchaseInvoiceReviewWarning,
|
|
16
|
+
type ReviewPositionModel,
|
|
17
|
+
} from './purchase-invoice-review.derive';
|
|
18
|
+
|
|
19
|
+
const KEY = 'business-partner-portal.purchase-invoice-header';
|
|
20
|
+
|
|
21
|
+
/** Echoes the key and its params so a wrong key or figure fails the assertion. */
|
|
22
|
+
const translate = (key: string, params?: Record<string, unknown>): string =>
|
|
23
|
+
params ? `${key}|${JSON.stringify(params)}` : key;
|
|
24
|
+
|
|
25
|
+
function invoiceWith(
|
|
26
|
+
stateCode: string | null,
|
|
27
|
+
issues: string[] = [],
|
|
28
|
+
businessPartnerId: string | null = 'bp-1',
|
|
29
|
+
category = 'REVIEW',
|
|
30
|
+
): BusinessPartnerPortalPurchaseInvoiceHeader {
|
|
31
|
+
return {
|
|
32
|
+
id: 'inv-1',
|
|
33
|
+
invoiceNumber: 'INV-0001',
|
|
34
|
+
businessPartnerId,
|
|
35
|
+
issues,
|
|
36
|
+
state: stateCode
|
|
37
|
+
? {
|
|
38
|
+
code: stateCode,
|
|
39
|
+
category: { code: category },
|
|
40
|
+
nameI18n: { es: 'En revisión', en: 'In review' },
|
|
41
|
+
translatedLocales: ['es', 'en'],
|
|
42
|
+
}
|
|
43
|
+
: null,
|
|
44
|
+
erpStatus: null,
|
|
45
|
+
} as unknown as BusinessPartnerPortalPurchaseInvoiceHeader;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const byAction = (states: { action: string }[], action: string) =>
|
|
49
|
+
states.find((state) => state.action === action);
|
|
50
|
+
|
|
51
|
+
describe('reviewScreenActionsOf', () => {
|
|
52
|
+
it('offers Modify and Reprocess and explains the missing supplier of Accept review', () => {
|
|
53
|
+
const actions = reviewScreenActionsOf(
|
|
54
|
+
invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT'], null),
|
|
55
|
+
'view',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(actions.map(({ action }) => action)).toEqual([
|
|
59
|
+
'MODIFY',
|
|
60
|
+
'REPROCESS',
|
|
61
|
+
'ACCEPT_DUPLICATE',
|
|
62
|
+
'ACCEPT_REVIEW',
|
|
63
|
+
'RELEASE_HOLD',
|
|
64
|
+
'SAVE',
|
|
65
|
+
'CANCEL',
|
|
66
|
+
]);
|
|
67
|
+
expect(byAction(actions, 'MODIFY')).toMatchObject({ available: true, missingConditions: [] });
|
|
68
|
+
expect(byAction(actions, 'REPROCESS')).toMatchObject({ available: true });
|
|
69
|
+
expect(byAction(actions, 'ACCEPT_REVIEW')).toEqual({
|
|
70
|
+
action: 'ACCEPT_REVIEW',
|
|
71
|
+
available: false,
|
|
72
|
+
missingConditions: ['SUPPLIER_ASSIGNED'],
|
|
73
|
+
});
|
|
74
|
+
expect(byAction(actions, 'SAVE')).toEqual({
|
|
75
|
+
action: 'SAVE',
|
|
76
|
+
available: false,
|
|
77
|
+
missingConditions: ['EDIT_MODE'],
|
|
78
|
+
});
|
|
79
|
+
expect(byAction(actions, 'CANCEL')).toMatchObject({
|
|
80
|
+
available: false,
|
|
81
|
+
missingConditions: ['EDIT_MODE'],
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('offers Save and Cancel in edit mode and hides Modify and every flow action', () => {
|
|
86
|
+
const actions = reviewScreenActionsOf(invoiceWith('IN_REVIEW', ['DUPLICATED']), 'edit');
|
|
87
|
+
|
|
88
|
+
expect(byAction(actions, 'SAVE')).toMatchObject({ available: true, missingConditions: [] });
|
|
89
|
+
expect(byAction(actions, 'CANCEL')).toMatchObject({ available: true });
|
|
90
|
+
// Reprocess is available by state, yet hidden while editing: VIEW_MODE leads the list.
|
|
91
|
+
expect(byAction(actions, 'REPROCESS')).toEqual({
|
|
92
|
+
action: 'REPROCESS',
|
|
93
|
+
available: false,
|
|
94
|
+
missingConditions: ['VIEW_MODE'],
|
|
95
|
+
});
|
|
96
|
+
expect(byAction(actions, 'ACCEPT_DUPLICATE')).toMatchObject({
|
|
97
|
+
available: false,
|
|
98
|
+
missingConditions: ['VIEW_MODE'],
|
|
99
|
+
});
|
|
100
|
+
expect(byAction(actions, 'MODIFY')).toEqual({
|
|
101
|
+
action: 'MODIFY',
|
|
102
|
+
available: false,
|
|
103
|
+
missingConditions: ['VIEW_MODE'],
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('names STATE_EDITABLE when the state is not editable', () => {
|
|
108
|
+
const actions = reviewScreenActionsOf(invoiceWith('SENT', [], 'bp-1', 'SENT'), 'view');
|
|
109
|
+
|
|
110
|
+
expect(byAction(actions, 'MODIFY')).toEqual({
|
|
111
|
+
action: 'MODIFY',
|
|
112
|
+
available: false,
|
|
113
|
+
missingConditions: ['STATE_EDITABLE'],
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('keeps the flow conditions next to VIEW_MODE in edit mode', () => {
|
|
118
|
+
const actions = reviewScreenActionsOf(invoiceWith('SENT', [], 'bp-1', 'SENT'), 'edit');
|
|
119
|
+
|
|
120
|
+
expect(byAction(actions, 'REPROCESS')).toMatchObject({
|
|
121
|
+
missingConditions: ['VIEW_MODE', 'STATE_IN_REVIEW_OR_ERROR'],
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('reviewScreenStatus', () => {
|
|
127
|
+
it('writes the state name in the active language, as the badge does', () => {
|
|
128
|
+
expect(reviewScreenStatus(invoiceWith('IN_REVIEW'), 'es')).toEqual({ label: 'En revisión' });
|
|
129
|
+
expect(reviewScreenStatus(invoiceWith('IN_REVIEW'), 'en')).toEqual({ label: 'In review' });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('is null without an invoice or a state', () => {
|
|
133
|
+
expect(reviewScreenStatus(null, 'es')).toBeNull();
|
|
134
|
+
expect(reviewScreenStatus(invoiceWith(null), 'es')).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('reviewScreenIssues', () => {
|
|
139
|
+
it('translates each issue with the key of the badges', () => {
|
|
140
|
+
expect(
|
|
141
|
+
reviewScreenIssues(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'DUPLICATED']), translate),
|
|
142
|
+
).toEqual([`${KEY}.Issues.DOUBTFUL_DOCUMENT`, `${KEY}.Issues.DUPLICATED`]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('is empty for an invoice without issues and null without an invoice', () => {
|
|
146
|
+
expect(reviewScreenIssues(invoiceWith('IN_REVIEW'), translate)).toEqual([]);
|
|
147
|
+
expect(reviewScreenIssues(null, translate)).toBeNull();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('reviewScreenActions', () => {
|
|
152
|
+
it('translates the labels and the condition names', () => {
|
|
153
|
+
const actions = reviewScreenActions(
|
|
154
|
+
invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT'], null),
|
|
155
|
+
'view',
|
|
156
|
+
translate,
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
expect(actions?.map(({ label }) => label)).toEqual([
|
|
160
|
+
`${KEY}.Modify`,
|
|
161
|
+
`${KEY}.Reprocess`,
|
|
162
|
+
`${KEY}.AcceptDuplicate`,
|
|
163
|
+
`${KEY}.AcceptReview`,
|
|
164
|
+
`${KEY}.ReleaseHold`,
|
|
165
|
+
'Save',
|
|
166
|
+
'Cancel',
|
|
167
|
+
]);
|
|
168
|
+
expect(actions?.[3]).toEqual({
|
|
169
|
+
label: `${KEY}.AcceptReview`,
|
|
170
|
+
available: false,
|
|
171
|
+
missingConditions: [`${KEY}.ScreenCondition.SUPPLIER_ASSIGNED`],
|
|
172
|
+
});
|
|
173
|
+
expect(actions?.[1]).toMatchObject({ available: true, missingConditions: [] });
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('is null without an invoice', () => {
|
|
177
|
+
expect(reviewScreenActions(null, 'view', translate)).toBeNull();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const view = (overrides: Partial<PurchaseInvoiceReviewView> = {}): PurchaseInvoiceReviewView => ({
|
|
182
|
+
positions: [],
|
|
183
|
+
taxBreakdowns: [],
|
|
184
|
+
unassignedReadTaxBreakdowns: [],
|
|
185
|
+
subtotal: 1000,
|
|
186
|
+
taxAmount: 210,
|
|
187
|
+
totalAmount: 1210,
|
|
188
|
+
warnings: { positionTaxes: {}, breakdowns: {}, invoice: [] },
|
|
189
|
+
supplierTin: null,
|
|
190
|
+
legalEntityTin: null,
|
|
191
|
+
...overrides,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const warning = (code: string, detail?: unknown) =>
|
|
195
|
+
({ code, detail }) as unknown as PurchaseInvoiceReviewWarning;
|
|
196
|
+
|
|
197
|
+
describe('reviewScreenFacts', () => {
|
|
198
|
+
const source = (overrides: Partial<ReviewFactsSource> = {}): ReviewFactsSource => ({
|
|
199
|
+
invoice: invoiceWith('IN_REVIEW'),
|
|
200
|
+
model: {
|
|
201
|
+
supplierInvoiceNumber: 'SI-77',
|
|
202
|
+
invoiceDate: '2026-09-01T00:00:00.000Z',
|
|
203
|
+
dueDate: null,
|
|
204
|
+
},
|
|
205
|
+
labels: { supplier: 'ACME · B123', legalEntity: 'Aurora SL' },
|
|
206
|
+
view: view(),
|
|
207
|
+
doubtReasons: [],
|
|
208
|
+
...overrides,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('writes the header values and the totals as the screen shows them', () => {
|
|
212
|
+
const facts = reviewScreenFacts(source(), 'es', translate);
|
|
213
|
+
|
|
214
|
+
expect(facts).toEqual([
|
|
215
|
+
{ label: `${KEY}.InvoiceNumber`, value: 'INV-0001' },
|
|
216
|
+
{ label: `${KEY}.Supplier`, value: 'ACME · B123' },
|
|
217
|
+
{ label: `${KEY}.LegalEntityId`, value: 'Aurora SL' },
|
|
218
|
+
{ label: `${KEY}.SupplierInvoiceNumber`, value: 'SI-77' },
|
|
219
|
+
{ label: `${KEY}.InvoiceDate`, value: '01-09-2026' },
|
|
220
|
+
{ label: `${KEY}.DueDate`, value: '' },
|
|
221
|
+
{ label: `${KEY}.Subtotal`, value: '1.000,00' },
|
|
222
|
+
{ label: `${KEY}.TaxAmount`, value: '210,00' },
|
|
223
|
+
{ label: `${KEY}.TotalAmount`, value: '1.210,00' },
|
|
224
|
+
]);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('adds the ERP status only when the invoice has one', () => {
|
|
228
|
+
const withErp = {
|
|
229
|
+
...invoiceWith('SENT'),
|
|
230
|
+
erpStatus: { nameI18n: { es: 'Contabilizada' }, translatedLocales: ['es'] },
|
|
231
|
+
} as unknown as BusinessPartnerPortalPurchaseInvoiceHeader;
|
|
232
|
+
|
|
233
|
+
expect(reviewScreenFacts(source({ invoice: withErp }), 'es', translate)).toContainEqual({
|
|
234
|
+
label: `${KEY}.ErpStatus`,
|
|
235
|
+
value: 'Contabilizada',
|
|
236
|
+
});
|
|
237
|
+
expect(reviewScreenFacts(source(), 'es', translate)?.map(({ label }) => label)).not.toContain(
|
|
238
|
+
`${KEY}.ErpStatus`,
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('writes the previewed totals, not the stored ones', () => {
|
|
243
|
+
const facts = reviewScreenFacts(
|
|
244
|
+
source({ view: view({ subtotal: 50, taxAmount: 10.5, totalAmount: 60.5 }) }),
|
|
245
|
+
'es',
|
|
246
|
+
translate,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
expect(facts).toContainEqual({ label: `${KEY}.TotalAmount`, value: '60,50' });
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('adds the total mismatch text and one fact per doubt reason', () => {
|
|
253
|
+
const facts = reviewScreenFacts(
|
|
254
|
+
source({
|
|
255
|
+
view: view({
|
|
256
|
+
warnings: {
|
|
257
|
+
positionTaxes: {},
|
|
258
|
+
breakdowns: {},
|
|
259
|
+
invoice: [warning('TOTAL_AMOUNT_MISMATCH', { expectedAmount: 1210, readAmount: 1200 })],
|
|
260
|
+
},
|
|
261
|
+
}),
|
|
262
|
+
doubtReasons: [
|
|
263
|
+
{ code: 'KEY_FIELD_MISSING', params: { field: 'totalAmount' } },
|
|
264
|
+
{ code: 'NOT_RECONCILED', params: { humanReviewReason: 'x' } },
|
|
265
|
+
],
|
|
266
|
+
}),
|
|
267
|
+
'es',
|
|
268
|
+
translate,
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
expect(facts).toContainEqual({
|
|
272
|
+
label: `${KEY}.TotalAmount`,
|
|
273
|
+
value: `${KEY}.TotalMismatch|{"expected":"1.210,00","read":"1.200,00"}`,
|
|
274
|
+
});
|
|
275
|
+
expect(facts).toContainEqual({
|
|
276
|
+
label: `${KEY}.Issues.DOUBTFUL_DOCUMENT`,
|
|
277
|
+
value: `${KEY}.DoubtReason.KEY_FIELD_MISSING|{"field":"totalAmount"}`,
|
|
278
|
+
});
|
|
279
|
+
expect(facts?.filter(({ label }) => label === `${KEY}.Issues.DOUBTFUL_DOCUMENT`)).toHaveLength(
|
|
280
|
+
2,
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('is null without an invoice', () => {
|
|
285
|
+
expect(reviewScreenFacts(source({ invoice: null }), 'es', translate)).toBeNull();
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe('reviewScreenRows', () => {
|
|
290
|
+
const position = (id: string, description: string, taxIds: string[]): ReviewPositionModel =>
|
|
291
|
+
({
|
|
292
|
+
id,
|
|
293
|
+
positionNumber: 0,
|
|
294
|
+
description,
|
|
295
|
+
taxes: taxIds.map((taxId) => ({ id: taxId, taxId: null, label: null, percentage: null })),
|
|
296
|
+
}) as unknown as ReviewPositionModel;
|
|
297
|
+
|
|
298
|
+
const source = (overrides: Partial<ReviewRowsSource> = {}): ReviewRowsSource => ({
|
|
299
|
+
positions: [
|
|
300
|
+
position('p1', 'Bolts', ['t1']),
|
|
301
|
+
position('p2', 'Nuts', ['t2']),
|
|
302
|
+
position('p3', 'Washers', ['t3']),
|
|
303
|
+
],
|
|
304
|
+
view: view({
|
|
305
|
+
taxBreakdowns: [
|
|
306
|
+
{ key: 'tax-1', taxId: 'tax-1', percentage: 21, amount: 10 },
|
|
307
|
+
{ key: 'UNMATCHED:7', taxId: null, label: 'IGIC', percentage: 7, amount: 3 },
|
|
308
|
+
],
|
|
309
|
+
warnings: {
|
|
310
|
+
positionTaxes: { t2: [warning('TAX_UNMATCHED')] },
|
|
311
|
+
breakdowns: {
|
|
312
|
+
'UNMATCHED:7': [warning('TAX_AMOUNT_MISMATCH', { expectedAmount: 3, readAmount: 4 })],
|
|
313
|
+
},
|
|
314
|
+
invoice: [],
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
taxNames: { 'tax-1': 'IVA 21%' },
|
|
318
|
+
...overrides,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('counts the lines and lists only the warned ones, numbered as displayed', () => {
|
|
322
|
+
const [lines] = reviewScreenRows(source(), translate);
|
|
323
|
+
|
|
324
|
+
expect(lines).toEqual({
|
|
325
|
+
label: `${KEY}.LinesTitle`,
|
|
326
|
+
count: 3,
|
|
327
|
+
rows: [
|
|
328
|
+
{
|
|
329
|
+
label: `${KEY}.ScreenContextLine|{"number":2,"description":"Nuts"}`,
|
|
330
|
+
warnings: [`${KEY}.TaxUnmatched`],
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('reads the taxes of a line from the preview when it derived them', () => {
|
|
337
|
+
const [lines] = reviewScreenRows(
|
|
338
|
+
source({
|
|
339
|
+
view: view({
|
|
340
|
+
positions: [{ id: 'p1', taxes: [{ id: 'derived-1' }] }],
|
|
341
|
+
warnings: {
|
|
342
|
+
positionTaxes: { 'derived-1': [warning('TAX_UNMATCHED')], t1: [] },
|
|
343
|
+
breakdowns: {},
|
|
344
|
+
invoice: [],
|
|
345
|
+
},
|
|
346
|
+
}),
|
|
347
|
+
}),
|
|
348
|
+
translate,
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
expect(lines?.rows.map(({ label }) => label)).toEqual([
|
|
352
|
+
`${KEY}.ScreenContextLine|{"number":1,"description":"Bolts"}`,
|
|
353
|
+
]);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('keeps one row per line and prefixes each warning with the badge text of its tax', () => {
|
|
357
|
+
const mismatch = (expectedAmount: number) =>
|
|
358
|
+
warning('TAX_AMOUNT_MISMATCH', { expectedAmount, readAmount: 0 });
|
|
359
|
+
const twoTaxes = {
|
|
360
|
+
...position('p1', 'Bolts', []),
|
|
361
|
+
taxes: [
|
|
362
|
+
{ id: 'a', taxId: 'tax-1', label: 'stored', percentage: 21, amount: null },
|
|
363
|
+
{ id: 'b', taxId: null, label: 'IGIC', percentage: 7, amount: null },
|
|
364
|
+
],
|
|
365
|
+
} as unknown as ReviewPositionModel;
|
|
366
|
+
|
|
367
|
+
const [lines] = reviewScreenRows(
|
|
368
|
+
source({
|
|
369
|
+
positions: [twoTaxes],
|
|
370
|
+
taxNames: { 'tax-1': 'IVA' },
|
|
371
|
+
view: view({
|
|
372
|
+
warnings: {
|
|
373
|
+
positionTaxes: {
|
|
374
|
+
a: [warning('TAX_UNMATCHED'), mismatch(1)],
|
|
375
|
+
b: [warning('TAX_UNMATCHED'), mismatch(2)],
|
|
376
|
+
},
|
|
377
|
+
breakdowns: {},
|
|
378
|
+
invoice: [],
|
|
379
|
+
},
|
|
380
|
+
}),
|
|
381
|
+
}),
|
|
382
|
+
translate,
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
expect(lines?.rows).toEqual([
|
|
386
|
+
{
|
|
387
|
+
label: `${KEY}.ScreenContextLine|{"number":1,"description":"Bolts"}`,
|
|
388
|
+
warnings: [
|
|
389
|
+
`IVA 21%: ${KEY}.TaxUnmatched`,
|
|
390
|
+
`IVA 21%: ${KEY}.RowAmountMismatch|{"expected":"1,00","read":"0,00"}`,
|
|
391
|
+
`IGIC 7%: ${KEY}.TaxUnmatched`,
|
|
392
|
+
`IGIC 7%: ${KEY}.RowAmountMismatch|{"expected":"2,00","read":"0,00"}`,
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
]);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('counts the breakdown rows and lists only the warned ones with the tax text', () => {
|
|
399
|
+
const [, breakdown] = reviewScreenRows(source(), translate);
|
|
400
|
+
|
|
401
|
+
expect(breakdown).toEqual({
|
|
402
|
+
label: `${KEY}.BreakdownTitle`,
|
|
403
|
+
count: 2,
|
|
404
|
+
rows: [
|
|
405
|
+
{
|
|
406
|
+
label: 'IGIC 7%',
|
|
407
|
+
warnings: [`${KEY}.RowAmountMismatch|{"expected":"3,00","read":"4,00"}`],
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('lists no rows when nothing carries a warning', () => {
|
|
414
|
+
const clean = source({
|
|
415
|
+
view: view({ warnings: { positionTaxes: {}, breakdowns: {}, invoice: [] } }),
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
expect(reviewScreenRows(clean, translate).map(({ rows }) => rows)).toEqual([[], []]);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the invoice review screen tells the assistant (`ScreenContextService`). Every builder here
|
|
3
|
+
* is a pure function over the same sources the screen renders from (`flowActionsOf`,
|
|
4
|
+
* `reviewWarningText`, `breakdownTaxText`, the preview view), so the context cannot say anything
|
|
5
|
+
* the screen does not show. Translation is injected: the builders run without Angular.
|
|
6
|
+
*/
|
|
7
|
+
import { formatIsoDate } from '@aurora';
|
|
8
|
+
import { resolveI18nValue } from '@aurora/lib';
|
|
9
|
+
import {
|
|
10
|
+
type ScreenAction,
|
|
11
|
+
type ScreenFact,
|
|
12
|
+
type ScreenStatus,
|
|
13
|
+
type ScreenTable,
|
|
14
|
+
} from '@aurora/modules/screen-context';
|
|
15
|
+
import { type BusinessPartnerPortalPurchaseInvoiceHeader } from '@src/src/app/aurora.types';
|
|
16
|
+
import {
|
|
17
|
+
breakdownTaxText,
|
|
18
|
+
flowActionsOf,
|
|
19
|
+
formatAmount,
|
|
20
|
+
isInvoiceEditable,
|
|
21
|
+
lineTaxText,
|
|
22
|
+
reviewWarningText,
|
|
23
|
+
type PurchaseInvoiceReviewModel,
|
|
24
|
+
type PurchaseInvoiceReviewView,
|
|
25
|
+
type ReviewFlowAction,
|
|
26
|
+
type ReviewFlowConditionCode,
|
|
27
|
+
type ReviewPositionModel,
|
|
28
|
+
} from './purchase-invoice-review.derive';
|
|
29
|
+
|
|
30
|
+
const KEY = 'business-partner-portal.purchase-invoice-header';
|
|
31
|
+
|
|
32
|
+
/** The id the detail and the form contribute their sections under; both must use the same one. */
|
|
33
|
+
export const REVIEW_SCREEN_ID = 'business-partner-portal.purchase-invoice-header';
|
|
34
|
+
|
|
35
|
+
type Invoice = BusinessPartnerPortalPurchaseInvoiceHeader | null | undefined;
|
|
36
|
+
type Translate = (key: string, params?: Record<string, unknown>) => string;
|
|
37
|
+
|
|
38
|
+
export type ReviewScreenAction = 'MODIFY' | ReviewFlowAction | 'SAVE' | 'CANCEL';
|
|
39
|
+
|
|
40
|
+
export type ReviewScreenConditionCode =
|
|
41
|
+
ReviewFlowConditionCode | 'VIEW_MODE' | 'EDIT_MODE' | 'STATE_EDITABLE';
|
|
42
|
+
|
|
43
|
+
export interface ReviewScreenActionState {
|
|
44
|
+
action: ReviewScreenAction;
|
|
45
|
+
available: boolean;
|
|
46
|
+
missingConditions: ReviewScreenConditionCode[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The key each toolbar button shows; the detail's buttons and the context read the same one. */
|
|
50
|
+
export const REVIEW_ACTION_LABEL_KEYS: Record<ReviewScreenAction, string> = {
|
|
51
|
+
MODIFY: `${KEY}.Modify`,
|
|
52
|
+
REPROCESS: `${KEY}.Reprocess`,
|
|
53
|
+
ACCEPT_DUPLICATE: `${KEY}.AcceptDuplicate`,
|
|
54
|
+
ACCEPT_REVIEW: `${KEY}.AcceptReview`,
|
|
55
|
+
RELEASE_HOLD: `${KEY}.ReleaseHold`,
|
|
56
|
+
SAVE: 'Save',
|
|
57
|
+
CANCEL: 'Cancel',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const stateOf = (
|
|
61
|
+
action: ReviewScreenAction,
|
|
62
|
+
missingConditions: ReviewScreenConditionCode[],
|
|
63
|
+
): ReviewScreenActionState => ({
|
|
64
|
+
action,
|
|
65
|
+
available: missingConditions.length === 0,
|
|
66
|
+
missingConditions,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Every button of the toolbar with the conditions it is missing, from the same sources the toolbar
|
|
71
|
+
* reads: the mode, `isInvoiceEditable` and `flowActionsOf`. Available means the screen shows it.
|
|
72
|
+
*
|
|
73
|
+
* @rule BR-BPP-PURCHASE-INVOICE-HEADER-057
|
|
74
|
+
*/
|
|
75
|
+
export function reviewScreenActionsOf(
|
|
76
|
+
invoice: Invoice,
|
|
77
|
+
mode: 'view' | 'edit',
|
|
78
|
+
): ReviewScreenActionState[] {
|
|
79
|
+
const isEditing = mode === 'edit';
|
|
80
|
+
const modify: ReviewScreenConditionCode[] = [];
|
|
81
|
+
if (isEditing) modify.push('VIEW_MODE');
|
|
82
|
+
if (!isInvoiceEditable(invoice)) modify.push('STATE_EDITABLE');
|
|
83
|
+
|
|
84
|
+
const flow = flowActionsOf(invoice).map(({ action, missingConditions }) =>
|
|
85
|
+
stateOf(action, [...(isEditing ? (['VIEW_MODE'] as const) : []), ...missingConditions]),
|
|
86
|
+
);
|
|
87
|
+
const editOnly: ReviewScreenConditionCode[] = isEditing ? [] : ['EDIT_MODE'];
|
|
88
|
+
|
|
89
|
+
return [
|
|
90
|
+
stateOf('MODIFY', modify),
|
|
91
|
+
...flow,
|
|
92
|
+
stateOf('SAVE', editOnly),
|
|
93
|
+
stateOf('CANCEL', editOnly),
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The state name in the active language, as the badge shows it. */
|
|
98
|
+
export function reviewScreenStatus(invoice: Invoice, lang: string): ScreenStatus | null {
|
|
99
|
+
const name = resolveI18nValue(invoice?.state?.nameI18n, lang, invoice?.state?.translatedLocales);
|
|
100
|
+
|
|
101
|
+
return name ? { label: name } : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The issues with the keys of the badges; null while no invoice is loaded. */
|
|
105
|
+
export function reviewScreenIssues(invoice: Invoice, translate: Translate): string[] | null {
|
|
106
|
+
if (!invoice) return null;
|
|
107
|
+
|
|
108
|
+
return (invoice.issues ?? []).map((issue) => translate(`${KEY}.Issues.${issue}`));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function reviewScreenActions(
|
|
112
|
+
invoice: Invoice,
|
|
113
|
+
mode: 'view' | 'edit',
|
|
114
|
+
translate: Translate,
|
|
115
|
+
): ScreenAction[] | null {
|
|
116
|
+
if (!invoice) return null;
|
|
117
|
+
|
|
118
|
+
return reviewScreenActionsOf(invoice, mode).map(({ action, available, missingConditions }) => ({
|
|
119
|
+
label: translate(REVIEW_ACTION_LABEL_KEYS[action]),
|
|
120
|
+
available,
|
|
121
|
+
missingConditions: missingConditions.map((code) => translate(`${KEY}.ScreenCondition.${code}`)),
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ReviewFactsSource {
|
|
126
|
+
invoice: Invoice;
|
|
127
|
+
model: Pick<PurchaseInvoiceReviewModel, 'supplierInvoiceNumber' | 'invoiceDate' | 'dueDate'>;
|
|
128
|
+
labels: { supplier: string; legalEntity: string };
|
|
129
|
+
view: PurchaseInvoiceReviewView;
|
|
130
|
+
doubtReasons: { code: string; params: Record<string, unknown> }[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The header values, totals and invoice-level warnings, as the form and the breakdown show them. */
|
|
134
|
+
export function reviewScreenFacts(
|
|
135
|
+
source: ReviewFactsSource,
|
|
136
|
+
lang: string,
|
|
137
|
+
translate: Translate,
|
|
138
|
+
): ScreenFact[] | null {
|
|
139
|
+
const { invoice, model, labels, view } = source;
|
|
140
|
+
if (!invoice) return null;
|
|
141
|
+
|
|
142
|
+
const fact = (key: string, value: string): ScreenFact => ({
|
|
143
|
+
label: translate(`${KEY}.${key}`),
|
|
144
|
+
value,
|
|
145
|
+
});
|
|
146
|
+
const facts: ScreenFact[] = [fact('InvoiceNumber', invoice.invoiceNumber ?? '')];
|
|
147
|
+
|
|
148
|
+
if (invoice.erpStatus) {
|
|
149
|
+
facts.push(
|
|
150
|
+
fact(
|
|
151
|
+
'ErpStatus',
|
|
152
|
+
resolveI18nValue(invoice.erpStatus.nameI18n, lang, invoice.erpStatus.translatedLocales),
|
|
153
|
+
),
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
facts.push(
|
|
157
|
+
fact('Supplier', labels.supplier),
|
|
158
|
+
fact('LegalEntityId', labels.legalEntity),
|
|
159
|
+
fact('SupplierInvoiceNumber', model.supplierInvoiceNumber),
|
|
160
|
+
fact('InvoiceDate', formatIsoDate(model.invoiceDate)),
|
|
161
|
+
fact('DueDate', formatIsoDate(model.dueDate)),
|
|
162
|
+
fact('Subtotal', formatAmount(view.subtotal)),
|
|
163
|
+
fact('TaxAmount', formatAmount(view.taxAmount)),
|
|
164
|
+
fact('TotalAmount', formatAmount(view.totalAmount)),
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const totalMismatch = view.warnings.invoice.find(({ code }) => code === 'TOTAL_AMOUNT_MISMATCH');
|
|
168
|
+
if (totalMismatch) {
|
|
169
|
+
facts.push(fact('TotalAmount', reviewWarningText(totalMismatch, translate)));
|
|
170
|
+
}
|
|
171
|
+
for (const reason of source.doubtReasons) {
|
|
172
|
+
facts.push(
|
|
173
|
+
fact(
|
|
174
|
+
'Issues.DOUBTFUL_DOCUMENT',
|
|
175
|
+
translate(`${KEY}.DoubtReason.${reason.code}`, reason.params),
|
|
176
|
+
),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return facts;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface ReviewRowsSource {
|
|
184
|
+
/** The lines in the order the grid shows them. */
|
|
185
|
+
positions: readonly ReviewPositionModel[];
|
|
186
|
+
view: PurchaseInvoiceReviewView;
|
|
187
|
+
taxNames: Record<string, string>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The lines and the tax breakdown tables: every row counted, only the warned ones listed. */
|
|
191
|
+
export function reviewScreenRows(source: ReviewRowsSource, translate: Translate): ScreenTable[] {
|
|
192
|
+
const { positions, view, taxNames } = source;
|
|
193
|
+
|
|
194
|
+
const lineRows = positions.flatMap((position, index) => {
|
|
195
|
+
// The grid shows the taxes the last preview derived, and the model's until one answers.
|
|
196
|
+
const taxes = view.positions.find(({ id }) => id === position.id)?.taxes ?? position.taxes;
|
|
197
|
+
// Each warning carries the badge text of its tax, as the grid shows it under that badge.
|
|
198
|
+
const warnings = taxes.flatMap((tax) => {
|
|
199
|
+
const taxText = lineTaxText(tax, taxNames);
|
|
200
|
+
|
|
201
|
+
return (view.warnings.positionTaxes[tax.id] ?? []).map((warning) => {
|
|
202
|
+
const text = reviewWarningText(warning, translate);
|
|
203
|
+
|
|
204
|
+
return taxText ? `${taxText}: ${text}` : text;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return warnings.length
|
|
209
|
+
? [
|
|
210
|
+
{
|
|
211
|
+
label: translate(`${KEY}.ScreenContextLine`, {
|
|
212
|
+
number: index + 1,
|
|
213
|
+
description: position.description,
|
|
214
|
+
}),
|
|
215
|
+
warnings,
|
|
216
|
+
},
|
|
217
|
+
]
|
|
218
|
+
: [];
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const breakdownRows = view.taxBreakdowns.flatMap((row) => {
|
|
222
|
+
const warnings = (view.warnings.breakdowns[row.key] ?? []).map((warning) =>
|
|
223
|
+
reviewWarningText(warning, translate),
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
return warnings.length ? [{ label: breakdownTaxText(row, taxNames, translate), warnings }] : [];
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return [
|
|
230
|
+
{ label: translate(`${KEY}.LinesTitle`), count: positions.length, rows: lineRows },
|
|
231
|
+
{
|
|
232
|
+
label: translate(`${KEY}.BreakdownTitle`),
|
|
233
|
+
count: view.taxBreakdowns.length,
|
|
234
|
+
rows: breakdownRows,
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
}
|