@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.
Files changed (234) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/domain/skills-scanner.js +7 -2
  3. package/dist/deploy/domain/curl-config.js +1 -1
  4. package/dist/deploy/domain/playbook-vars.js +1 -1
  5. package/dist/generator/domain/frontend-composition.js +4 -4
  6. package/dist/generator/domain/property-filters.d.ts +8 -0
  7. package/dist/generator/domain/property-filters.js +17 -6
  8. package/dist/generator/handlers/front.handler.js +10 -1
  9. package/dist/sheets/domain/auth.js +10 -5
  10. package/dist/sheets/sync/sheet-to-yaml.d.ts +1 -0
  11. package/dist/sheets/sync/sheet-to-yaml.js +19 -3
  12. package/dist/templates/backend/application/.claude/skills/catalyst-tools/SKILL.md +5 -3
  13. package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-catalog-section-reader.spec.ts +4 -0
  14. package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.spec.ts +2 -0
  15. package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.ts +2 -1
  16. package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual-section-reader.port.ts +2 -0
  17. package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual.types.ts +2 -0
  18. package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual-graphql-schema.spec.ts +10 -2
  19. package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual.graphql +4 -0
  20. package/dist/templates/backend/business-rules/business-partner-portal/supplier-document.md +96 -6
  21. package/dist/templates/backend/business-rules/tools/assistant-usage.md +60 -0
  22. package/dist/templates/backend/manual/business-partner-portal/CONTEXT.md +5 -5
  23. package/dist/templates/backend/manual/business-partner-portal/en/purchase-invoice-header.md +5 -1
  24. package/dist/templates/backend/manual/business-partner-portal/es/purchase-invoice-header.md +5 -1
  25. package/dist/templates/backend/manual/production-planning/en/planner.md +1 -1
  26. package/dist/templates/backend/manual/production-planning/en/production-order-position-event.md +8 -5
  27. package/dist/templates/backend/manual/production-planning/es/planner.md +1 -1
  28. package/dist/templates/backend/manual/production-planning/es/production-order-position-event.md +8 -5
  29. package/dist/templates/backend/manual/reporting/en/report.md +40 -0
  30. package/dist/templates/backend/manual/reporting/es/report.md +40 -0
  31. package/dist/templates/backend/manual/tools/CONTEXT.md +1 -0
  32. package/dist/templates/backend/manual/tools/actions.yaml +11 -0
  33. package/dist/templates/backend/manual/tools/en/assistant-conversation.md +38 -0
  34. package/dist/templates/backend/manual/tools/en/assistant-usage-policy.md +46 -0
  35. package/dist/templates/backend/manual/tools/en/assistant-usage.md +28 -0
  36. package/dist/templates/backend/manual/tools/en/file-storage.md +83 -0
  37. package/dist/templates/backend/manual/tools/es/assistant-conversation.md +38 -0
  38. package/dist/templates/backend/manual/tools/es/assistant-usage-policy.md +46 -0
  39. package/dist/templates/backend/manual/tools/es/assistant-usage.md +28 -0
  40. package/dist/templates/backend/manual/tools/es/file-storage.md +83 -0
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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
  47. 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
  48. 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
  49. 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
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-create-report.dto.ts +0 -21
  57. package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-report.dto.ts +3 -3
  58. package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-report-by-id.dto.ts +0 -48
  59. package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-reports.dto.ts +0 -48
  60. package/dist/templates/backend/packages/reporting/src/@api/reporting/report/graphql/reporting-report.graphql +3 -20
  61. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/create/reporting-create-report.service.ts +2 -2
  62. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/reporting-report.payload-types.ts +33 -0
  63. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.handler.spec.ts +77 -0
  64. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.service.ts +2 -2
  65. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-reports.service.ts +2 -2
  66. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update-execution-cache/reporting-update-report-execution-cache.handler.spec.ts +35 -0
  67. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/domain/reporting-report.field-schema.ts +7 -0
  68. package/dist/templates/backend/packages/reporting/src/@app/reporting/report/index.ts +5 -0
  69. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-assistant-conversation.dto.ts +8 -1
  70. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversation-by-id.dto.ts +8 -1
  71. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversations.dto.ts +8 -1
  72. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/graphql/tools-assistant-conversation.graphql +8 -1
  73. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/controllers/tools-ask-assistant-assistant-usage.controller.ts +1 -0
  74. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-ask-assistant.dto.ts +47 -0
  75. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-answer.dto.ts +1 -0
  76. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-usage.dto.ts +8 -1
  77. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usage-by-id.dto.ts +8 -1
  78. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usages.dto.ts +8 -1
  79. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/graphql/tools-assistant-usage.graphql +45 -1
  80. package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/resolvers/tools-ask-assistant-assistant-usage.resolver.ts +1 -0
  81. package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/infrastructure/tools-anthropic-assistant-model.service.spec.ts +1 -0
  82. package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.spec.ts +145 -0
  83. package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.ts +44 -2
  84. package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/types/tools-anthropic-assistant-answer.types.ts +3 -2
  85. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/domain/tools-assistant-conversation.field-schema.ts +6 -0
  86. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/infrastructure/drizzle/tools-drizzle-assistant-conversation.schema.ts +1 -0
  87. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.spec.ts +105 -5
  88. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.ts +40 -23
  89. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-errors.function.ts +8 -0
  90. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.spec.ts +257 -0
  91. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.ts +200 -0
  92. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.spec.ts +7 -2
  93. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.ts +7 -2
  94. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-model.port.ts +44 -0
  95. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-usage.field-schema.ts +6 -0
  96. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.spec.ts +25 -0
  97. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.ts +3 -0
  98. package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.schema.ts +1 -0
  99. package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-ask.e2e-spec.ts +16 -1
  100. package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-usage-increment.e2e-spec.ts +52 -5
  101. package/dist/templates/codegen/frontend/module/__module_name__/features/__module_name__-list.component.ts.eta +7 -1
  102. package/dist/templates/codegen/frontend/module/__module_name__/features/index.ts.eta +1 -1
  103. package/dist/templates/frontend/application/.claude/skills/catalyst-project-structure/SKILL.md +3 -0
  104. package/dist/templates/frontend/application/libs/ui/command/src/lib/hlm-command-item.ts +1 -1
  105. package/dist/templates/frontend/application/src/@aurora/modules/assisted-form/README.md +2 -0
  106. package/dist/templates/frontend/application/src/@aurora/modules/command-palette/command-palette-trigger.component.ts +1 -0
  107. package/dist/templates/frontend/application/src/@aurora/modules/guided-action/README.md +4 -0
  108. package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.spec.ts +69 -0
  109. package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.ts +13 -4
  110. package/dist/templates/frontend/application/src/@aurora/modules/index.ts +1 -0
  111. package/dist/templates/frontend/application/src/@aurora/modules/manual/manual.graphql.ts +1 -0
  112. package/dist/templates/frontend/application/src/@aurora/modules/screen-context/README.md +36 -0
  113. package/dist/templates/frontend/application/src/@aurora/modules/screen-context/index.ts +2 -0
  114. package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.spec.ts +137 -0
  115. package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.ts +60 -0
  116. package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.types.ts +47 -0
  117. package/dist/templates/frontend/application/src/app/domains/admin/layout/site-header.ts +1 -1
  118. package/dist/templates/frontend/application/tsconfig.json +1 -0
  119. package/dist/templates/frontend/navigation-i18n/reporting/en.json +1 -1
  120. package/dist/templates/frontend/navigation-i18n/reporting/es.json +1 -1
  121. package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/index.ts +0 -1
  122. package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/state-machine-history-list.component.ts +0 -13
  123. package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/en.json +11 -0
  124. package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/es.json +11 -0
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/index.ts +0 -1
  136. 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
  137. package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.spec.ts +26 -1
  138. package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.ts +45 -0
  139. package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/en.json +15 -4
  140. package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/es.json +15 -4
  141. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/index.ts +1 -0
  142. 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
  143. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner-process-weights.derive.ts +39 -0
  144. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.spec.ts +15 -0
  145. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.ts +7 -3
  146. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.graphql.ts +23 -0
  147. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner-process-weights-dialog.component.ts +137 -0
  148. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner.component.ts +41 -4
  149. 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
  150. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.derive.ts +0 -21
  151. 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
  152. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.resolvers.ts +3 -1
  153. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/batch-detail-sheet.component.ts +22 -10
  154. 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
  155. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-form-sheet.component.ts +95 -59
  156. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-list.component.ts +121 -123
  157. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/production-dashboard.component.ts +52 -19
  158. 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
  159. 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
  160. 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
  161. 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
  162. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/finish-event-dialog.component.ts +3 -3
  163. package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/weight-input-dialog.component.ts +3 -3
  164. package/dist/templates/frontend/packages/reporting/public/i18n/reporting/en.json +1 -1
  165. package/dist/templates/frontend/packages/reporting/public/i18n/reporting/es.json +1 -1
  166. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.detail-config.ts +1 -2
  167. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.graphql.ts +0 -14
  168. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.spec.ts +96 -0
  169. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.ts +46 -69
  170. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-list.component.ts +2 -22
  171. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/report.columns.ts +0 -1
  172. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting-icons.providers.ts +2 -1
  173. package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting.navigation.ts +7 -0
  174. package/dist/templates/frontend/packages/tools/public/i18n/tools/en.json +4 -2
  175. package/dist/templates/frontend/packages/tools/public/i18n/tools/es.json +4 -2
  176. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.spec.ts +82 -7
  177. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.ts +12 -2
  178. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/assistant-conversation.columns.ts +13 -0
  179. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/data-access/assistant-conversation.graphql.ts +1 -0
  180. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-form.component.ts +18 -0
  181. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list.component.ts +0 -13
  182. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/index.ts +0 -1
  183. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/assistant-usage.columns.ts +13 -0
  184. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/data-access/assistant-usage.graphql.ts +2 -0
  185. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-form.component.ts +18 -0
  186. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list.component.ts +0 -13
  187. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/index.ts +0 -1
  188. package/dist/templates/monorepo/.claude/commands/business-rules/promote.md +5 -1
  189. package/dist/templates/monorepo/.claude/hooks/__fixtures__/br-hr-regression-baseline.txt +2 -2
  190. package/dist/templates/monorepo/.claude/hooks/check-required-setup.ts +4 -4
  191. package/dist/templates/monorepo/.claude/hooks/inject-prompt-context.ts +1 -1
  192. package/dist/templates/monorepo/.claude/scripts/generate-skills-index.test.ts +29 -1
  193. package/dist/templates/monorepo/.claude/scripts/generate-skills-index.ts +7 -1
  194. package/dist/templates/monorepo/.claude/skills/REGISTRY.md +2 -2
  195. package/dist/templates/monorepo/.claude/skills/catalyst-backlog/SKILL.md +19 -4
  196. package/dist/templates/monorepo/.claude/skills/catalyst-backlog/frontier-worker-addendum.md +3 -3
  197. package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/SKILL.md +8 -5
  198. package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/references/workflow.md +10 -6
  199. package/dist/templates/monorepo/.claude/skills/catalyst-delegation/SKILL.md +1 -1
  200. package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/SKILL.md +6 -6
  201. package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/enforcement.md +3 -3
  202. package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/format.md +3 -3
  203. package/dist/templates/monorepo/.claude/skills/catalyst-update-skill-registry/SKILL.md +4 -4
  204. package/dist/templates/monorepo/.claude/skills/catalyst-user-manual/SKILL.md +48 -2
  205. package/dist/templates/monorepo/.claude/skills/openspec-apply-change/SKILL.md +28 -10
  206. package/dist/templates/monorepo/.claude/skills/openspec-archive-change/SKILL.md +52 -13
  207. package/dist/templates/monorepo/.claude/skills/openspec-explore/SKILL.md +59 -14
  208. package/dist/templates/monorepo/.claude/skills/openspec-propose/SKILL.md +38 -12
  209. package/dist/templates/monorepo/.claude/skills/openspec-sync-specs/SKILL.md +31 -3
  210. package/dist/templates/monorepo/CLAUDE.md +14 -14
  211. package/dist/templates/monorepo/docs/business-rules/ARCHITECTURE.md +16 -13
  212. package/dist/templates/monorepo/docs/business-rules/MIGRATION.md +5 -5
  213. package/dist/templates/monorepo/docs/manual/en/04-asistente.md +71 -0
  214. package/dist/templates/monorepo/docs/manual/es/04-asistente.md +71 -0
  215. package/dist/templates/monorepo/openspec/config.yaml +25 -5
  216. package/dist/templates/monorepo/package.json +3 -1
  217. package/dist/templates/monorepo/scripts/backlog/prompt.test.ts +5 -5
  218. package/dist/templates/monorepo/scripts/backlog/prompt.ts +1 -1
  219. package/dist/templates/monorepo/scripts/business-rules/audit.ts +1 -1
  220. package/dist/templates/monorepo/scripts/manual/compile.test.ts +78 -0
  221. package/dist/templates/monorepo/scripts/manual/compile.ts +36 -9
  222. package/dist/templates/monorepo/scripts/worktree/prune.test.ts +517 -0
  223. package/dist/templates/monorepo/scripts/worktree/prune.ts +331 -0
  224. package/oclif.manifest.json +85 -85
  225. package/package.json +15 -17
  226. 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
  227. 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
  228. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list-actions-cell.component.ts +0 -44
  229. package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list-actions-cell.component.ts +0 -43
  230. package/dist/templates/monorepo/.claude/commands/opsx/apply.md +0 -184
  231. package/dist/templates/monorepo/.claude/commands/opsx/archive.md +0 -225
  232. package/dist/templates/monorepo/.claude/commands/opsx/explore.md +0 -196
  233. package/dist/templates/monorepo/.claude/commands/opsx/propose.md +0 -145
  234. package/dist/templates/monorepo/.claude/commands/opsx/sync.md +0 -258
@@ -3,6 +3,7 @@ import { type BusinessPartnerPortalPurchaseInvoiceHeader } from '@src/src/app/au
3
3
  import { describe, expect, it } from 'vitest';
4
4
  import {
5
5
  addPosition,
6
+ breakdownTaxText,
6
7
  buildReviewModel,
7
8
  describeDoubtOperation,
8
9
  flowActionsOf,
@@ -10,11 +11,13 @@ import {
10
11
  groupReviewWarnings,
11
12
  isInvoiceEditable,
12
13
  legalEntityOptionOf,
14
+ lineTaxText,
13
15
  mergePreviewIntoView,
14
16
  movePosition,
15
17
  reconcileBreakdowns,
16
18
  removePosition,
17
19
  removeUnmatchedTax,
20
+ reviewWarningText,
18
21
  selectLegalEntity,
19
22
  selectSupplier,
20
23
  setPositionTaxes,
@@ -25,6 +28,7 @@ import {
25
28
  toSavePayload,
26
29
  viewFromModel,
27
30
  type PurchaseInvoiceReviewPreview,
31
+ type PurchaseInvoiceReviewWarning,
28
32
  } from './purchase-invoice-review.derive';
29
33
 
30
34
  const HEADER_DEFINITION: CustomFieldCaptureDefinition = {
@@ -741,15 +745,93 @@ describe('flowActionsOf', () => {
741
745
  businessPartnerId,
742
746
  } as unknown as Partial<BusinessPartnerPortalPurchaseInvoiceHeader>);
743
747
 
748
+ /** The actions the buttons show: the available ones, in button order. */
749
+ const offered = (invoice: BusinessPartnerPortalPurchaseInvoiceHeader | null) =>
750
+ flowActionsOf(invoice)
751
+ .filter(({ available }) => available)
752
+ .map(({ action }) => action);
753
+
754
+ it('returns every action in button order with its missing conditions', () => {
755
+ expect(flowActionsOf(invoiceWith('IN_REVIEW'))).toEqual([
756
+ { action: 'REPROCESS', available: true, missingConditions: [] },
757
+ { action: 'ACCEPT_DUPLICATE', available: false, missingConditions: ['ISSUE_DUPLICATED'] },
758
+ {
759
+ action: 'ACCEPT_REVIEW',
760
+ available: false,
761
+ missingConditions: ['ISSUE_DOUBTFUL_DOCUMENT'],
762
+ },
763
+ { action: 'RELEASE_HOLD', available: false, missingConditions: ['STATE_BLOCKED'] },
764
+ ]);
765
+ });
766
+
767
+ it('names every condition an in-review invoice with DUPLICATED meets', () => {
768
+ const [reprocess, acceptDuplicate] = flowActionsOf(invoiceWith('IN_REVIEW', ['DUPLICATED']));
769
+
770
+ expect(reprocess).toEqual({ action: 'REPROCESS', available: true, missingConditions: [] });
771
+ expect(acceptDuplicate).toEqual({
772
+ action: 'ACCEPT_DUPLICATE',
773
+ available: true,
774
+ missingConditions: [],
775
+ });
776
+ });
777
+
778
+ it('names the missing supplier as the only condition of a doubtful invoice without one', () => {
779
+ const acceptReview = flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT'], null)).find(
780
+ ({ action }) => action === 'ACCEPT_REVIEW',
781
+ );
782
+
783
+ expect(acceptReview).toEqual({
784
+ action: 'ACCEPT_REVIEW',
785
+ available: false,
786
+ missingConditions: ['SUPPLIER_ASSIGNED'],
787
+ });
788
+ });
789
+
790
+ it('names EXTRACTION_FAILED as what blocks Accept review', () => {
791
+ const acceptReview = flowActionsOf(
792
+ invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'EXTRACTION_FAILED']),
793
+ ).find(({ action }) => action === 'ACCEPT_REVIEW');
794
+
795
+ expect(acceptReview?.missingConditions).toEqual(['NO_EXTRACTION_FAILED']);
796
+ });
797
+
798
+ it('names the state as the missing condition outside review', () => {
799
+ const states = (code: string | null) =>
800
+ Object.fromEntries(
801
+ flowActionsOf(invoiceWith(code)).map(({ action, missingConditions }) => [
802
+ action,
803
+ missingConditions,
804
+ ]),
805
+ );
806
+
807
+ expect(states('ERROR')['REPROCESS']).toEqual([]);
808
+ expect(states('ERROR')['ACCEPT_DUPLICATE']).toEqual(['STATE_IN_REVIEW', 'ISSUE_DUPLICATED']);
809
+ expect(states('BLOCKED')['RELEASE_HOLD']).toEqual([]);
810
+ expect(states('SENT')['REPROCESS']).toEqual(['STATE_IN_REVIEW_OR_ERROR']);
811
+ expect(states(null)['RELEASE_HOLD']).toEqual(['STATE_BLOCKED']);
812
+ });
813
+
814
+ it('returns every action unavailable for no invoice', () => {
815
+ const actions = flowActionsOf(null);
816
+
817
+ expect(actions.map(({ action }) => action)).toEqual([
818
+ 'REPROCESS',
819
+ 'ACCEPT_DUPLICATE',
820
+ 'ACCEPT_REVIEW',
821
+ 'RELEASE_HOLD',
822
+ ]);
823
+ expect(actions.every(({ available }) => !available)).toBe(true);
824
+ });
825
+
744
826
  it('offers Reprocess alone to an invoice in review without a duplicate', () => {
745
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['EXTENDING_FAILED', 'TAX_ERROR']))).toEqual([
827
+ expect(offered(invoiceWith('IN_REVIEW', ['EXTENDING_FAILED', 'TAX_ERROR']))).toEqual([
746
828
  'REPROCESS',
747
829
  ]);
748
- expect(flowActionsOf(invoiceWith('IN_REVIEW'))).toEqual(['REPROCESS']);
830
+ expect(offered(invoiceWith('IN_REVIEW'))).toEqual(['REPROCESS']);
749
831
  });
750
832
 
751
833
  it('offers Reprocess and Accept duplicate to an invoice in review holding DUPLICATED', () => {
752
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['TAX_ERROR', 'DUPLICATED']))).toEqual([
834
+ expect(offered(invoiceWith('IN_REVIEW', ['TAX_ERROR', 'DUPLICATED']))).toEqual([
753
835
  'REPROCESS',
754
836
  'ACCEPT_DUPLICATE',
755
837
  ]);
@@ -757,18 +839,18 @@ describe('flowActionsOf', () => {
757
839
 
758
840
  describe('Accept review', () => {
759
841
  it('is offered to an invoice in review that holds DOUBTFUL_DOCUMENT, has no EXTRACTION_FAILED and has a supplier', () => {
760
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT']))).toEqual([
842
+ expect(offered(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT']))).toEqual([
761
843
  'REPROCESS',
762
844
  'ACCEPT_REVIEW',
763
845
  ]);
764
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['TAX_ERROR', 'DOUBTFUL_DOCUMENT']))).toEqual([
846
+ expect(offered(invoiceWith('IN_REVIEW', ['TAX_ERROR', 'DOUBTFUL_DOCUMENT']))).toEqual([
765
847
  'REPROCESS',
766
848
  'ACCEPT_REVIEW',
767
849
  ]);
768
850
  });
769
851
 
770
852
  it('comes after Accept duplicate when the invoice holds both DUPLICATED and DOUBTFUL_DOCUMENT', () => {
771
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'DUPLICATED']))).toEqual([
853
+ expect(offered(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'DUPLICATED']))).toEqual([
772
854
  'REPROCESS',
773
855
  'ACCEPT_DUPLICATE',
774
856
  'ACCEPT_REVIEW',
@@ -776,61 +858,57 @@ describe('flowActionsOf', () => {
776
858
  });
777
859
 
778
860
  it('is not offered without DOUBTFUL_DOCUMENT', () => {
779
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['TAX_ERROR']))).toEqual(['REPROCESS']);
861
+ expect(offered(invoiceWith('IN_REVIEW', ['TAX_ERROR']))).toEqual(['REPROCESS']);
780
862
  });
781
863
 
782
864
  it('is not offered when the invoice holds EXTRACTION_FAILED', () => {
783
- expect(
784
- flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'EXTRACTION_FAILED'])),
785
- ).toEqual(['REPROCESS']);
865
+ expect(offered(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', 'EXTRACTION_FAILED']))).toEqual(
866
+ ['REPROCESS'],
867
+ );
786
868
  });
787
869
 
788
870
  it('is not offered without a supplier', () => {
789
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT'], null))).toEqual([
790
- 'REPROCESS',
791
- ]);
871
+ expect(offered(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT'], null))).toEqual(['REPROCESS']);
792
872
  });
793
873
 
794
874
  // The three outcomes of the identification that leave the invoice without a supplier.
795
875
  it.each(['SEVERAL_SUPPLIERS', 'WITHOUT_SUPPLIER', 'SUPPLIER_TIN_MISMATCH'])(
796
876
  'is not offered to a doubtful invoice left by %s without a supplier',
797
877
  (issue) => {
798
- expect(flowActionsOf(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', issue], null))).toEqual(
799
- ['REPROCESS'],
800
- );
878
+ expect(offered(invoiceWith('IN_REVIEW', ['DOUBTFUL_DOCUMENT', issue], null))).toEqual([
879
+ 'REPROCESS',
880
+ ]);
801
881
  },
802
882
  );
803
883
 
804
884
  it.each(['ERROR', 'BLOCKED', 'RECEIVED', 'EXTRACTED', 'PROCESSING', 'SENT'])(
805
885
  'is not offered in %s with every other condition met',
806
886
  (code) => {
807
- expect(flowActionsOf(invoiceWith(code, ['DOUBTFUL_DOCUMENT']))).not.toContain(
808
- 'ACCEPT_REVIEW',
809
- );
887
+ expect(offered(invoiceWith(code, ['DOUBTFUL_DOCUMENT']))).not.toContain('ACCEPT_REVIEW');
810
888
  },
811
889
  );
812
890
  });
813
891
 
814
892
  it('offers Reprocess alone to an invoice in error, even if it holds DUPLICATED', () => {
815
- expect(flowActionsOf(invoiceWith('ERROR', ['TIMEOUT']))).toEqual(['REPROCESS']);
816
- expect(flowActionsOf(invoiceWith('ERROR', ['DUPLICATED']))).toEqual(['REPROCESS']);
893
+ expect(offered(invoiceWith('ERROR', ['TIMEOUT']))).toEqual(['REPROCESS']);
894
+ expect(offered(invoiceWith('ERROR', ['DUPLICATED']))).toEqual(['REPROCESS']);
817
895
  });
818
896
 
819
897
  it('offers Release hold alone to a blocked invoice', () => {
820
- expect(flowActionsOf(invoiceWith('BLOCKED', ['HELD']))).toEqual(['RELEASE_HOLD']);
821
- expect(flowActionsOf(invoiceWith('BLOCKED', ['DUPLICATED']))).toEqual(['RELEASE_HOLD']);
898
+ expect(offered(invoiceWith('BLOCKED', ['HELD']))).toEqual(['RELEASE_HOLD']);
899
+ expect(offered(invoiceWith('BLOCKED', ['DUPLICATED']))).toEqual(['RELEASE_HOLD']);
822
900
  });
823
901
 
824
902
  it.each(['RECEIVED', 'EXTENDING', 'EXTRACTED', 'PROCESSING', 'APPROVED', 'SENT', 'ARCHIVED'])(
825
903
  'offers nothing in %s',
826
904
  (code) => {
827
- expect(flowActionsOf(invoiceWith(code, ['DUPLICATED', 'HELD']))).toEqual([]);
905
+ expect(offered(invoiceWith(code, ['DUPLICATED', 'HELD']))).toEqual([]);
828
906
  },
829
907
  );
830
908
 
831
909
  it('offers nothing without a state or an invoice', () => {
832
- expect(flowActionsOf(invoiceWith(null))).toEqual([]);
833
- expect(flowActionsOf(null)).toEqual([]);
910
+ expect(offered(invoiceWith(null))).toEqual([]);
911
+ expect(offered(null)).toEqual([]);
834
912
  });
835
913
  });
836
914
 
@@ -978,3 +1056,80 @@ describe('describeDoubtOperation', () => {
978
1056
  });
979
1057
  });
980
1058
  });
1059
+
1060
+ describe('review warning and breakdown texts', () => {
1061
+ /** Echoes the key and its params so a wrong key or a wrong figure fails the assertion. */
1062
+ const translate = (key: string, params?: Record<string, unknown>): string =>
1063
+ params ? `${key}|${JSON.stringify(params)}` : key;
1064
+ const warning = (code: string, detail?: unknown) =>
1065
+ ({ code, detail }) as unknown as PurchaseInvoiceReviewWarning;
1066
+
1067
+ describe('reviewWarningText', () => {
1068
+ it('writes the expected and read amounts of TAX_AMOUNT_MISMATCH as the screen shows them', () => {
1069
+ expect(
1070
+ reviewWarningText(
1071
+ warning('TAX_AMOUNT_MISMATCH', { expectedAmount: 1234.5, readAmount: 20 }),
1072
+ translate,
1073
+ ),
1074
+ ).toBe(
1075
+ 'business-partner-portal.purchase-invoice-header.RowAmountMismatch|{"expected":"1.234,50","read":"20,00"}',
1076
+ );
1077
+ });
1078
+
1079
+ it('writes the expected and read totals of TOTAL_AMOUNT_MISMATCH', () => {
1080
+ expect(
1081
+ reviewWarningText(
1082
+ warning('TOTAL_AMOUNT_MISMATCH', { expectedAmount: 100, readAmount: 99 }),
1083
+ translate,
1084
+ ),
1085
+ ).toBe(
1086
+ 'business-partner-portal.purchase-invoice-header.TotalMismatch|{"expected":"100,00","read":"99,00"}',
1087
+ );
1088
+ });
1089
+
1090
+ it('falls back to the unmatched tax text for any other warning', () => {
1091
+ expect(reviewWarningText(warning('TAX_UNMATCHED'), translate)).toBe(
1092
+ 'business-partner-portal.purchase-invoice-header.TaxUnmatched',
1093
+ );
1094
+ });
1095
+ });
1096
+
1097
+ describe('lineTaxText', () => {
1098
+ const taxNames = { 'tax-1': 'IVA' };
1099
+
1100
+ it('writes the catalog name when the tax has one, then the percentage', () => {
1101
+ expect(lineTaxText({ taxId: 'tax-1', label: 'stored', percentage: 21 }, taxNames)).toBe(
1102
+ 'IVA 21%',
1103
+ );
1104
+ });
1105
+
1106
+ it('falls back to the stored label, then to the percentage alone', () => {
1107
+ expect(lineTaxText({ taxId: null, label: 'IGIC', percentage: 7 }, taxNames)).toBe('IGIC 7%');
1108
+ expect(lineTaxText({ taxId: 'tax-9', label: null, percentage: 4 }, taxNames)).toBe('4%');
1109
+ expect(lineTaxText({ taxId: null, label: null, percentage: null }, taxNames)).toBe('');
1110
+ });
1111
+ });
1112
+
1113
+ describe('breakdownTaxText', () => {
1114
+ const taxNames = { 'tax-1': 'IVA 21%' };
1115
+
1116
+ it('prefers the catalog name', () => {
1117
+ expect(
1118
+ breakdownTaxText({ taxId: 'tax-1', label: 'IVA', percentage: 21 }, taxNames, translate),
1119
+ ).toBe('IVA 21%');
1120
+ });
1121
+
1122
+ it('writes what the document read when the row has no catalog tax', () => {
1123
+ expect(
1124
+ breakdownTaxText({ taxId: null, label: 'IVA', percentage: 10 }, taxNames, translate),
1125
+ ).toBe('IVA 10%');
1126
+ expect(breakdownTaxText({ taxId: 'tax-9', percentage: 4 }, taxNames, translate)).toBe('4%');
1127
+ });
1128
+
1129
+ it('writes the placeholder when nothing identifies the row', () => {
1130
+ expect(breakdownTaxText({ taxId: null }, taxNames, translate)).toBe(
1131
+ 'business-partner-portal.purchase-invoice-header.UnidentifiedTax',
1132
+ );
1133
+ });
1134
+ });
1135
+ });
@@ -531,40 +531,158 @@ export function isInvoiceEditable(
531
531
  /** The flow actions of the detail, in the order the buttons are shown. */
532
532
  export type ReviewFlowAction = 'REPROCESS' | 'ACCEPT_DUPLICATE' | 'ACCEPT_REVIEW' | 'RELEASE_HOLD';
533
533
 
534
+ export type ReviewFlowConditionCode =
535
+ | 'STATE_IN_REVIEW_OR_ERROR'
536
+ | 'STATE_IN_REVIEW'
537
+ | 'STATE_BLOCKED'
538
+ | 'ISSUE_DUPLICATED'
539
+ | 'ISSUE_DOUBTFUL_DOCUMENT'
540
+ | 'NO_EXTRACTION_FAILED'
541
+ | 'SUPPLIER_ASSIGNED';
542
+
543
+ type ReviewFlowInvoice = BusinessPartnerPortalPurchaseInvoiceHeader | null | undefined;
544
+
545
+ interface ReviewFlowCondition {
546
+ code: ReviewFlowConditionCode;
547
+ holds: (invoice: ReviewFlowInvoice) => boolean;
548
+ }
549
+
550
+ const issuesOf = (invoice: ReviewFlowInvoice): readonly string[] => invoice?.issues ?? [];
551
+
552
+ const STATE_IN_REVIEW_OR_ERROR: ReviewFlowCondition = {
553
+ code: 'STATE_IN_REVIEW_OR_ERROR',
554
+ holds: (invoice) => invoice?.state?.code === 'IN_REVIEW' || invoice?.state?.code === 'ERROR',
555
+ };
556
+ const STATE_IN_REVIEW: ReviewFlowCondition = {
557
+ code: 'STATE_IN_REVIEW',
558
+ holds: (invoice) => invoice?.state?.code === 'IN_REVIEW',
559
+ };
560
+ const STATE_BLOCKED: ReviewFlowCondition = {
561
+ code: 'STATE_BLOCKED',
562
+ holds: (invoice) => invoice?.state?.code === 'BLOCKED',
563
+ };
564
+ const ISSUE_DUPLICATED: ReviewFlowCondition = {
565
+ code: 'ISSUE_DUPLICATED',
566
+ holds: (invoice) => issuesOf(invoice).includes('DUPLICATED'),
567
+ };
568
+ const ISSUE_DOUBTFUL_DOCUMENT: ReviewFlowCondition = {
569
+ code: 'ISSUE_DOUBTFUL_DOCUMENT',
570
+ holds: (invoice) => issuesOf(invoice).includes('DOUBTFUL_DOCUMENT'),
571
+ };
572
+ const NO_EXTRACTION_FAILED: ReviewFlowCondition = {
573
+ code: 'NO_EXTRACTION_FAILED',
574
+ holds: (invoice) => !issuesOf(invoice).includes('EXTRACTION_FAILED'),
575
+ };
576
+ const SUPPLIER_ASSIGNED: ReviewFlowCondition = {
577
+ code: 'SUPPLIER_ASSIGNED',
578
+ holds: (invoice) => invoice?.businessPartnerId != null,
579
+ };
580
+
581
+ /**
582
+ * What each flow action needs. Declaration order is button order. A doubtful document read without
583
+ * a failed extraction and with a supplier assigned lets the reviewer vouch for the key fields
584
+ * instead of asking step 2 again.
585
+ */
586
+ const REVIEW_FLOW_CONDITIONS: Record<ReviewFlowAction, readonly ReviewFlowCondition[]> = {
587
+ REPROCESS: [STATE_IN_REVIEW_OR_ERROR],
588
+ ACCEPT_DUPLICATE: [STATE_IN_REVIEW, ISSUE_DUPLICATED],
589
+ ACCEPT_REVIEW: [
590
+ STATE_IN_REVIEW,
591
+ ISSUE_DOUBTFUL_DOCUMENT,
592
+ NO_EXTRACTION_FAILED,
593
+ SUPPLIER_ASSIGNED,
594
+ ],
595
+ RELEASE_HOLD: [STATE_BLOCKED],
596
+ };
597
+
598
+ export interface ReviewFlowActionState {
599
+ action: ReviewFlowAction;
600
+ /** No condition is missing. */
601
+ available: boolean;
602
+ missingConditions: ReviewFlowConditionCode[];
603
+ }
604
+
534
605
  /**
535
- * The flow actions the detail offers for an invoice, decided by its state code and issues alone.
536
- * The screen never decides the target state of a reprocess nor checks permissions: the backend does.
606
+ * Every flow action of the detail for an invoice, in button order, with the conditions it is
607
+ * missing; the buttons show the available ones. Decided by the state code, issues and supplier
608
+ * alone. The screen never decides the target state of a reprocess nor checks permissions: the
609
+ * backend does.
537
610
  *
538
611
  * @rule BR-BPP-PURCHASE-INVOICE-HEADER-042
612
+ * @rule BR-BPP-PURCHASE-INVOICE-HEADER-054
539
613
  * @rule BR-BPP-PURCHASE-INVOICE-HEADER-056
540
614
  * @rule BR-BPP-PURCHASE-INVOICE-HEADER-075
541
615
  */
542
- export function flowActionsOf(
543
- invoice: BusinessPartnerPortalPurchaseInvoiceHeader | null | undefined,
544
- ): ReviewFlowAction[] {
545
- const stateCode = invoice?.state?.code;
546
-
547
- if (stateCode === 'IN_REVIEW') {
548
- const issues = invoice?.issues ?? [];
549
- const actions: ReviewFlowAction[] = ['REPROCESS'];
550
-
551
- if (issues.includes('DUPLICATED')) actions.push('ACCEPT_DUPLICATE');
552
- // A doubtful document read without a failed extraction and with a supplier assigned: the
553
- // reviewer can vouch for the key fields instead of asking step 2 again.
554
- if (
555
- issues.includes('DOUBTFUL_DOCUMENT') &&
556
- !issues.includes('EXTRACTION_FAILED') &&
557
- invoice?.businessPartnerId != null
558
- ) {
559
- actions.push('ACCEPT_REVIEW');
560
- }
616
+ export function flowActionsOf(invoice: ReviewFlowInvoice): ReviewFlowActionState[] {
617
+ return (Object.keys(REVIEW_FLOW_CONDITIONS) as ReviewFlowAction[]).map((action) => {
618
+ const missingConditions = REVIEW_FLOW_CONDITIONS[action]
619
+ .filter((condition) => !condition.holds(invoice))
620
+ .map(({ code }) => code);
561
621
 
562
- return actions;
622
+ return { action, available: missingConditions.length === 0, missingConditions };
623
+ });
624
+ }
625
+
626
+ type ReviewTranslate = (key: string, params?: Record<string, unknown>) => string;
627
+
628
+ interface AmountMismatchDetail {
629
+ expectedAmount?: number | null;
630
+ readAmount?: number | null;
631
+ }
632
+
633
+ /**
634
+ * The text of a line, breakdown or invoice warning. The screen and the assistant context call this
635
+ * one function so both say the same thing.
636
+ */
637
+ export function reviewWarningText(
638
+ warning: PurchaseInvoiceReviewWarning,
639
+ translate: ReviewTranslate,
640
+ ): string {
641
+ const detail = (warning.detail ?? {}) as AmountMismatchDetail;
642
+ const amounts = {
643
+ expected: formatAmount(detail.expectedAmount),
644
+ read: formatAmount(detail.readAmount),
645
+ };
646
+
647
+ if (warning.code === 'TAX_AMOUNT_MISMATCH') {
648
+ return translate('business-partner-portal.purchase-invoice-header.RowAmountMismatch', amounts);
563
649
  }
564
- if (stateCode === 'ERROR') return ['REPROCESS'];
565
- if (stateCode === 'BLOCKED') return ['RELEASE_HOLD'];
650
+ if (warning.code === 'TOTAL_AMOUNT_MISMATCH') {
651
+ return translate('business-partner-portal.purchase-invoice-header.TotalMismatch', amounts);
652
+ }
653
+
654
+ return translate('business-partner-portal.purchase-invoice-header.TaxUnmatched');
655
+ }
656
+
657
+ /**
658
+ * The text of a line tax badge: the catalog name when the tax has one, else the stored label, then
659
+ * the percentage. The lines grid and the assistant context both call this one function.
660
+ */
661
+ export function lineTaxText(
662
+ tax: { taxId?: string | null; label?: string | null; percentage?: number | null },
663
+ taxNames: Record<string, string>,
664
+ ): string {
665
+ const name = (tax.taxId ? taxNames[tax.taxId] : undefined) ?? tax.label;
666
+
667
+ return [name, tax.percentage == null ? null : `${tax.percentage}%`]
668
+ .filter((part) => part)
669
+ .join(' ');
670
+ }
671
+
672
+ /** The catalog name when the row has a catalog tax, else what the row read, else a placeholder. */
673
+ export function breakdownTaxText(
674
+ row: { taxId?: string | null; label?: string | null; percentage?: number | null },
675
+ taxNames: Record<string, string>,
676
+ translate: ReviewTranslate,
677
+ ): string {
678
+ const catalogName = row.taxId ? taxNames[row.taxId] : undefined;
679
+ if (catalogName) return catalogName;
680
+
681
+ const read = [row.label, row.percentage == null ? null : `${row.percentage}%`]
682
+ .filter((part) => part)
683
+ .join(' ');
566
684
 
567
- return [];
685
+ return read || translate('business-partner-portal.purchase-invoice-header.UnidentifiedTax');
568
686
  }
569
687
 
570
688
  /** Renumbers the lines 1..n in their current array order: that order is what the save stores. */
@@ -8,6 +8,7 @@ import { By } from '@angular/platform-browser';
8
8
  import { ActivatedRoute, provideRouter } from '@angular/router';
9
9
  import { CustomFieldCatalogService } from '@aurora';
10
10
  import { PDF_VIEWER_ENGINE, type PdfViewerEngine } from '@aurora/components/pdf-viewer';
11
+ import { ScreenContextService } from '@aurora/modules/screen-context';
11
12
  import { TranslocoService, TranslocoTestingModule } from '@jsverse/transloco';
12
13
  import { toast } from '@spartan-ng/brain/sonner';
13
14
  import {
@@ -1008,4 +1009,45 @@ describe('PurchaseInvoiceHeaderDetailComponent', () => {
1008
1009
  );
1009
1010
  });
1010
1011
  });
1012
+
1013
+ describe('screen context', () => {
1014
+ it('publishes the five sections of what the screen shows and withdraws them with the screen', async () => {
1015
+ const doubtful = invoice({
1016
+ issues: ['DOUBTFUL_DOCUMENT'],
1017
+ state: {
1018
+ code: 'IN_REVIEW',
1019
+ nameI18n: { en: 'In review', es: 'En revisión' },
1020
+ category: { code: 'REVIEW' },
1021
+ },
1022
+ } as unknown as Partial<BusinessPartnerPortalPurchaseInvoiceHeader>);
1023
+ const { fixture } = setup(doubtful);
1024
+ await settle(fixture);
1025
+ const context = TestBed.inject(ScreenContextService);
1026
+
1027
+ const snapshot = context.snapshot();
1028
+
1029
+ expect(snapshot?.screenId).toBe('business-partner-portal.purchase-invoice-header');
1030
+ expect(snapshot?.status).toEqual({ label: 'In review' });
1031
+ expect(snapshot?.issues).toEqual(['Doubtful Document']);
1032
+ // Without a supplier Accept review is hidden and the context says why; Reprocess is shown.
1033
+ expect(snapshot?.actions?.find(({ label }) => label === 'Accept review')).toEqual({
1034
+ label: 'Accept review',
1035
+ available: false,
1036
+ missingConditions: ['The invoice has a supplier assigned'],
1037
+ });
1038
+ expect(snapshot?.actions?.find(({ label }) => label === 'Reprocess')?.available).toBe(true);
1039
+ expect(snapshot?.facts).toContainEqual({
1040
+ label: 'Supplier Invoice Number',
1041
+ value: 'SI-LOADED',
1042
+ });
1043
+ expect(snapshot?.rows?.map(({ label, count }) => [label, count])).toEqual([
1044
+ ['Lines', 1],
1045
+ ['Tax breakdown and totals', 0],
1046
+ ]);
1047
+
1048
+ fixture.destroy();
1049
+
1050
+ expect(context.snapshot()).toBeNull();
1051
+ });
1052
+ });
1011
1053
  });
@@ -17,6 +17,7 @@ import {
17
17
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
18
18
  import { ActivatedRoute } from '@angular/router';
19
19
  import { formatIsoDate, listContainerClass, useBreadcrumbs } from '@aurora';
20
+ import { ScreenContextService } from '@aurora/modules/screen-context';
20
21
  import { provideTranslocoScope, TranslocoDirective, TranslocoService } from '@jsverse/transloco';
21
22
  import { NgIcon, provideIcons } from '@ng-icons/core';
22
23
  import { lucidePencil, lucideReceipt, lucideTriangleAlert } from '@ng-icons/lucide';
@@ -44,6 +45,13 @@ import {
44
45
  take,
45
46
  type Observable,
46
47
  } from 'rxjs';
48
+ import {
49
+ REVIEW_ACTION_LABEL_KEYS,
50
+ REVIEW_SCREEN_ID,
51
+ reviewScreenActions,
52
+ reviewScreenIssues,
53
+ reviewScreenStatus,
54
+ } from '../data-access/purchase-invoice-review-context.derive';
47
55
  import {
48
56
  flowActionsOf,
49
57
  formatAmount,
@@ -89,25 +97,25 @@ const FLOW_ACTION_VIEW: Record<
89
97
  > = {
90
98
  REPROCESS: {
91
99
  testId: 'reprocess-button',
92
- labelKey: `${KEY}.Reprocess`,
100
+ labelKey: REVIEW_ACTION_LABEL_KEYS.REPROCESS,
93
101
  successKey: `${KEY}.ReprocessSuccess`,
94
102
  run: reprocessPurchaseInvoice,
95
103
  },
96
104
  ACCEPT_DUPLICATE: {
97
105
  testId: 'accept-duplicate-button',
98
- labelKey: `${KEY}.AcceptDuplicate`,
106
+ labelKey: REVIEW_ACTION_LABEL_KEYS.ACCEPT_DUPLICATE,
99
107
  successKey: `${KEY}.AcceptDuplicateSuccess`,
100
108
  run: forceDuplicatePurchaseInvoice,
101
109
  },
102
110
  ACCEPT_REVIEW: {
103
111
  testId: 'accept-review-button',
104
- labelKey: `${KEY}.AcceptReview`,
112
+ labelKey: REVIEW_ACTION_LABEL_KEYS.ACCEPT_REVIEW,
105
113
  successKey: `${KEY}.AcceptReviewSuccess`,
106
114
  run: acceptReviewPurchaseInvoice,
107
115
  },
108
116
  RELEASE_HOLD: {
109
117
  testId: 'release-hold-button',
110
- labelKey: `${KEY}.ReleaseHold`,
118
+ labelKey: REVIEW_ACTION_LABEL_KEYS.RELEASE_HOLD,
111
119
  successKey: `${KEY}.ReleaseHoldSuccess`,
112
120
  run: releaseHoldPurchaseInvoice,
113
121
  },
@@ -217,7 +225,7 @@ type AcceptReviewField = (typeof ACCEPT_REVIEW_FIELDS)[number];
217
225
  hlmBtn
218
226
  (click)="onCancel(form)"
219
227
  >
220
- {{ t('Cancel') }}
228
+ {{ t(actionLabelKeys.CANCEL) }}
221
229
  </button>
222
230
  <button
223
231
  data-testid="save-button"
@@ -230,7 +238,7 @@ type AcceptReviewField = (typeof ACCEPT_REVIEW_FIELDS)[number];
230
238
  @if (saving()) {
231
239
  <hlm-spinner class="text-sm" />
232
240
  }
233
- {{ t('Save') }}
241
+ {{ t(actionLabelKeys.SAVE) }}
234
242
  </button>
235
243
  } @else {
236
244
  <!-- #region customizations -->
@@ -261,7 +269,7 @@ type AcceptReviewField = (typeof ACCEPT_REVIEW_FIELDS)[number];
261
269
  (click)="onModify()"
262
270
  >
263
271
  <ng-icon name="lucidePencil" />
264
- {{ t('business-partner-portal.purchase-invoice-header.Modify') }}
272
+ {{ t(actionLabelKeys.MODIFY) }}
265
273
  </button>
266
274
  }
267
275
  }
@@ -446,6 +454,7 @@ export default class PurchaseInvoiceHeaderDetailComponent {
446
454
  private readonly injector = inject(Injector);
447
455
  private readonly transloco = inject(TranslocoService);
448
456
  private readonly destroyRef = inject(DestroyRef);
457
+ private readonly screenContext = inject(ScreenContextService);
449
458
 
450
459
  protected readonly containerClass = listContainerClass('standalone');
451
460
 
@@ -481,11 +490,15 @@ export default class PurchaseInvoiceHeaderDetailComponent {
481
490
  value: values[field],
482
491
  }));
483
492
  });
493
+ /** The toolbar buttons read the keys the assistant context reads. */
494
+ protected readonly actionLabelKeys = REVIEW_ACTION_LABEL_KEYS;
484
495
  protected readonly canModify = computed(() => isInvoiceEditable(this.invoice()));
485
496
  /** The flow action in flight: while one runs, every action button is disabled. */
486
497
  protected readonly runningAction = signal<ReviewFlowAction | null>(null);
487
498
  protected readonly flowActions = computed(() =>
488
- flowActionsOf(this.invoice()).map((action) => ({ action, ...FLOW_ACTION_VIEW[action] })),
499
+ flowActionsOf(this.invoice())
500
+ .filter(({ available }) => available)
501
+ .map(({ action }) => ({ action, ...FLOW_ACTION_VIEW[action] })),
489
502
  );
490
503
  protected readonly issues = computed(() => this.invoice()?.issues ?? []);
491
504
  protected readonly supplierDocumentView = computed(() =>
@@ -526,6 +539,17 @@ export default class PurchaseInvoiceHeaderDetailComponent {
526
539
  this.fiscalPositionOptions.set(data?.fiscalPositionOptions ?? []);
527
540
  this.paymentMethodOptions.set(data?.paymentMethodOptions ?? []);
528
541
 
542
+ // The form contributes the facts and the rows: the invoice data it renders lives there.
543
+ this.screenContext.contribute(REVIEW_SCREEN_ID, {
544
+ status: () => reviewScreenStatus(this.invoice(), this.transloco.getActiveLang()),
545
+ issues: () =>
546
+ reviewScreenIssues(this.invoice(), (key, params) => this.transloco.translate(key, params)),
547
+ actions: () =>
548
+ reviewScreenActions(this.invoice(), this.mode(), (key, params) =>
549
+ this.transloco.translate(key, params),
550
+ ),
551
+ });
552
+
529
553
  // The document is read as soon as there is one, and again if the invoice links another.
530
554
  effect(() => {
531
555
  const documentId = this.documentId();