@open-mercato/core 0.7.1-develop.7178.1.ab93fbaf4e → 0.7.1-develop.7180.1.9717fbbb43
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/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/staff_time_entry/index.js +14 -0
- package/dist/generated/entities/staff_time_entry/index.js.map +2 -2
- package/dist/generated/entities/staff_time_entry_tag/index.js +15 -0
- package/dist/generated/entities/staff_time_entry_tag/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project/index.js +16 -0
- package/dist/generated/entities/staff_time_project/index.js.map +2 -2
- package/dist/generated/entities/staff_time_report/index.js +57 -0
- package/dist/generated/entities/staff_time_report/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_entry/index.js +27 -0
- package/dist/generated/entities/staff_time_report_entry/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_event/index.js +21 -0
- package/dist/generated/entities/staff_time_report_event/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_project/index.js +15 -0
- package/dist/generated/entities/staff_time_report_project/index.js.map +7 -0
- package/dist/generated/entities/staff_time_tag/index.js +21 -0
- package/dist/generated/entities/staff_time_tag/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task/index.js +37 -0
- package/dist/generated/entities/staff_time_task/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_comment/index.js +21 -0
- package/dist/generated/entities/staff_time_task_comment/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_status/index.js +29 -0
- package/dist/generated/entities/staff_time_task_status/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_tag/index.js +15 -0
- package/dist/generated/entities/staff_time_task_tag/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +11 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +149 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/timesheetFixtures.js +7 -0
- package/dist/helpers/integration/timesheetFixtures.js.map +2 -2
- package/dist/modules/auth/cli.js +16 -0
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/lib/backendChrome.js +1 -0
- package/dist/modules/auth/lib/backendChrome.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerRoleAcls.js +44 -0
- package/dist/modules/customer_accounts/lib/customerRoleAcls.js.map +7 -0
- package/dist/modules/customer_accounts/setup.js +1 -28
- package/dist/modules/customer_accounts/setup.js.map +2 -2
- package/dist/modules/data_sync/api/options.js +2 -0
- package/dist/modules/data_sync/api/options.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +39 -17
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/lib/start-controls.js +42 -0
- package/dist/modules/data_sync/lib/start-controls.js.map +7 -0
- package/dist/modules/staff/acl.js +9 -1
- package/dist/modules/staff/acl.js.map +2 -2
- package/dist/modules/staff/ai-agents.js +142 -0
- package/dist/modules/staff/ai-agents.js.map +7 -0
- package/dist/modules/staff/ai-tools/time-tracking-pack.js +348 -0
- package/dist/modules/staff/ai-tools/time-tracking-pack.js.map +7 -0
- package/dist/modules/staff/ai-tools/types.js +54 -0
- package/dist/modules/staff/ai-tools/types.js.map +7 -0
- package/dist/modules/staff/ai-tools.js +8 -0
- package/dist/modules/staff/ai-tools.js.map +7 -0
- package/dist/modules/staff/analytics.js +84 -1
- package/dist/modules/staff/analytics.js.map +2 -2
- package/dist/modules/staff/api/guards.js +37 -3
- package/dist/modules/staff/api/guards.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +1 -3
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +1 -3
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/portal/time-reports/[id]/route.js +131 -0
- package/dist/modules/staff/api/portal/time-reports/[id]/route.js.map +7 -0
- package/dist/modules/staff/api/portal/time-reports/route.js +179 -0
- package/dist/modules/staff/api/portal/time-reports/route.js.map +7 -0
- package/dist/modules/staff/api/team-members/self/route.js +1 -3
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +1 -3
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +1 -3
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js +174 -0
- package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js.map +7 -0
- package/dist/modules/staff/api/timesheets/access-requests/route.js +226 -0
- package/dist/modules/staff/api/timesheets/access-requests/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +15 -8
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-projects/route.js +13 -1
- package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-work/myWorkAggregate.js +42 -0
- package/dist/modules/staff/api/timesheets/my-work/myWorkAggregate.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-work/route.js +383 -0
- package/dist/modules/staff/api/timesheets/my-work/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js +14 -2
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js +168 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js +246 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js +183 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js +164 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/preview/route.js +360 -0
- package/dist/modules/staff/api/timesheets/reports/preview/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/route.js +316 -0
- package/dist/modules/staff/api/timesheets/reports/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/shared.js +63 -0
- package/dist/modules/staff/api/timesheets/reports/shared.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js +164 -0
- package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/rounding-impact/route.js +168 -0
- package/dist/modules/staff/api/timesheets/settings/rounding-impact/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/route.js +199 -0
- package/dist/modules/staff/api/timesheets/settings/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/access.js +76 -0
- package/dist/modules/staff/api/timesheets/tags/access.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js +235 -0
- package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/route.js +160 -0
- package/dist/modules/staff/api/timesheets/tags/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js +233 -0
- package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/task-statuses/route.js +188 -0
- package/dist/modules/staff/api/timesheets/task-statuses/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js +399 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js +210 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/route.js +333 -0
- package/dist/modules/staff/api/timesheets/tasks/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js +228 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +29 -10
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +31 -18
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +21 -7
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +27 -7
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +215 -32
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js +378 -0
- package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js +340 -0
- package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js +238 -26
- package/dist/modules/staff/api/timesheets/time-entries/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +23 -8
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js +209 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js +59 -2
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-projects/route.js +264 -22
- package/dist/modules/staff/api/timesheets/time-projects/route.js.map +2 -2
- package/dist/modules/staff/backend/staff/time-tracking/board/page.js +110 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.js +981 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.js +583 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.meta.js +15 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.js +65 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.js +229 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js +1014 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.js +97 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.js +1040 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.meta.js +19 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.js +353 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.js +457 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.js +697 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.js +174 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.js +546 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/GridView.js +710 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/GridView.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.js +646 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js +4 -793
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js +2 -7
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js +5 -136
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js +5 -445
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +3 -3
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js +4 -76
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +4 -613
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js +2 -17
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js.map +2 -2
- package/dist/modules/staff/ce.js +40 -0
- package/dist/modules/staff/ce.js.map +2 -2
- package/dist/modules/staff/cli.js +166 -1
- package/dist/modules/staff/cli.js.map +2 -2
- package/dist/modules/staff/commands/index.js +5 -0
- package/dist/modules/staff/commands/index.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-entries.js +569 -21
- package/dist/modules/staff/commands/timesheets-entries.js.map +3 -3
- package/dist/modules/staff/commands/timesheets-projects.js +450 -7
- package/dist/modules/staff/commands/timesheets-projects.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-reports.js +1036 -0
- package/dist/modules/staff/commands/timesheets-reports.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-tags.js +1015 -0
- package/dist/modules/staff/commands/timesheets-tags.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-task-comments.js +438 -0
- package/dist/modules/staff/commands/timesheets-task-comments.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-task-statuses.js +723 -0
- package/dist/modules/staff/commands/timesheets-task-statuses.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-tasks.js +834 -0
- package/dist/modules/staff/commands/timesheets-tasks.js.map +7 -0
- package/dist/modules/staff/data/enrichers.js +426 -12
- package/dist/modules/staff/data/enrichers.js.map +2 -2
- package/dist/modules/staff/data/entities.js +552 -3
- package/dist/modules/staff/data/entities.js.map +2 -2
- package/dist/modules/staff/data/extensions.js +41 -0
- package/dist/modules/staff/data/extensions.js.map +7 -0
- package/dist/modules/staff/data/validators.js +254 -9
- package/dist/modules/staff/data/validators.js.map +2 -2
- package/dist/modules/staff/di.js +42 -1
- package/dist/modules/staff/di.js.map +2 -2
- package/dist/modules/staff/events.js +84 -6
- package/dist/modules/staff/events.js.map +2 -2
- package/dist/modules/staff/events.payloads.js +158 -0
- package/dist/modules/staff/events.payloads.js.map +7 -0
- package/dist/modules/staff/extension-points.js +261 -0
- package/dist/modules/staff/extension-points.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.js +138 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.js +12 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.js +133 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.js +19 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.js.map +7 -0
- package/dist/modules/staff/lib/crud.js +11 -1
- package/dist/modules/staff/lib/crud.js.map +2 -2
- package/dist/modules/staff/lib/time-tracking/access.js +92 -0
- package/dist/modules/staff/lib/time-tracking/access.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/billability.js +39 -0
- package/dist/modules/staff/lib/time-tracking/billability.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/capacity.js +68 -0
- package/dist/modules/staff/lib/time-tracking/capacity.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/componentContracts.js +15 -0
- package/dist/modules/staff/lib/time-tracking/componentContracts.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/cost.js +82 -0
- package/dist/modules/staff/lib/time-tracking/cost.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/duration.js +55 -0
- package/dist/modules/staff/lib/time-tracking/duration.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/featureAccess.js +41 -0
- package/dist/modules/staff/lib/time-tracking/featureAccess.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/interval.js +72 -0
- package/dist/modules/staff/lib/time-tracking/interval.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/migrateProjectCodes.js +88 -0
- package/dist/modules/staff/lib/time-tracking/migrateProjectCodes.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/moneyVisibility.js +10 -0
- package/dist/modules/staff/lib/time-tracking/moneyVisibility.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/overlap.js +87 -0
- package/dist/modules/staff/lib/time-tracking/overlap.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/portalRecipients.js +27 -0
- package/dist/modules/staff/lib/time-tracking/portalRecipients.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/portalReports.js +16 -0
- package/dist/modules/staff/lib/time-tracking/portalReports.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/projectCode.js +135 -0
- package/dist/modules/staff/lib/time-tracking/projectCode.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/reapplyRounding.js +187 -0
- package/dist/modules/staff/lib/time-tracking/reapplyRounding.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/recalculationRunner.js +80 -0
- package/dist/modules/staff/lib/time-tracking/recalculationRunner.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/recalculations.js +56 -0
- package/dist/modules/staff/lib/time-tracking/recalculations.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/invoke.js +63 -0
- package/dist/modules/staff/lib/time-tracking/registries/invoke.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/registry.js +62 -0
- package/dist/modules/staff/lib/time-tracking/registries/registry.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/scope.js +21 -0
- package/dist/modules/staff/lib/time-tracking/registries/scope.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/rollup.js +34 -0
- package/dist/modules/staff/lib/time-tracking/rollup.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/rounding.js +66 -0
- package/dist/modules/staff/lib/time-tracking/rounding.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/roundingImpact.js +39 -0
- package/dist/modules/staff/lib/time-tracking/roundingImpact.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/settingKeys.js +214 -0
- package/dist/modules/staff/lib/time-tracking/settingKeys.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/settings.js +87 -0
- package/dist/modules/staff/lib/time-tracking/settings.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/sqlInClause.js +9 -0
- package/dist/modules/staff/lib/time-tracking/sqlInClause.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/timeEntrySources.js +48 -0
- package/dist/modules/staff/lib/time-tracking/timeEntrySources.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/BoardFilterChips.js +283 -0
- package/dist/modules/staff/lib/time-tracking-ui/BoardFilterChips.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/CustomerPicker.js +324 -0
- package/dist/modules/staff/lib/time-tracking-ui/CustomerPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/DurationInput.js +121 -0
- package/dist/modules/staff/lib/time-tracking-ui/DurationInput.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryDetailsFields.js +188 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryDetailsFields.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryFilterBar.js +89 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryFilterBar.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanBoard.js +855 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanBoard.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanCard.js +360 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanCard.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanColumn.js +259 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanColumn.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/NewTaskDialog.js +238 -0
- package/dist/modules/staff/lib/time-tracking-ui/NewTaskDialog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/NoProjectAccess.js +130 -0
- package/dist/modules/staff/lib/time-tracking-ui/NoProjectAccess.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/PeriodSelector.js +98 -0
- package/dist/modules/staff/lib/time-tracking-ui/PeriodSelector.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/PhasePlaceholder.js +27 -0
- package/dist/modules/staff/lib/time-tracking-ui/PhasePlaceholder.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCodeField.js +166 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCodeField.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.js +295 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectFormSections.js +212 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectFormSections.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.js +729 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ReportSheet.js +217 -0
- package/dist/modules/staff/lib/time-tracking-ui/ReportSheet.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TagPicker.js +158 -0
- package/dist/modules/staff/lib/time-tracking-ui/TagPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskBoardScreen.js +224 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskBoardScreen.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskCommentThread.js +93 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskCommentThread.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskDrawer.js +1196 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskDrawer.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskListView.js +176 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskListView.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskPicker.js +307 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskQuickLog.js +284 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskQuickLog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.js +73 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDialog.js +1499 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDialog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.js +95 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetCalendar.js +188 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetCalendar.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.js +61 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.js +45 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardDirectory.js +176 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardDirectory.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardFilters.js +82 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardFilters.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardSummary.js +5 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardSummary.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/kanbanBoardData.js +152 -0
- package/dist/modules/staff/lib/time-tracking-ui/kanbanBoardData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/projectTeamAssignment.js +92 -0
- package/dist/modules/staff/lib/time-tracking-ui/projectTeamAssignment.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/taskDrawerData.js +111 -0
- package/dist/modules/staff/lib/time-tracking-ui/taskDrawerData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryDialogState.js +243 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryDialogState.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryListData.js +151 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryListData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.js +105 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetData.js +132 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetPeriod.js +205 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetPeriod.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetTargets.js +53 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetTargets.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/useBoardFilters.js +77 -0
- package/dist/modules/staff/lib/time-tracking-ui/useBoardFilters.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.js +151 -0
- package/dist/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.js.map +7 -0
- package/dist/modules/staff/lib/timeTrackingSeeds.js +809 -0
- package/dist/modules/staff/lib/timeTrackingSeeds.js.map +7 -0
- package/dist/modules/staff/lib/timesheets/timeEntryCacheInvalidation.js +2 -3
- package/dist/modules/staff/lib/timesheets/timeEntryCacheInvalidation.js.map +2 -2
- package/dist/modules/staff/lib/timesheets/timeEntryDecoration.js +152 -0
- package/dist/modules/staff/lib/timesheets/timeEntryDecoration.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetBurn.js +36 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetBurn.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThreshold.js +66 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThreshold.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThresholdState.js +78 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThresholdState.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectFinancials.js +81 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectFinancials.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/reportSelection.js +44 -0
- package/dist/modules/staff/lib/timesheets-projects/reportSelection.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.js +169 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.js +22 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js +51 -1
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.js +70 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js +63 -0
- package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/loadReportData.js +170 -0
- package/dist/modules/staff/lib/timesheets-reports/loadReportData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/pdf.js +205 -0
- package/dist/modules/staff/lib/timesheets-reports/pdf.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportApprovalPolicies.js +68 -0
- package/dist/modules/staff/lib/timesheets-reports/reportApprovalPolicies.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigData.js +135 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigState.js +48 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigState.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExport.js +262 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExport.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExportFormats.js +34 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExportFormats.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportGroupings.js +79 -0
- package/dist/modules/staff/lib/timesheets-reports/reportGroupings.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportLabels.js +11 -0
- package/dist/modules/staff/lib/timesheets-reports/reportLabels.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportReference.js +83 -0
- package/dist/modules/staff/lib/timesheets-reports/reportReference.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportRows.js +42 -0
- package/dist/modules/staff/lib/timesheets-reports/reportRows.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportSheetData.js +107 -0
- package/dist/modules/staff/lib/timesheets-reports/reportSheetData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportTotals.js +289 -0
- package/dist/modules/staff/lib/timesheets-reports/reportTotals.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/xlsx.js +145 -0
- package/dist/modules/staff/lib/timesheets-reports/xlsx.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/computeTaskRollups.js +116 -0
- package/dist/modules/staff/lib/timesheets-tasks/computeTaskRollups.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.js +50 -0
- package/dist/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/seedProjectStatuses.js +27 -0
- package/dist/modules/staff/lib/timesheets-tasks/seedProjectStatuses.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusPositions.js +65 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusPositions.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusSlug.js +31 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusSlug.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHierarchy.js +31 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHierarchy.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHoursTotals.js +17 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHoursTotals.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskReference.js +51 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskReference.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js +11 -4
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-ui/ListView.js +369 -111
- package/dist/modules/staff/lib/timesheets-ui/ListView.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js +47 -2
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js.map +2 -2
- package/dist/modules/staff/migrations/Migration20260813073131_staff.js +79 -0
- package/dist/modules/staff/migrations/Migration20260813073131_staff.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260824143357_staff.js +15 -0
- package/dist/modules/staff/migrations/Migration20260824143357_staff.js.map +7 -0
- package/dist/modules/staff/notifications.client.js +16 -0
- package/dist/modules/staff/notifications.client.js.map +7 -0
- package/dist/modules/staff/notifications.handlers.js +80 -0
- package/dist/modules/staff/notifications.handlers.js.map +7 -0
- package/dist/modules/staff/notifications.js +168 -0
- package/dist/modules/staff/notifications.js.map +2 -2
- package/dist/modules/staff/search.js +159 -1
- package/dist/modules/staff/search.js.map +2 -2
- package/dist/modules/staff/setup.js +20 -1
- package/dist/modules/staff/setup.js.map +2 -2
- package/dist/modules/staff/subscribers/time-project-access-requested-notification.js +68 -0
- package/dist/modules/staff/subscribers/time-project-access-requested-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-project-budget-threshold-notification.js +149 -0
- package/dist/modules/staff/subscribers/time-project-budget-threshold-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-report-approved-notification.js +78 -0
- package/dist/modules/staff/subscribers/time-report-approved-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-report-portal-broadcast.js +78 -0
- package/dist/modules/staff/subscribers/time-report-portal-broadcast.js.map +7 -0
- package/dist/modules/staff/translations.js +4 -1
- package/dist/modules/staff/translations.js.map +2 -2
- package/dist/modules/staff/widgets/components.js +7 -0
- package/dist/modules/staff/widgets/components.js.map +7 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js +5 -4
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js.map +2 -2
- package/dist/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.js +135 -0
- package/dist/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.js.map +7 -0
- package/dist/modules/staff/widgets/notifications/index.js +5 -0
- package/dist/modules/staff/widgets/notifications/index.js.map +7 -0
- package/dist/modules/staff/workers/timesheets-reapply-rounding.js +43 -0
- package/dist/modules/staff/workers/timesheets-reapply-rounding.js.map +7 -0
- package/generated/entities/staff_time_entry/index.ts +7 -0
- package/generated/entities/staff_time_entry_tag/index.ts +6 -0
- package/generated/entities/staff_time_project/index.ts +8 -0
- package/generated/entities/staff_time_report/index.ts +27 -0
- package/generated/entities/staff_time_report_entry/index.ts +12 -0
- package/generated/entities/staff_time_report_event/index.ts +9 -0
- package/generated/entities/staff_time_report_project/index.ts +6 -0
- package/generated/entities/staff_time_tag/index.ts +9 -0
- package/generated/entities/staff_time_task/index.ts +17 -0
- package/generated/entities/staff_time_task_comment/index.ts +9 -0
- package/generated/entities/staff_time_task_status/index.ts +13 -0
- package/generated/entities/staff_time_task_tag/index.ts +6 -0
- package/generated/entities.ids.generated.ts +11 -1
- package/generated/entity-fields-registry.ts +149 -0
- package/package.json +7 -7
- package/src/helpers/integration/timesheetFixtures.ts +31 -1
- package/src/modules/auth/README.md +1 -1
- package/src/modules/auth/cli.ts +35 -1
- package/src/modules/auth/i18n/de.json +7 -0
- package/src/modules/auth/i18n/en.json +7 -0
- package/src/modules/auth/i18n/es.json +7 -0
- package/src/modules/auth/i18n/ko.json +7 -0
- package/src/modules/auth/i18n/pl.json +7 -0
- package/src/modules/auth/lib/backendChrome.tsx +1 -0
- package/src/modules/customer_accounts/lib/customerRoleAcls.ts +79 -0
- package/src/modules/customer_accounts/setup.ts +1 -45
- package/src/modules/data_sync/AGENTS.md +34 -0
- package/src/modules/data_sync/api/options.ts +2 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +82 -33
- package/src/modules/data_sync/i18n/de.json +1 -0
- package/src/modules/data_sync/i18n/en.json +1 -0
- package/src/modules/data_sync/i18n/es.json +1 -0
- package/src/modules/data_sync/i18n/ko.json +1 -0
- package/src/modules/data_sync/i18n/pl.json +1 -0
- package/src/modules/data_sync/lib/adapter.ts +45 -0
- package/src/modules/data_sync/lib/start-controls.ts +89 -0
- package/src/modules/staff/AGENTS.md +769 -1
- package/src/modules/staff/acl.ts +9 -0
- package/src/modules/staff/ai-agents.ts +189 -0
- package/src/modules/staff/ai-tools/time-tracking-pack.ts +494 -0
- package/src/modules/staff/ai-tools/types.ts +82 -0
- package/src/modules/staff/ai-tools.ts +13 -0
- package/src/modules/staff/analytics.ts +113 -0
- package/src/modules/staff/api/guards.ts +85 -3
- package/src/modules/staff/api/leave-requests/accept/route.ts +0 -2
- package/src/modules/staff/api/leave-requests/reject/route.ts +0 -2
- package/src/modules/staff/api/portal/time-reports/[id]/route.ts +182 -0
- package/src/modules/staff/api/portal/time-reports/route.ts +270 -0
- package/src/modules/staff/api/team-members/self/route.ts +0 -2
- package/src/modules/staff/api/team-members/tags/assign/route.ts +0 -2
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +0 -2
- package/src/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.ts +292 -0
- package/src/modules/staff/api/timesheets/access-requests/route.ts +299 -0
- package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +15 -7
- package/src/modules/staff/api/timesheets/my-projects/route.ts +14 -1
- package/src/modules/staff/api/timesheets/my-work/myWorkAggregate.ts +90 -0
- package/src/modules/staff/api/timesheets/my-work/route.ts +475 -0
- package/src/modules/staff/api/timesheets/projects/kpis/route.ts +15 -2
- package/src/modules/staff/api/timesheets/reports/[id]/close/route.ts +203 -0
- package/src/modules/staff/api/timesheets/reports/[id]/export/route.ts +315 -0
- package/src/modules/staff/api/timesheets/reports/[id]/sheet/route.ts +220 -0
- package/src/modules/staff/api/timesheets/reports/[id]/unlock/route.ts +208 -0
- package/src/modules/staff/api/timesheets/reports/preview/route.ts +449 -0
- package/src/modules/staff/api/timesheets/reports/route.ts +386 -0
- package/src/modules/staff/api/timesheets/reports/shared.ts +121 -0
- package/src/modules/staff/api/timesheets/settings/reapply-rounding/route.ts +205 -0
- package/src/modules/staff/api/timesheets/settings/rounding-impact/route.ts +226 -0
- package/src/modules/staff/api/timesheets/settings/route.ts +242 -0
- package/src/modules/staff/api/timesheets/tags/access.ts +134 -0
- package/src/modules/staff/api/timesheets/tags/entry-assignments/route.ts +290 -0
- package/src/modules/staff/api/timesheets/tags/route.ts +177 -0
- package/src/modules/staff/api/timesheets/tags/task-assignments/route.ts +294 -0
- package/src/modules/staff/api/timesheets/task-statuses/route.ts +232 -0
- package/src/modules/staff/api/timesheets/tasks/[id]/comments/route.ts +532 -0
- package/src/modules/staff/api/timesheets/tasks/[id]/status/route.ts +271 -0
- package/src/modules/staff/api/timesheets/tasks/route.ts +443 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.ts +306 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +32 -10
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +32 -17
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +27 -6
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +36 -6
- package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +331 -34
- package/src/modules/staff/api/timesheets/time-entries/copy-day/route.ts +533 -0
- package/src/modules/staff/api/timesheets/time-entries/overlaps/route.ts +457 -0
- package/src/modules/staff/api/timesheets/time-entries/route.ts +378 -24
- package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +31 -9
- package/src/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.ts +246 -0
- package/src/modules/staff/api/timesheets/time-projects/[id]/employees/route.ts +62 -2
- package/src/modules/staff/api/timesheets/time-projects/route.ts +397 -22
- package/src/modules/staff/backend/staff/time-tracking/board/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/board/page.tsx +151 -0
- package/src/modules/staff/backend/staff/time-tracking/entries/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/entries/page.tsx +1229 -0
- package/src/modules/staff/backend/staff/time-tracking/page.meta.ts +11 -0
- package/src/modules/staff/backend/staff/time-tracking/page.tsx +823 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.tsx +81 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.tsx +275 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/page.tsx +1420 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/create/page.tsx +109 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/page.meta.ts +15 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/page.tsx +1254 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.ts +466 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/[id]/page.tsx +632 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/create/page.tsx +867 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/page.tsx +246 -0
- package/src/modules/staff/backend/staff/time-tracking/settings/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/settings/page.tsx +701 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/GridView.tsx +953 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/page.tsx +800 -0
- package/src/modules/staff/backend/staff/timesheets/page.meta.ts +6 -6
- package/src/modules/staff/backend/staff/timesheets/page.tsx +12 -1010
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.tsx +4 -158
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +4 -609
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.tsx +3 -89
- package/src/modules/staff/backend/staff/timesheets/projects/page.meta.ts +2 -19
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +3 -778
- package/src/modules/staff/ce.ts +63 -0
- package/src/modules/staff/cli.ts +207 -1
- package/src/modules/staff/commands/index.ts +5 -0
- package/src/modules/staff/commands/timesheets-entries.ts +1006 -28
- package/src/modules/staff/commands/timesheets-projects.ts +593 -7
- package/src/modules/staff/commands/timesheets-reports.ts +1329 -0
- package/src/modules/staff/commands/timesheets-tags.ts +1315 -0
- package/src/modules/staff/commands/timesheets-task-comments.ts +583 -0
- package/src/modules/staff/commands/timesheets-task-statuses.ts +889 -0
- package/src/modules/staff/commands/timesheets-tasks.ts +1121 -0
- package/src/modules/staff/data/enrichers.ts +675 -10
- package/src/modules/staff/data/entities.ts +494 -2
- package/src/modules/staff/data/extensions.ts +68 -0
- package/src/modules/staff/data/validators.ts +348 -3
- package/src/modules/staff/di.ts +96 -0
- package/src/modules/staff/events.payloads.ts +268 -0
- package/src/modules/staff/events.ts +87 -5
- package/src/modules/staff/extension-points.ts +308 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.ts +10 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.tsx +225 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.ts +17 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/page.tsx +182 -0
- package/src/modules/staff/i18n/de.json +899 -0
- package/src/modules/staff/i18n/en.json +899 -0
- package/src/modules/staff/i18n/es.json +899 -0
- package/src/modules/staff/i18n/ko.json +899 -0
- package/src/modules/staff/i18n/pl.json +899 -0
- package/src/modules/staff/lib/crud.ts +14 -3
- package/src/modules/staff/lib/time-tracking/access.ts +155 -0
- package/src/modules/staff/lib/time-tracking/billability.ts +68 -0
- package/src/modules/staff/lib/time-tracking/capacity.ts +124 -0
- package/src/modules/staff/lib/time-tracking/componentContracts.ts +26 -0
- package/src/modules/staff/lib/time-tracking/cost.ts +144 -0
- package/src/modules/staff/lib/time-tracking/duration.ts +68 -0
- package/src/modules/staff/lib/time-tracking/featureAccess.ts +115 -0
- package/src/modules/staff/lib/time-tracking/interval.ts +90 -0
- package/src/modules/staff/lib/time-tracking/migrateProjectCodes.ts +161 -0
- package/src/modules/staff/lib/time-tracking/moneyVisibility.ts +37 -0
- package/src/modules/staff/lib/time-tracking/overlap.ts +159 -0
- package/src/modules/staff/lib/time-tracking/portalRecipients.ts +76 -0
- package/src/modules/staff/lib/time-tracking/portalReports.ts +31 -0
- package/src/modules/staff/lib/time-tracking/projectCode.ts +221 -0
- package/src/modules/staff/lib/time-tracking/reapplyRounding.ts +313 -0
- package/src/modules/staff/lib/time-tracking/recalculationRunner.ts +118 -0
- package/src/modules/staff/lib/time-tracking/recalculations.ts +135 -0
- package/src/modules/staff/lib/time-tracking/registries/invoke.ts +122 -0
- package/src/modules/staff/lib/time-tracking/registries/registry.ts +124 -0
- package/src/modules/staff/lib/time-tracking/registries/scope.ts +56 -0
- package/src/modules/staff/lib/time-tracking/rollup.ts +59 -0
- package/src/modules/staff/lib/time-tracking/rounding.ts +126 -0
- package/src/modules/staff/lib/time-tracking/roundingImpact.ts +75 -0
- package/src/modules/staff/lib/time-tracking/settingKeys.ts +274 -0
- package/src/modules/staff/lib/time-tracking/settings.ts +168 -0
- package/src/modules/staff/lib/time-tracking/sqlInClause.ts +22 -0
- package/src/modules/staff/lib/time-tracking/timeEntrySources.ts +85 -0
- package/src/modules/staff/lib/time-tracking-ui/BoardFilterChips.tsx +360 -0
- package/src/modules/staff/lib/time-tracking-ui/CustomerPicker.tsx +427 -0
- package/src/modules/staff/lib/time-tracking-ui/DurationInput.tsx +192 -0
- package/src/modules/staff/lib/time-tracking-ui/EntryDetailsFields.tsx +224 -0
- package/src/modules/staff/lib/time-tracking-ui/EntryFilterBar.tsx +144 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanBoard.tsx +1065 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanCard.tsx +435 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanColumn.tsx +316 -0
- package/src/modules/staff/lib/time-tracking-ui/NewTaskDialog.tsx +291 -0
- package/src/modules/staff/lib/time-tracking-ui/NoProjectAccess.tsx +162 -0
- package/src/modules/staff/lib/time-tracking-ui/PeriodSelector.tsx +149 -0
- package/src/modules/staff/lib/time-tracking-ui/PhasePlaceholder.tsx +31 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectCodeField.tsx +230 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.tsx +432 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectFormSections.tsx +323 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.tsx +930 -0
- package/src/modules/staff/lib/time-tracking-ui/ReportSheet.tsx +357 -0
- package/src/modules/staff/lib/time-tracking-ui/TagPicker.tsx +195 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskBoardScreen.tsx +243 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskCommentThread.tsx +137 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskDrawer.tsx +1405 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskListView.tsx +260 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskPicker.tsx +435 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskQuickLog.tsx +296 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.tsx +97 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntryDialog.tsx +1929 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.tsx +126 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetCalendar.tsx +265 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.tsx +78 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.tsx +70 -0
- package/src/modules/staff/lib/time-tracking-ui/boardDirectory.ts +231 -0
- package/src/modules/staff/lib/time-tracking-ui/boardFilters.ts +128 -0
- package/src/modules/staff/lib/time-tracking-ui/boardSummary.ts +20 -0
- package/src/modules/staff/lib/time-tracking-ui/kanbanBoardData.ts +228 -0
- package/src/modules/staff/lib/time-tracking-ui/projectTeamAssignment.ts +143 -0
- package/src/modules/staff/lib/time-tracking-ui/taskDrawerData.ts +194 -0
- package/src/modules/staff/lib/time-tracking-ui/timeEntryDialogState.ts +400 -0
- package/src/modules/staff/lib/time-tracking-ui/timeEntryListData.ts +271 -0
- package/src/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.ts +168 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetData.ts +225 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetPeriod.ts +278 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetTargets.ts +93 -0
- package/src/modules/staff/lib/time-tracking-ui/useBoardFilters.ts +107 -0
- package/src/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.ts +245 -0
- package/src/modules/staff/lib/timeTrackingSeeds.ts +1037 -0
- package/src/modules/staff/lib/timesheets/timeEntryCacheInvalidation.ts +11 -10
- package/src/modules/staff/lib/timesheets/timeEntryDecoration.ts +256 -0
- package/src/modules/staff/lib/timesheets-projects/budgetBurn.ts +60 -0
- package/src/modules/staff/lib/timesheets-projects/budgetThreshold.ts +135 -0
- package/src/modules/staff/lib/timesheets-projects/budgetThresholdState.ts +137 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectFinancials.ts +142 -0
- package/src/modules/staff/lib/timesheets-projects/reportSelection.ts +82 -0
- package/src/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.tsx +237 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.tsx +33 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectCard.tsx +56 -1
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.tsx +90 -0
- package/src/modules/staff/lib/timesheets-reports/buildReportSheet.ts +125 -0
- package/src/modules/staff/lib/timesheets-reports/loadReportData.ts +251 -0
- package/src/modules/staff/lib/timesheets-reports/pdf.ts +263 -0
- package/src/modules/staff/lib/timesheets-reports/reportApprovalPolicies.ts +137 -0
- package/src/modules/staff/lib/timesheets-reports/reportConfigData.ts +247 -0
- package/src/modules/staff/lib/timesheets-reports/reportConfigState.ts +89 -0
- package/src/modules/staff/lib/timesheets-reports/reportExport.ts +373 -0
- package/src/modules/staff/lib/timesheets-reports/reportExportFormats.ts +71 -0
- package/src/modules/staff/lib/timesheets-reports/reportGroupings.ts +153 -0
- package/src/modules/staff/lib/timesheets-reports/reportLabels.ts +23 -0
- package/src/modules/staff/lib/timesheets-reports/reportReference.ts +146 -0
- package/src/modules/staff/lib/timesheets-reports/reportRows.ts +89 -0
- package/src/modules/staff/lib/timesheets-reports/reportSheetData.ts +196 -0
- package/src/modules/staff/lib/timesheets-reports/reportTotals.ts +544 -0
- package/src/modules/staff/lib/timesheets-reports/xlsx.ts +207 -0
- package/src/modules/staff/lib/timesheets-tasks/computeTaskRollups.ts +238 -0
- package/src/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.ts +90 -0
- package/src/modules/staff/lib/timesheets-tasks/seedProjectStatuses.ts +43 -0
- package/src/modules/staff/lib/timesheets-tasks/statusPositions.ts +132 -0
- package/src/modules/staff/lib/timesheets-tasks/statusSlug.ts +43 -0
- package/src/modules/staff/lib/timesheets-tasks/taskHierarchy.ts +99 -0
- package/src/modules/staff/lib/timesheets-tasks/taskHoursTotals.ts +42 -0
- package/src/modules/staff/lib/timesheets-tasks/taskReference.ts +108 -0
- package/src/modules/staff/lib/timesheets-ui/CreateProjectDialog.tsx +18 -4
- package/src/modules/staff/lib/timesheets-ui/ListView.tsx +504 -149
- package/src/modules/staff/lib/timesheets-ui/TimerBar.tsx +50 -2
- package/src/modules/staff/migrations/.snapshot-open-mercato.json +3244 -228
- package/src/modules/staff/migrations/Migration20260813073131_staff.ts +94 -0
- package/src/modules/staff/migrations/Migration20260824143357_staff.ts +17 -0
- package/src/modules/staff/notifications.client.ts +16 -0
- package/src/modules/staff/notifications.handlers.ts +88 -0
- package/src/modules/staff/notifications.ts +163 -0
- package/src/modules/staff/search.ts +191 -1
- package/src/modules/staff/setup.ts +22 -0
- package/src/modules/staff/subscribers/time-project-access-requested-notification.ts +95 -0
- package/src/modules/staff/subscribers/time-project-budget-threshold-notification.ts +226 -0
- package/src/modules/staff/subscribers/time-report-approved-notification.ts +116 -0
- package/src/modules/staff/subscribers/time-report-portal-broadcast.ts +120 -0
- package/src/modules/staff/translations.ts +17 -0
- package/src/modules/staff/widgets/components.ts +34 -0
- package/src/modules/staff/widgets/injection/timer-sidebar-indicator/widget.tsx +6 -5
- package/src/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.tsx +138 -0
- package/src/modules/staff/widgets/notifications/index.ts +1 -0
- package/src/modules/staff/workers/timesheets-reapply-rounding.ts +59 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js +0 -123
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js.map +0 -7
- package/src/modules/staff/backend/staff/timesheets/projects/projectFormConfig.ts +0 -138
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `POST /api/staff/timesheets/settings/reapply-rounding` — screen 16 note 3 (T7.3).
|
|
3
|
+
*
|
|
4
|
+
* The mockup draws retroactive rounding as a switch. It is implemented as an
|
|
5
|
+
* **action**, because the two are not the same promise: a switch that rewrites
|
|
6
|
+
* `rounded_minutes` across a tenant's history when the settings form is saved
|
|
7
|
+
* changes invoiced amounts as a side effect of an unrelated save. This endpoint
|
|
8
|
+
* makes it something a person does, once, on purpose, with a progress bar and a
|
|
9
|
+
* final count.
|
|
10
|
+
*
|
|
11
|
+
* It enqueues; it does not do the work. Restating a tenant's entries is exactly the
|
|
12
|
+
* long-running job the progress module exists for, so the response is a `202` with
|
|
13
|
+
* a `progressJobId` that the top bar picks up on its own.
|
|
14
|
+
*
|
|
15
|
+
* Locked entries are never touched — the candidate query excludes them and the
|
|
16
|
+
* command excludes them again, independently.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { NextResponse } from 'next/server'
|
|
20
|
+
import { resolveFeatureAccess } from '../../../../lib/time-tracking/featureAccess'
|
|
21
|
+
import { z } from 'zod'
|
|
22
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
23
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
24
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
25
|
+
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
26
|
+
import { CrudHttpError, forbidden, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
27
|
+
import { runRouteMutationGuards } from '@open-mercato/shared/lib/crud/route-mutation-guard'
|
|
28
|
+
import { authorizeFeatures } from '@open-mercato/shared/security/featurePolicy'
|
|
29
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
30
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
31
|
+
import { emitStaffEvent } from '../../../../events'
|
|
32
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
33
|
+
import type { ProgressService } from '../../../../../progress/lib/progressService'
|
|
34
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
35
|
+
import { STAFF_TIME_TRACKING_RESOURCE_KINDS } from '../../../guards'
|
|
36
|
+
import { runTimesheetInterceptors } from '../../_shared/withTimesheetInterceptors'
|
|
37
|
+
import {
|
|
38
|
+
STAFF_TIME_REAPPLY_ROUNDING_JOB_TYPE,
|
|
39
|
+
STAFF_TIME_REAPPLY_ROUNDING_QUEUE,
|
|
40
|
+
countReapplyRoundingCandidates,
|
|
41
|
+
getStaffQueue,
|
|
42
|
+
type ReapplyRoundingScope,
|
|
43
|
+
} from '../../../../lib/time-tracking/reapplyRounding'
|
|
44
|
+
|
|
45
|
+
const logger = createLogger('staff').child({ component: 'api/timesheets/settings/reapply-rounding' })
|
|
46
|
+
|
|
47
|
+
const MANAGE_FEATURE = 'staff.timesheets.settings.manage'
|
|
48
|
+
const RESOURCE_KIND = STAFF_TIME_TRACKING_RESOURCE_KINDS.settings
|
|
49
|
+
const RESOURCE_ID = 'time_tracking'
|
|
50
|
+
|
|
51
|
+
export const metadata = {
|
|
52
|
+
POST: { requireAuth: true, requireFeatures: [MANAGE_FEATURE] },
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const responseSchema = z.object({
|
|
56
|
+
ok: z.boolean(),
|
|
57
|
+
progressJobId: z.string().uuid().nullable(),
|
|
58
|
+
/** Entries eligible for restatement — locked ones are not among them. */
|
|
59
|
+
candidateCount: z.number().int(),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export async function POST(req: Request) {
|
|
63
|
+
try {
|
|
64
|
+
const container = await createRequestContainer()
|
|
65
|
+
const auth = await getAuthFromRequest(req)
|
|
66
|
+
const { translate } = await resolveTranslations()
|
|
67
|
+
if (!auth) {
|
|
68
|
+
throw new CrudHttpError(401, { error: translate('staff.errors.unauthorized', 'Unauthorized') })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const organizationScope = await resolveOrganizationScopeForRequest({ container, auth, request: req })
|
|
72
|
+
const tenantId = organizationScope?.tenantId ?? auth.tenantId ?? null
|
|
73
|
+
if (!tenantId) {
|
|
74
|
+
throw new CrudHttpError(400, {
|
|
75
|
+
error: translate('staff.errors.missingScope', 'Missing tenant or organization scope.'),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const actorId = typeof auth.sub === 'string' && auth.sub.trim().length > 0 ? auth.sub : 'system'
|
|
80
|
+
const organizationId = organizationScope?.selectedId ?? auth.orgId ?? null
|
|
81
|
+
|
|
82
|
+
// One lookup through the module's single RBAC authority: the decision is
|
|
83
|
+
// checked unconditionally and fails closed, and the grant list the plumbing
|
|
84
|
+
// takes comes from the same answer instead of a second, nullable read.
|
|
85
|
+
const access = await resolveFeatureAccess(container, actorId, [MANAGE_FEATURE], { tenantId, organizationId })
|
|
86
|
+
if (!access.allowed) {
|
|
87
|
+
throw forbidden(translate('staff.errors.forbidden', 'Forbidden'))
|
|
88
|
+
}
|
|
89
|
+
const grantedFeatures = access.grantedFeatures
|
|
90
|
+
|
|
91
|
+
const interceptors = await runTimesheetInterceptors({
|
|
92
|
+
request: req,
|
|
93
|
+
method: 'POST',
|
|
94
|
+
scope: {
|
|
95
|
+
container,
|
|
96
|
+
userId: actorId,
|
|
97
|
+
tenantId,
|
|
98
|
+
organizationId,
|
|
99
|
+
userFeatures: grantedFeatures,
|
|
100
|
+
tenantGlobal: true,
|
|
101
|
+
},
|
|
102
|
+
body: await readJsonSafe<Record<string, unknown>>(req, {}),
|
|
103
|
+
})
|
|
104
|
+
if (!interceptors.ok) return interceptors.response
|
|
105
|
+
const { session } = interceptors
|
|
106
|
+
|
|
107
|
+
const guardResult = await runRouteMutationGuards({
|
|
108
|
+
container,
|
|
109
|
+
req,
|
|
110
|
+
auth: {
|
|
111
|
+
userId: actorId,
|
|
112
|
+
tenantId,
|
|
113
|
+
organizationId,
|
|
114
|
+
userFeatures: grantedFeatures,
|
|
115
|
+
},
|
|
116
|
+
input: {
|
|
117
|
+
resourceKind: RESOURCE_KIND,
|
|
118
|
+
resourceId: RESOURCE_ID,
|
|
119
|
+
operation: 'update',
|
|
120
|
+
mutationPayload: { action: 'reapply-rounding' },
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
if (!guardResult.ok) return guardResult.response
|
|
124
|
+
|
|
125
|
+
const scope: ReapplyRoundingScope = {
|
|
126
|
+
tenantId,
|
|
127
|
+
// `filterIds === null` means the caller may act across every organization of
|
|
128
|
+
// the tenant, which is what a tenant-global rule is about; anything narrower
|
|
129
|
+
// restates only what the caller can already see.
|
|
130
|
+
organizationIds: organizationScope?.filterIds ?? (organizationId ? [organizationId] : null),
|
|
131
|
+
userId: actorId,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const em = container.resolve('em') as EntityManager
|
|
135
|
+
const candidateCount = await countReapplyRoundingCandidates(em.fork(), scope)
|
|
136
|
+
if (candidateCount === 0) {
|
|
137
|
+
// Nothing to restate: no job, no progress bar, no queue traffic. The caller
|
|
138
|
+
// gets an honest zero rather than a job that completes instantly.
|
|
139
|
+
await guardResult.runAfterSuccess()
|
|
140
|
+
return session.respond(200, responseSchema.parse({ ok: true, progressJobId: null, candidateCount: 0 }))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const progressService = container.resolve('progressService') as ProgressService
|
|
144
|
+
const progressJob = await progressService.createJob(
|
|
145
|
+
{
|
|
146
|
+
jobType: STAFF_TIME_REAPPLY_ROUNDING_JOB_TYPE,
|
|
147
|
+
name: translate('staff.time_tracking.settings.retro.jobName', 'Reapply rounding to existing entries'),
|
|
148
|
+
description: translate(
|
|
149
|
+
'staff.time_tracking.settings.retro.jobDescription',
|
|
150
|
+
'Recomputing rounded time on existing entries. Locked entries are not changed.',
|
|
151
|
+
),
|
|
152
|
+
totalCount: candidateCount,
|
|
153
|
+
cancellable: true,
|
|
154
|
+
meta: { source: 'staff.timesheets.settings.reapply-rounding' },
|
|
155
|
+
},
|
|
156
|
+
{ tenantId, organizationId, userId: actorId },
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const queue = getStaffQueue(STAFF_TIME_REAPPLY_ROUNDING_QUEUE)
|
|
160
|
+
await queue.enqueue({ progressJobId: progressJob.id, scope })
|
|
161
|
+
|
|
162
|
+
await guardResult.runAfterSuccess()
|
|
163
|
+
|
|
164
|
+
void emitStaffEvent('staff.timesheets.time_tracking.rounding_reapplied', {
|
|
165
|
+
tenantId,
|
|
166
|
+
organizationId,
|
|
167
|
+
progressJobId: progressJob.id,
|
|
168
|
+
candidateCount,
|
|
169
|
+
}, { persistent: true }).catch((err) => {
|
|
170
|
+
logger.error('staff.timesheets emit time_tracking.rounding_reapplied failed', { err })
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
return session.respond(202, responseSchema.parse({ ok: true, progressJobId: progressJob.id, candidateCount }))
|
|
174
|
+
} catch (err) {
|
|
175
|
+
if (isCrudHttpError(err)) {
|
|
176
|
+
return NextResponse.json(err.body, { status: err.status })
|
|
177
|
+
}
|
|
178
|
+
logger.error('staff.timesheets.settings.reapply-rounding failed', { err })
|
|
179
|
+
const { translate } = await resolveTranslations()
|
|
180
|
+
return NextResponse.json(
|
|
181
|
+
{ error: translate('staff.errors.internal', 'Internal server error') },
|
|
182
|
+
{ status: 500 },
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const openApi: OpenApiRouteDoc = {
|
|
188
|
+
tag: 'Staff',
|
|
189
|
+
summary: 'Reapply the rounding rule to existing entries',
|
|
190
|
+
methods: {
|
|
191
|
+
POST: {
|
|
192
|
+
summary: 'Queue a retroactive rounding job',
|
|
193
|
+
description:
|
|
194
|
+
'Enqueues a `ProgressJob` that recomputes `rounded_minutes` on existing time entries under the tenant’s current rounding rule. Entries locked into a closed report are excluded — a billed amount is never restated. Returns `202` with `progressJobId`, or `200` with a null job id when there is nothing to restate.',
|
|
195
|
+
responses: [
|
|
196
|
+
{ status: 200, description: 'Nothing to restate', schema: responseSchema },
|
|
197
|
+
{ status: 202, description: 'Job queued', schema: responseSchema },
|
|
198
|
+
{ status: 400, description: 'Missing scope', schema: z.object({ error: z.string() }) },
|
|
199
|
+
{ status: 401, description: 'Unauthorized', schema: z.object({ error: z.string() }) },
|
|
200
|
+
{ status: 403, description: 'Missing staff.timesheets.settings.manage' },
|
|
201
|
+
{ status: 500, description: 'Queueing failure', schema: z.object({ error: z.string() }) },
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET /api/staff/timesheets/settings/rounding-impact` — screen 16's 90-day preview (T7.2).
|
|
3
|
+
*
|
|
4
|
+
* Rounding is the one setting on that screen that moves money, and its effect is
|
|
5
|
+
* invisible until an invoice goes out. This route answers "what would the last 90
|
|
6
|
+
* days have billed under the rule I am about to save" before the Save button is
|
|
7
|
+
* pressed, so changing it stops being a blind shot at client amounts.
|
|
8
|
+
*
|
|
9
|
+
* Three deliberate properties:
|
|
10
|
+
*
|
|
11
|
+
* * **Locked entries are excluded.** An entry frozen into a closed report cannot
|
|
12
|
+
* be restated, so counting it in the projection would promise a change that the
|
|
13
|
+
* retro-rounding job would then refuse to make. They are counted separately and
|
|
14
|
+
* returned as `lockedEntryCount`, which is what lets the screen say "closed
|
|
15
|
+
* reports stay as they are" from data rather than as boilerplate.
|
|
16
|
+
* * **The projection is per entry** (D-7) — the database groups identical
|
|
17
|
+
* durations and `projectRoundingImpact` rounds each distinct duration once,
|
|
18
|
+
* through the same `roundMinutes` the write path uses.
|
|
19
|
+
* * **The candidate rule comes from the query string**, defaulting to what is
|
|
20
|
+
* stored, so the card recomputes as the toggles move without saving anything.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { NextResponse } from 'next/server'
|
|
24
|
+
import { z } from 'zod'
|
|
25
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
26
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
27
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
28
|
+
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
29
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
30
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
31
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
32
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
33
|
+
import type { ModuleConfigService } from '@open-mercato/core/modules/configs/lib/module-config-service'
|
|
34
|
+
import { readTimeTrackingSettings } from '../../../../lib/time-tracking/settings'
|
|
35
|
+
import type { RoundingDirection, RoundingSettings, RoundingUnitMinutes } from '../../../../lib/time-tracking/rounding'
|
|
36
|
+
import { projectRoundingImpact, type DurationBucket } from '../../../../lib/time-tracking/roundingImpact'
|
|
37
|
+
import { buildSqlInClause } from '../../../../lib/time-tracking/sqlInClause'
|
|
38
|
+
|
|
39
|
+
const logger = createLogger('staff').child({ component: 'api/timesheets/settings/rounding-impact' })
|
|
40
|
+
|
|
41
|
+
const MANAGE_FEATURE = 'staff.timesheets.settings.manage'
|
|
42
|
+
|
|
43
|
+
export const DEFAULT_IMPACT_WINDOW_DAYS = 90
|
|
44
|
+
const MAX_IMPACT_WINDOW_DAYS = 365
|
|
45
|
+
|
|
46
|
+
export const metadata = {
|
|
47
|
+
GET: { requireAuth: true, requireFeatures: [MANAGE_FEATURE] },
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const querySchema = z.object({
|
|
51
|
+
unitMinutes: z.coerce.number().optional(),
|
|
52
|
+
direction: z.enum(['up', 'nearest']).optional(),
|
|
53
|
+
windowDays: z.coerce.number().int().min(1).max(MAX_IMPACT_WINDOW_DAYS).optional(),
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const impactSchema = z.object({
|
|
57
|
+
entryCount: z.number().int(),
|
|
58
|
+
rawMinutes: z.number().int(),
|
|
59
|
+
roundedMinutes: z.number().int(),
|
|
60
|
+
deltaMinutes: z.number().int(),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const responseSchema = z.object({
|
|
64
|
+
windowDays: z.number().int(),
|
|
65
|
+
from: z.string(),
|
|
66
|
+
to: z.string(),
|
|
67
|
+
rounding: z.object({
|
|
68
|
+
unitMinutes: z.union([z.literal(0), z.literal(5), z.literal(10), z.literal(15)]),
|
|
69
|
+
direction: z.enum(['up', 'nearest']),
|
|
70
|
+
}),
|
|
71
|
+
/** The projection under the requested (or stored) rule, locked entries excluded. */
|
|
72
|
+
projected: impactSchema,
|
|
73
|
+
/** The same window under the rule currently stored, so the screen can show the move. */
|
|
74
|
+
current: impactSchema,
|
|
75
|
+
/** Entries in the window that a rounding change can never restate. */
|
|
76
|
+
lockedEntryCount: z.number().int(),
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const ROUNDING_UNITS: readonly number[] = [0, 5, 10, 15]
|
|
80
|
+
|
|
81
|
+
type BucketRow = {
|
|
82
|
+
duration_minutes: string | number | null
|
|
83
|
+
entry_count: string | number | null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type LockedRow = {
|
|
87
|
+
locked_count: string | number | null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function toDateOnlyString(value: Date): string {
|
|
91
|
+
return value.toISOString().slice(0, 10)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function GET(req: Request) {
|
|
95
|
+
try {
|
|
96
|
+
const container = await createRequestContainer()
|
|
97
|
+
const auth = await getAuthFromRequest(req)
|
|
98
|
+
const { translate } = await resolveTranslations()
|
|
99
|
+
if (!auth) {
|
|
100
|
+
throw new CrudHttpError(401, { error: translate('staff.errors.unauthorized', 'Unauthorized') })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })
|
|
104
|
+
const tenantId = scope?.tenantId ?? auth.tenantId ?? null
|
|
105
|
+
if (!tenantId) {
|
|
106
|
+
throw new CrudHttpError(400, {
|
|
107
|
+
error: translate('staff.errors.missingScope', 'Missing tenant or organization scope.'),
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const url = new URL(req.url)
|
|
112
|
+
const parsedQuery = querySchema.safeParse(Object.fromEntries(url.searchParams.entries()))
|
|
113
|
+
if (!parsedQuery.success) {
|
|
114
|
+
throw new CrudHttpError(400, {
|
|
115
|
+
error: translate('staff.errors.invalid_request', 'Invalid request'),
|
|
116
|
+
details: parsedQuery.error.issues,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const configService = container.resolve('moduleConfigService') as ModuleConfigService
|
|
121
|
+
const stored = await readTimeTrackingSettings(configService, { tenantId })
|
|
122
|
+
|
|
123
|
+
const requestedUnit = parsedQuery.data.unitMinutes
|
|
124
|
+
const candidate: RoundingSettings = {
|
|
125
|
+
unitMinutes:
|
|
126
|
+
typeof requestedUnit === 'number' && ROUNDING_UNITS.includes(requestedUnit)
|
|
127
|
+
? (requestedUnit as RoundingUnitMinutes)
|
|
128
|
+
: stored.rounding.unitMinutes,
|
|
129
|
+
direction: (parsedQuery.data.direction ?? stored.rounding.direction) as RoundingDirection,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const windowDays = parsedQuery.data.windowDays ?? DEFAULT_IMPACT_WINDOW_DAYS
|
|
133
|
+
const to = new Date()
|
|
134
|
+
const from = new Date(to.getTime() - (windowDays - 1) * 24 * 60 * 60 * 1000)
|
|
135
|
+
const fromDate = toDateOnlyString(from)
|
|
136
|
+
const toDate = toDateOnlyString(to)
|
|
137
|
+
|
|
138
|
+
// Organizations narrow the same way every other read in the module does; a null
|
|
139
|
+
// filter list means "every organization of this tenant", which is what a
|
|
140
|
+
// tenant-global setting is asking about.
|
|
141
|
+
const organizationIds = scope?.filterIds ?? null
|
|
142
|
+
const orgIn = organizationIds ? buildSqlInClause('organization_id', organizationIds) : null
|
|
143
|
+
const orgClause = orgIn ? ` AND ${orgIn.sql}` : ''
|
|
144
|
+
const orgParams = orgIn ? orgIn.params : []
|
|
145
|
+
|
|
146
|
+
const em = container.resolve('em') as EntityManager
|
|
147
|
+
const connection = em.getConnection()
|
|
148
|
+
|
|
149
|
+
const bucketRows = (await connection.execute(
|
|
150
|
+
`
|
|
151
|
+
SELECT duration_minutes, COUNT(*)::bigint AS entry_count
|
|
152
|
+
FROM staff_time_entries
|
|
153
|
+
WHERE tenant_id = ?
|
|
154
|
+
AND deleted_at IS NULL
|
|
155
|
+
AND locked_report_id IS NULL
|
|
156
|
+
AND date >= ?::date
|
|
157
|
+
AND date <= ?::date${orgClause}
|
|
158
|
+
GROUP BY duration_minutes
|
|
159
|
+
`,
|
|
160
|
+
[tenantId, fromDate, toDate, ...orgParams],
|
|
161
|
+
)) as BucketRow[]
|
|
162
|
+
|
|
163
|
+
const lockedRows = (await connection.execute(
|
|
164
|
+
`
|
|
165
|
+
SELECT COUNT(*)::bigint AS locked_count
|
|
166
|
+
FROM staff_time_entries
|
|
167
|
+
WHERE tenant_id = ?
|
|
168
|
+
AND deleted_at IS NULL
|
|
169
|
+
AND locked_report_id IS NOT NULL
|
|
170
|
+
AND date >= ?::date
|
|
171
|
+
AND date <= ?::date${orgClause}
|
|
172
|
+
`,
|
|
173
|
+
[tenantId, fromDate, toDate, ...orgParams],
|
|
174
|
+
)) as LockedRow[]
|
|
175
|
+
|
|
176
|
+
const buckets: DurationBucket[] = (bucketRows ?? []).map((row) => ({
|
|
177
|
+
durationMinutes: Number(row.duration_minutes ?? 0),
|
|
178
|
+
entryCount: Number(row.entry_count ?? 0),
|
|
179
|
+
}))
|
|
180
|
+
|
|
181
|
+
const lockedRaw = Number(lockedRows?.[0]?.locked_count ?? 0)
|
|
182
|
+
|
|
183
|
+
return NextResponse.json(
|
|
184
|
+
{
|
|
185
|
+
windowDays,
|
|
186
|
+
from: fromDate,
|
|
187
|
+
to: toDate,
|
|
188
|
+
rounding: candidate,
|
|
189
|
+
projected: projectRoundingImpact(buckets, candidate),
|
|
190
|
+
current: projectRoundingImpact(buckets, stored.rounding),
|
|
191
|
+
lockedEntryCount: Number.isFinite(lockedRaw) ? lockedRaw : 0,
|
|
192
|
+
},
|
|
193
|
+
{ status: 200 },
|
|
194
|
+
)
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (err instanceof CrudHttpError) {
|
|
197
|
+
return NextResponse.json(err.body, { status: err.status })
|
|
198
|
+
}
|
|
199
|
+
logger.error('staff.timesheets.settings.rounding-impact failed', { err })
|
|
200
|
+
const { translate } = await resolveTranslations()
|
|
201
|
+
return NextResponse.json(
|
|
202
|
+
{ error: translate('staff.errors.internal', 'Internal server error') },
|
|
203
|
+
{ status: 500 },
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export const openApi: OpenApiRouteDoc = {
|
|
209
|
+
tag: 'Staff',
|
|
210
|
+
summary: 'Rounding impact preview',
|
|
211
|
+
methods: {
|
|
212
|
+
GET: {
|
|
213
|
+
summary: 'Project the billing impact of a rounding rule over a recent window',
|
|
214
|
+
description:
|
|
215
|
+
'Answers what the last `windowDays` (default 90) would have billed under a candidate rounding rule, before it is saved. Entries already locked into a closed report are excluded from the projection — they cannot be restated — and reported separately as `lockedEntryCount`. Rounding is applied per entry (D-7) through the same helper the write path uses.',
|
|
216
|
+
query: querySchema,
|
|
217
|
+
responses: [
|
|
218
|
+
{ status: 200, description: 'Rounding impact projection', schema: responseSchema },
|
|
219
|
+
{ status: 400, description: 'Invalid request or missing scope', schema: z.object({ error: z.string() }) },
|
|
220
|
+
{ status: 401, description: 'Unauthorized', schema: z.object({ error: z.string() }) },
|
|
221
|
+
{ status: 403, description: 'Missing staff.timesheets.settings.manage' },
|
|
222
|
+
{ status: 500, description: 'Projection failure', schema: z.object({ error: z.string() }) },
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { resolveFeatureAccess } from '../../../lib/time-tracking/featureAccess'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
6
|
+
import { CrudHttpError, forbidden, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
|
+
import { runRouteMutationGuards } from '@open-mercato/shared/lib/crud/route-mutation-guard'
|
|
8
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
9
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
10
|
+
import { emitStaffEvent } from '../../../events'
|
|
11
|
+
import type { OpenApiMethodDoc, OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
12
|
+
import type { ModuleConfigService } from '@open-mercato/core/modules/configs/lib/module-config-service'
|
|
13
|
+
import { buildTimeTrackingSettingsSchema } from '../../../lib/time-tracking/settingKeys'
|
|
14
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
15
|
+
import { STAFF_TIME_TRACKING_RESOURCE_KINDS } from '../../guards'
|
|
16
|
+
import {
|
|
17
|
+
readSearchParamsRecord,
|
|
18
|
+
runTimesheetInterceptors,
|
|
19
|
+
} from '../_shared/withTimesheetInterceptors'
|
|
20
|
+
import {
|
|
21
|
+
readTimeTrackingSettings,
|
|
22
|
+
writeTimeTrackingSettings,
|
|
23
|
+
type TimeTrackingSettings,
|
|
24
|
+
} from '../../../lib/time-tracking/settings'
|
|
25
|
+
|
|
26
|
+
const logger = createLogger('staff').child({ component: 'api/timesheets/settings' })
|
|
27
|
+
|
|
28
|
+
const VIEW_FEATURE = 'staff.timesheets.view'
|
|
29
|
+
const MANAGE_FEATURE = 'staff.timesheets.settings.manage'
|
|
30
|
+
const RESOURCE_KIND = STAFF_TIME_TRACKING_RESOURCE_KINDS.settings
|
|
31
|
+
const RESOURCE_ID = 'time_tracking'
|
|
32
|
+
|
|
33
|
+
export const metadata = {
|
|
34
|
+
GET: { requireAuth: true, requireFeatures: [VIEW_FEATURE] },
|
|
35
|
+
PUT: { requireAuth: true, requireFeatures: [MANAGE_FEATURE] },
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* EP-42 — derived from the setting-key registry, so a contributed key is published in
|
|
40
|
+
* the OpenAPI response shape instead of being invisible to it. Rebuilt per read for the
|
|
41
|
+
* same reason the request schema is: a key may be registered after this module loads.
|
|
42
|
+
*/
|
|
43
|
+
function settingsResponseSchema(): z.ZodTypeAny {
|
|
44
|
+
return buildTimeTrackingSettingsSchema()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type SettingsContext = {
|
|
48
|
+
container: Awaited<ReturnType<typeof createRequestContainer>>
|
|
49
|
+
tenantId: string
|
|
50
|
+
organizationId: string | null
|
|
51
|
+
actorId: string
|
|
52
|
+
translate: (key: string, fallback?: string) => string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function resolveSettingsContext(req: Request): Promise<SettingsContext> {
|
|
56
|
+
const container = await createRequestContainer()
|
|
57
|
+
const auth = await getAuthFromRequest(req)
|
|
58
|
+
const { translate } = await resolveTranslations()
|
|
59
|
+
if (!auth || !auth.tenantId) {
|
|
60
|
+
throw new CrudHttpError(401, { error: translate('staff.errors.unauthorized', 'Unauthorized') })
|
|
61
|
+
}
|
|
62
|
+
const actorId =
|
|
63
|
+
(typeof auth.sub === 'string' && auth.sub.trim().length > 0 && auth.sub) ||
|
|
64
|
+
(typeof auth.userId === 'string' && auth.userId.trim().length > 0 && auth.userId) ||
|
|
65
|
+
(typeof auth.keyId === 'string' && auth.keyId.trim().length > 0 && auth.keyId) ||
|
|
66
|
+
'system'
|
|
67
|
+
return {
|
|
68
|
+
container,
|
|
69
|
+
tenantId: auth.tenantId,
|
|
70
|
+
organizationId: auth.orgId ?? null,
|
|
71
|
+
actorId,
|
|
72
|
+
translate,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function resolveConfigService(context: SettingsContext): ModuleConfigService {
|
|
77
|
+
return context.container.resolve('moduleConfigService') as ModuleConfigService
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function GET(req: Request) {
|
|
81
|
+
try {
|
|
82
|
+
const context = await resolveSettingsContext(req)
|
|
83
|
+
const interceptors = await runTimesheetInterceptors({
|
|
84
|
+
request: req,
|
|
85
|
+
method: 'GET',
|
|
86
|
+
scope: {
|
|
87
|
+
container: context.container,
|
|
88
|
+
userId: context.actorId,
|
|
89
|
+
tenantId: context.tenantId,
|
|
90
|
+
organizationId: context.organizationId,
|
|
91
|
+
tenantGlobal: true,
|
|
92
|
+
},
|
|
93
|
+
query: readSearchParamsRecord(req.url),
|
|
94
|
+
})
|
|
95
|
+
if (!interceptors.ok) return interceptors.response
|
|
96
|
+
|
|
97
|
+
const settings = await readTimeTrackingSettings(resolveConfigService(context), {
|
|
98
|
+
tenantId: context.tenantId,
|
|
99
|
+
})
|
|
100
|
+
return interceptors.session.respond(200, settings)
|
|
101
|
+
} catch (err) {
|
|
102
|
+
return errorResponse(err, 'staff.timesheets.settings.GET failed')
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function PUT(req: Request) {
|
|
107
|
+
try {
|
|
108
|
+
const context = await resolveSettingsContext(req)
|
|
109
|
+
// One lookup through the module's single RBAC authority, answering both
|
|
110
|
+
// questions this route asks: may the caller manage settings, and what grant
|
|
111
|
+
// list do the interceptors and the mutation-guard registry gate on. The
|
|
112
|
+
// decision is checked unconditionally and fails closed; the list is plumbing
|
|
113
|
+
// and is empty — never absent — when RBAC could not produce it.
|
|
114
|
+
const access = await resolveFeatureAccess(context.container, context.actorId || null, [MANAGE_FEATURE], {
|
|
115
|
+
tenantId: context.tenantId,
|
|
116
|
+
organizationId: context.organizationId,
|
|
117
|
+
})
|
|
118
|
+
if (!access.allowed) {
|
|
119
|
+
throw forbidden(context.translate('staff.errors.forbidden', 'Forbidden'))
|
|
120
|
+
}
|
|
121
|
+
const grantedFeatures = access.grantedFeatures
|
|
122
|
+
|
|
123
|
+
const interceptors = await runTimesheetInterceptors({
|
|
124
|
+
request: req,
|
|
125
|
+
method: 'PUT',
|
|
126
|
+
scope: {
|
|
127
|
+
container: context.container,
|
|
128
|
+
userId: context.actorId,
|
|
129
|
+
tenantId: context.tenantId,
|
|
130
|
+
organizationId: context.organizationId,
|
|
131
|
+
userFeatures: grantedFeatures,
|
|
132
|
+
tenantGlobal: true,
|
|
133
|
+
},
|
|
134
|
+
body: await readJsonSafe<Record<string, unknown>>(req, {}),
|
|
135
|
+
})
|
|
136
|
+
if (!interceptors.ok) return interceptors.response
|
|
137
|
+
const { session } = interceptors
|
|
138
|
+
|
|
139
|
+
const settingsSchema = buildTimeTrackingSettingsSchema()
|
|
140
|
+
const parsed = settingsSchema.parse(session.body)
|
|
141
|
+
|
|
142
|
+
const guardResult = await runRouteMutationGuards({
|
|
143
|
+
container: context.container,
|
|
144
|
+
req,
|
|
145
|
+
auth: {
|
|
146
|
+
userId: context.actorId,
|
|
147
|
+
tenantId: context.tenantId,
|
|
148
|
+
organizationId: context.organizationId,
|
|
149
|
+
userFeatures: grantedFeatures,
|
|
150
|
+
},
|
|
151
|
+
input: {
|
|
152
|
+
resourceKind: RESOURCE_KIND,
|
|
153
|
+
resourceId: RESOURCE_ID,
|
|
154
|
+
operation: 'update',
|
|
155
|
+
mutationPayload: parsed,
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
if (!guardResult.ok) return guardResult.response
|
|
159
|
+
|
|
160
|
+
const effective = guardResult.modifiedPayload
|
|
161
|
+
? settingsSchema.parse({ ...parsed, ...guardResult.modifiedPayload })
|
|
162
|
+
: parsed
|
|
163
|
+
|
|
164
|
+
const settings: TimeTrackingSettings = await writeTimeTrackingSettings(
|
|
165
|
+
resolveConfigService(context),
|
|
166
|
+
{ tenantId: context.tenantId },
|
|
167
|
+
effective,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
await guardResult.runAfterSuccess()
|
|
171
|
+
|
|
172
|
+
void emitStaffEvent('staff.timesheets.time_tracking.settings_updated', {
|
|
173
|
+
tenantId: context.tenantId,
|
|
174
|
+
organizationId: context.organizationId,
|
|
175
|
+
settings,
|
|
176
|
+
}, { persistent: true }).catch((err) => {
|
|
177
|
+
logger.error('staff.timesheets emit time_tracking.settings_updated failed', { err })
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
return session.respond(200, settings)
|
|
181
|
+
} catch (err) {
|
|
182
|
+
return errorResponse(err, 'staff.timesheets.settings.PUT failed')
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function errorResponse(err: unknown, message: string) {
|
|
187
|
+
if (isCrudHttpError(err)) {
|
|
188
|
+
return NextResponse.json(err.body, { status: err.status })
|
|
189
|
+
}
|
|
190
|
+
const { translate } = await resolveTranslations()
|
|
191
|
+
if (err instanceof z.ZodError) {
|
|
192
|
+
return NextResponse.json(
|
|
193
|
+
{ error: translate('staff.errors.invalid_request', 'Invalid request'), details: err.issues },
|
|
194
|
+
{ status: 400 },
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
logger.error(message, { err })
|
|
198
|
+
return NextResponse.json(
|
|
199
|
+
{ error: translate('staff.errors.internal', 'Internal server error') },
|
|
200
|
+
{ status: 500 },
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const getDoc: OpenApiMethodDoc = {
|
|
205
|
+
summary: 'Read time tracking settings',
|
|
206
|
+
tags: ['Staff'],
|
|
207
|
+
get responses() {
|
|
208
|
+
return [
|
|
209
|
+
{ status: 200, description: 'Tenant time tracking settings', schema: settingsResponseSchema() },
|
|
210
|
+
{ status: 401, description: 'Unauthorized', schema: z.object({ error: z.string() }) },
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const putDoc: OpenApiMethodDoc = {
|
|
216
|
+
summary: 'Update time tracking settings',
|
|
217
|
+
tags: ['Staff'],
|
|
218
|
+
get requestBody() {
|
|
219
|
+
return { schema: buildTimeTrackingSettingsSchema() }
|
|
220
|
+
},
|
|
221
|
+
get responses() {
|
|
222
|
+
return [
|
|
223
|
+
{ status: 200, description: 'Updated time tracking settings', schema: settingsResponseSchema() },
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
errors: [
|
|
227
|
+
{ status: 400, description: 'Invalid request body' },
|
|
228
|
+
{ status: 401, description: 'Unauthorized' },
|
|
229
|
+
{ status: 403, description: 'Missing staff.timesheets.settings.manage' },
|
|
230
|
+
],
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const openApi: OpenApiRouteDoc = {
|
|
234
|
+
tag: 'Staff',
|
|
235
|
+
summary: 'Time tracking module settings',
|
|
236
|
+
methods: {
|
|
237
|
+
GET: getDoc,
|
|
238
|
+
PUT: putDoc,
|
|
239
|
+
},
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export { GET, PUT }
|