@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,1036 @@
|
|
|
1
|
+
import { registerCommand } from "@open-mercato/shared/lib/commands";
|
|
2
|
+
import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
|
|
3
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
4
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
5
|
+
import { buildChanges, emitCrudSideEffects, emitCrudUndoSideEffects } from "@open-mercato/shared/lib/commands/helpers";
|
|
6
|
+
import { withAtomicFlush } from "@open-mercato/shared/lib/commands/flush";
|
|
7
|
+
import {
|
|
8
|
+
StaffTimeEntry,
|
|
9
|
+
StaffTimeProject,
|
|
10
|
+
StaffTimeReport,
|
|
11
|
+
StaffTimeReportEntry,
|
|
12
|
+
StaffTimeReportEvent,
|
|
13
|
+
StaffTimeReportProject
|
|
14
|
+
} from "../data/entities.js";
|
|
15
|
+
import {
|
|
16
|
+
staffTimeReportCloseSchema,
|
|
17
|
+
staffTimeReportCreateSchema,
|
|
18
|
+
staffTimeReportUnlockSchema,
|
|
19
|
+
staffTimeReportUpdateSchema
|
|
20
|
+
} from "../data/validators.js";
|
|
21
|
+
import { readTimeTrackingSettings } from "../lib/time-tracking/settings.js";
|
|
22
|
+
import {
|
|
23
|
+
allocateReportReference,
|
|
24
|
+
highestReportSequenceNumber,
|
|
25
|
+
isReportReferenceConflict,
|
|
26
|
+
reportReferencePrefix,
|
|
27
|
+
reportReferenceYear,
|
|
28
|
+
withReportReferenceRetry
|
|
29
|
+
} from "../lib/timesheets-reports/reportReference.js";
|
|
30
|
+
import { loadReportData } from "../lib/timesheets-reports/loadReportData.js";
|
|
31
|
+
import { reportSheetLabels } from "../lib/timesheets-reports/reportLabels.js";
|
|
32
|
+
import {
|
|
33
|
+
computeReportTotals,
|
|
34
|
+
resolveEntryValues,
|
|
35
|
+
resolveReportCurrency,
|
|
36
|
+
selectIncludedEntries
|
|
37
|
+
} from "../lib/timesheets-reports/reportTotals.js";
|
|
38
|
+
import { emitStaffEvent } from "../events.js";
|
|
39
|
+
import {
|
|
40
|
+
applyScopeToWhere,
|
|
41
|
+
commandActorScope,
|
|
42
|
+
commandInputScope,
|
|
43
|
+
ensureOrganizationScope,
|
|
44
|
+
ensureTenantScope,
|
|
45
|
+
extractUndoPayload,
|
|
46
|
+
scopedStaffSnapshotWhere,
|
|
47
|
+
staffSnapshotScopeFromContext,
|
|
48
|
+
staffSnapshotScopeFromSnapshot
|
|
49
|
+
} from "./shared.js";
|
|
50
|
+
const staffTimeReportCommandIds = {
|
|
51
|
+
create: "staff.timesheets.reports.create",
|
|
52
|
+
update: "staff.timesheets.reports.update",
|
|
53
|
+
delete: "staff.timesheets.reports.delete",
|
|
54
|
+
close: "staff.timesheets.reports.close",
|
|
55
|
+
unlock: "staff.timesheets.reports.unlock"
|
|
56
|
+
};
|
|
57
|
+
const STAFF_TIME_REPORT_RESOURCE_KIND = "staff.timesheets.time_report";
|
|
58
|
+
const REPORT_CURRENCY_CONFLICT_CODE = "report_currency_conflict";
|
|
59
|
+
const REPORT_PROJECT_CUSTOMER_MISMATCH_CODE = "report_project_customer_mismatch";
|
|
60
|
+
const REPORT_PROJECT_NOT_FOUND_CODE = "report_project_not_found";
|
|
61
|
+
const REPORT_CLOSED_CODE = "report_closed";
|
|
62
|
+
const REPORT_NOT_CLOSED_CODE = "report_not_closed";
|
|
63
|
+
const REPORT_REFERENCE_CONFLICT_CODE = "report_reference_conflict";
|
|
64
|
+
const REPORT_EMPTY_CODE = "report_empty";
|
|
65
|
+
const logger = createLogger("staff").child({ component: "commands/timesheets-reports" });
|
|
66
|
+
const reportCrudIndexer = {
|
|
67
|
+
entityType: "staff:staff_time_report"
|
|
68
|
+
};
|
|
69
|
+
const reportCrudEvents = {
|
|
70
|
+
module: "staff",
|
|
71
|
+
entity: "timesheets.time_report",
|
|
72
|
+
persistent: true,
|
|
73
|
+
buildPayload: (ctx) => ({
|
|
74
|
+
id: ctx.identifiers.id,
|
|
75
|
+
organizationId: ctx.identifiers.organizationId,
|
|
76
|
+
tenantId: ctx.identifiers.tenantId
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
const DIFFED_FIELDS = [
|
|
80
|
+
"title",
|
|
81
|
+
"periodKind",
|
|
82
|
+
"periodFrom",
|
|
83
|
+
"periodTo",
|
|
84
|
+
"currencyCode",
|
|
85
|
+
"grouping",
|
|
86
|
+
"nonbillableMode",
|
|
87
|
+
"includeAlreadyReported",
|
|
88
|
+
"showRates",
|
|
89
|
+
"status",
|
|
90
|
+
"totalBillableMinutes",
|
|
91
|
+
"totalNonbillableMinutes",
|
|
92
|
+
"totalAmount"
|
|
93
|
+
];
|
|
94
|
+
function toIsoDate(value) {
|
|
95
|
+
if (!value) return null;
|
|
96
|
+
if (value instanceof Date) {
|
|
97
|
+
if (Number.isNaN(value.getTime())) return null;
|
|
98
|
+
const year = value.getFullYear();
|
|
99
|
+
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
100
|
+
const day = String(value.getDate()).padStart(2, "0");
|
|
101
|
+
return `${year}-${month}-${day}`;
|
|
102
|
+
}
|
|
103
|
+
const text = String(value);
|
|
104
|
+
return text.length >= 10 ? text.slice(0, 10) : text;
|
|
105
|
+
}
|
|
106
|
+
function snapshotScopeWhere(scope) {
|
|
107
|
+
const where = {};
|
|
108
|
+
if (scope?.tenantId) where.tenantId = scope.tenantId;
|
|
109
|
+
if (scope?.organizationId) where.organizationId = scope.organizationId;
|
|
110
|
+
return where;
|
|
111
|
+
}
|
|
112
|
+
async function loadReportProjectIds(em, reportId, scope) {
|
|
113
|
+
const rows = await em.find(StaffTimeReportProject, { reportId, ...snapshotScopeWhere(scope) });
|
|
114
|
+
return rows.map((row) => row.timeProjectId);
|
|
115
|
+
}
|
|
116
|
+
function toSnapshot(report, timeProjectIds) {
|
|
117
|
+
return {
|
|
118
|
+
id: report.id,
|
|
119
|
+
tenantId: report.tenantId,
|
|
120
|
+
organizationId: report.organizationId,
|
|
121
|
+
customerId: report.customerId,
|
|
122
|
+
customerSnapshot: report.customerSnapshot ?? null,
|
|
123
|
+
reference: report.reference,
|
|
124
|
+
title: report.title,
|
|
125
|
+
periodKind: report.periodKind,
|
|
126
|
+
periodFrom: toIsoDate(report.periodFrom),
|
|
127
|
+
periodTo: toIsoDate(report.periodTo),
|
|
128
|
+
currencyCode: report.currencyCode,
|
|
129
|
+
grouping: report.grouping,
|
|
130
|
+
nonbillableMode: report.nonbillableMode,
|
|
131
|
+
includeAlreadyReported: report.includeAlreadyReported ?? false,
|
|
132
|
+
showRates: report.showRates ?? true,
|
|
133
|
+
roundingUnitMinutes: report.roundingUnitMinutes ?? 0,
|
|
134
|
+
roundingDirection: report.roundingDirection ?? "up",
|
|
135
|
+
status: report.status,
|
|
136
|
+
totalBillableMinutes: report.totalBillableMinutes ?? null,
|
|
137
|
+
totalNonbillableMinutes: report.totalNonbillableMinutes ?? null,
|
|
138
|
+
totalAmount: report.totalAmount ?? null,
|
|
139
|
+
closedAt: report.closedAt ? report.closedAt.toISOString() : null,
|
|
140
|
+
closedByUserId: report.closedByUserId ?? null,
|
|
141
|
+
timeProjectIds,
|
|
142
|
+
deletedAt: report.deletedAt ? report.deletedAt.toISOString() : null
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function loadReportSnapshot(em, id, scope) {
|
|
146
|
+
const report = await em.findOne(StaffTimeReport, scopedStaffSnapshotWhere(id, scope));
|
|
147
|
+
if (!report) return null;
|
|
148
|
+
const projectIds = await loadReportProjectIds(em, report.id, scope);
|
|
149
|
+
return toSnapshot(report, projectIds);
|
|
150
|
+
}
|
|
151
|
+
function reportNotFoundError(translate) {
|
|
152
|
+
return new CrudHttpError(404, {
|
|
153
|
+
error: translate("staff.time_tracking.reports.errors.notFound", "Report not found or not accessible.")
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function reportClosedError(translate, reference) {
|
|
157
|
+
return new CrudHttpError(409, {
|
|
158
|
+
code: REPORT_CLOSED_CODE,
|
|
159
|
+
error: translate(
|
|
160
|
+
"staff.time_tracking.reports.errors.closed",
|
|
161
|
+
"This report is closed. Unlock it before changing anything."
|
|
162
|
+
),
|
|
163
|
+
reference: reference ?? null
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function projectsRequiredError(translate) {
|
|
167
|
+
const message = translate(
|
|
168
|
+
"staff.time_tracking.reports.errors.projectsRequired",
|
|
169
|
+
"Pick at least one project for this report."
|
|
170
|
+
);
|
|
171
|
+
return new CrudHttpError(422, { error: message, fieldErrors: { timeProjectIds: message } });
|
|
172
|
+
}
|
|
173
|
+
function projectNotFoundError(translate, missingIds) {
|
|
174
|
+
const message = translate(
|
|
175
|
+
"staff.time_tracking.reports.errors.projectNotFound",
|
|
176
|
+
"Some of the selected projects are not available."
|
|
177
|
+
);
|
|
178
|
+
return new CrudHttpError(422, {
|
|
179
|
+
code: REPORT_PROJECT_NOT_FOUND_CODE,
|
|
180
|
+
error: message,
|
|
181
|
+
fieldErrors: { timeProjectIds: message },
|
|
182
|
+
missingProjectIds: missingIds
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function customerMismatchError(translate, offenders) {
|
|
186
|
+
const message = translate(
|
|
187
|
+
"staff.time_tracking.reports.errors.customerMismatch",
|
|
188
|
+
"A report always covers one customer. These projects belong to someone else: {projects}."
|
|
189
|
+
).replace("{projects}", offenders.join(", "));
|
|
190
|
+
return new CrudHttpError(422, {
|
|
191
|
+
code: REPORT_PROJECT_CUSTOMER_MISMATCH_CODE,
|
|
192
|
+
error: message,
|
|
193
|
+
fieldErrors: { timeProjectIds: message },
|
|
194
|
+
offenders
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function currencyConflictError(translate, currencies, offenders) {
|
|
198
|
+
const message = translate(
|
|
199
|
+
"staff.time_tracking.reports.errors.currencyConflict",
|
|
200
|
+
"A report always covers one currency. Selected projects use {currencies}."
|
|
201
|
+
).replace("{currencies}", currencies.join(", "));
|
|
202
|
+
return new CrudHttpError(422, {
|
|
203
|
+
code: REPORT_CURRENCY_CONFLICT_CODE,
|
|
204
|
+
error: message,
|
|
205
|
+
fieldErrors: { timeProjectIds: message },
|
|
206
|
+
currencies,
|
|
207
|
+
offenders: offenders.map((project) => ({
|
|
208
|
+
id: project.id,
|
|
209
|
+
name: project.name,
|
|
210
|
+
currencyCode: project.currencyCode ?? null
|
|
211
|
+
}))
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function referenceConflictError(translate) {
|
|
215
|
+
return new CrudHttpError(409, {
|
|
216
|
+
code: REPORT_REFERENCE_CONFLICT_CODE,
|
|
217
|
+
error: translate(
|
|
218
|
+
"staff.time_tracking.reports.errors.referenceConflict",
|
|
219
|
+
"Could not allocate a report number right now. Try again."
|
|
220
|
+
)
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async function resolveReportProjects(em, timeProjectIds, customerId, scope, translate) {
|
|
224
|
+
const ids = Array.from(new Set(timeProjectIds.filter((id) => typeof id === "string" && id.length > 0)));
|
|
225
|
+
if (ids.length === 0) throw projectsRequiredError(translate);
|
|
226
|
+
const projects = await em.find(
|
|
227
|
+
StaffTimeProject,
|
|
228
|
+
applyScopeToWhere({ id: { $in: ids }, deletedAt: null }, scope)
|
|
229
|
+
);
|
|
230
|
+
if (projects.length !== ids.length) {
|
|
231
|
+
const found = new Set(projects.map((project) => project.id));
|
|
232
|
+
throw projectNotFoundError(
|
|
233
|
+
translate,
|
|
234
|
+
ids.filter((id) => !found.has(id))
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
const mismatched = projects.filter((project) => (project.customerId ?? null) !== customerId);
|
|
238
|
+
if (mismatched.length > 0) {
|
|
239
|
+
throw customerMismatchError(
|
|
240
|
+
translate,
|
|
241
|
+
mismatched.map((project) => project.name)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
const resolution = resolveReportCurrency(
|
|
245
|
+
projects.map((project) => ({
|
|
246
|
+
id: project.id,
|
|
247
|
+
name: project.name,
|
|
248
|
+
currencyCode: project.currencyCode ?? null
|
|
249
|
+
}))
|
|
250
|
+
);
|
|
251
|
+
if (!resolution.ok) {
|
|
252
|
+
throw currencyConflictError(translate, resolution.currencies, resolution.offenders);
|
|
253
|
+
}
|
|
254
|
+
return { projects, currencyCode: resolution.currencyCode ?? "" };
|
|
255
|
+
}
|
|
256
|
+
function deriveCustomerSnapshot(projects) {
|
|
257
|
+
for (const project of projects) {
|
|
258
|
+
const snapshot = project.customerSnapshot;
|
|
259
|
+
if (snapshot && typeof snapshot === "object" && Object.keys(snapshot).length > 0) {
|
|
260
|
+
return snapshot;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
async function readRoundingSnapshot(ctx, tenantId) {
|
|
266
|
+
try {
|
|
267
|
+
const configService = ctx.container.resolve("moduleConfigService");
|
|
268
|
+
const settings = await readTimeTrackingSettings(configService, { tenantId });
|
|
269
|
+
return { unitMinutes: settings.rounding.unitMinutes, direction: settings.rounding.direction };
|
|
270
|
+
} catch (err) {
|
|
271
|
+
logger.warn("staff.timesheets.reports rounding snapshot unavailable", { err });
|
|
272
|
+
return { unitMinutes: 0, direction: "up" };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function replaceReportProjects(em, report, projects) {
|
|
276
|
+
const existing = await em.find(StaffTimeReportProject, { reportId: report.id });
|
|
277
|
+
for (const row of existing) em.remove(row);
|
|
278
|
+
for (const project of projects) {
|
|
279
|
+
em.persist(
|
|
280
|
+
em.create(StaffTimeReportProject, {
|
|
281
|
+
tenantId: report.tenantId,
|
|
282
|
+
organizationId: report.organizationId,
|
|
283
|
+
reportId: report.id,
|
|
284
|
+
timeProjectId: project.id,
|
|
285
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function actorUserId(ctx) {
|
|
291
|
+
return typeof ctx.auth?.sub === "string" ? ctx.auth.sub : null;
|
|
292
|
+
}
|
|
293
|
+
async function readHighestReportSequence(em, year, scope) {
|
|
294
|
+
const rows = await em.find(
|
|
295
|
+
StaffTimeReport,
|
|
296
|
+
applyScopeToWhere({ reference: { $like: `${reportReferencePrefix(year)}%` } }, scope)
|
|
297
|
+
);
|
|
298
|
+
return highestReportSequenceNumber(
|
|
299
|
+
rows.map((row) => row.reference),
|
|
300
|
+
year
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const createReportCommand = {
|
|
304
|
+
id: staffTimeReportCommandIds.create,
|
|
305
|
+
async execute(rawInput, ctx) {
|
|
306
|
+
const parsed = staffTimeReportCreateSchema.parse(rawInput);
|
|
307
|
+
ensureTenantScope(ctx, parsed.tenantId);
|
|
308
|
+
ensureOrganizationScope(ctx, parsed.organizationId);
|
|
309
|
+
const scope = commandInputScope(ctx, parsed.tenantId, parsed.organizationId);
|
|
310
|
+
const { translate } = await resolveTranslations();
|
|
311
|
+
const baseEm = ctx.container.resolve("em");
|
|
312
|
+
const createdByUserId = actorUserId(ctx);
|
|
313
|
+
const rounding = await readRoundingSnapshot(ctx, parsed.tenantId);
|
|
314
|
+
const issuedAt = /* @__PURE__ */ new Date();
|
|
315
|
+
const year = reportReferenceYear(issuedAt);
|
|
316
|
+
let record;
|
|
317
|
+
try {
|
|
318
|
+
record = await withReportReferenceRetry(async () => {
|
|
319
|
+
const em = baseEm.fork();
|
|
320
|
+
let created = null;
|
|
321
|
+
let plan = null;
|
|
322
|
+
await withAtomicFlush(
|
|
323
|
+
em,
|
|
324
|
+
[
|
|
325
|
+
async () => {
|
|
326
|
+
const resolved = await resolveReportProjects(
|
|
327
|
+
em,
|
|
328
|
+
parsed.timeProjectIds,
|
|
329
|
+
parsed.customerId,
|
|
330
|
+
scope,
|
|
331
|
+
translate
|
|
332
|
+
);
|
|
333
|
+
plan = {
|
|
334
|
+
projects: resolved.projects,
|
|
335
|
+
currencyCode: resolved.currencyCode,
|
|
336
|
+
highest: await readHighestReportSequence(em, year, scope)
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
() => {
|
|
340
|
+
if (!plan) throw reportNotFoundError(translate);
|
|
341
|
+
const allocation = allocateReportReference(year, plan.highest);
|
|
342
|
+
const now = /* @__PURE__ */ new Date();
|
|
343
|
+
created = em.create(StaffTimeReport, {
|
|
344
|
+
tenantId: parsed.tenantId,
|
|
345
|
+
organizationId: parsed.organizationId,
|
|
346
|
+
customerId: parsed.customerId,
|
|
347
|
+
customerSnapshot: deriveCustomerSnapshot(plan.projects),
|
|
348
|
+
reference: allocation.reference,
|
|
349
|
+
title: parsed.title,
|
|
350
|
+
periodKind: parsed.periodKind,
|
|
351
|
+
periodFrom: parsed.periodFrom,
|
|
352
|
+
periodTo: parsed.periodTo,
|
|
353
|
+
currencyCode: plan.currencyCode,
|
|
354
|
+
grouping: parsed.grouping,
|
|
355
|
+
nonbillableMode: parsed.nonbillableMode,
|
|
356
|
+
includeAlreadyReported: parsed.includeAlreadyReported,
|
|
357
|
+
showRates: parsed.showRates,
|
|
358
|
+
roundingUnitMinutes: rounding.unitMinutes,
|
|
359
|
+
roundingDirection: rounding.direction,
|
|
360
|
+
status: "draft",
|
|
361
|
+
createdByUserId,
|
|
362
|
+
createdAt: now,
|
|
363
|
+
updatedAt: now,
|
|
364
|
+
deletedAt: null
|
|
365
|
+
});
|
|
366
|
+
em.persist(created);
|
|
367
|
+
},
|
|
368
|
+
async () => {
|
|
369
|
+
if (!created || !plan) return;
|
|
370
|
+
await replaceReportProjects(em, created, plan.projects);
|
|
371
|
+
}
|
|
372
|
+
],
|
|
373
|
+
{ transaction: true, label: staffTimeReportCommandIds.create }
|
|
374
|
+
);
|
|
375
|
+
if (!created) throw reportNotFoundError(translate);
|
|
376
|
+
return created;
|
|
377
|
+
});
|
|
378
|
+
} catch (err) {
|
|
379
|
+
if (isReportReferenceConflict(err)) throw referenceConflictError(translate);
|
|
380
|
+
throw err;
|
|
381
|
+
}
|
|
382
|
+
await emitCrudSideEffects({
|
|
383
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
384
|
+
action: "created",
|
|
385
|
+
entity: record,
|
|
386
|
+
identifiers: { id: record.id, organizationId: record.organizationId, tenantId: record.tenantId },
|
|
387
|
+
events: reportCrudEvents,
|
|
388
|
+
indexer: reportCrudIndexer
|
|
389
|
+
});
|
|
390
|
+
return { reportId: record.id };
|
|
391
|
+
},
|
|
392
|
+
captureAfter: async (_input, result, ctx) => {
|
|
393
|
+
const em = ctx.container.resolve("em").fork();
|
|
394
|
+
const snapshot = await loadReportSnapshot(em, result.reportId, staffSnapshotScopeFromContext(ctx));
|
|
395
|
+
if (!snapshot) return null;
|
|
396
|
+
return { snapshot };
|
|
397
|
+
},
|
|
398
|
+
buildLog: async ({ result, ctx }) => {
|
|
399
|
+
const em = ctx.container.resolve("em").fork();
|
|
400
|
+
const snapshot = await loadReportSnapshot(em, result.reportId, staffSnapshotScopeFromContext(ctx));
|
|
401
|
+
if (!snapshot) return null;
|
|
402
|
+
const { translate } = await resolveTranslations();
|
|
403
|
+
return {
|
|
404
|
+
actionLabel: translate("staff.audit.timesheets.reports.create", "Create report"),
|
|
405
|
+
resourceKind: STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
406
|
+
resourceId: snapshot.id,
|
|
407
|
+
tenantId: snapshot.tenantId,
|
|
408
|
+
organizationId: snapshot.organizationId,
|
|
409
|
+
snapshotAfter: snapshot,
|
|
410
|
+
payload: { undo: { after: snapshot } }
|
|
411
|
+
};
|
|
412
|
+
},
|
|
413
|
+
undo: async ({ logEntry, ctx }) => {
|
|
414
|
+
const payload = extractUndoPayload(logEntry);
|
|
415
|
+
const after = payload?.after;
|
|
416
|
+
if (!after) return;
|
|
417
|
+
const em = ctx.container.resolve("em").fork();
|
|
418
|
+
const report = await em.findOne(
|
|
419
|
+
StaffTimeReport,
|
|
420
|
+
scopedStaffSnapshotWhere(after.id, staffSnapshotScopeFromSnapshot(after))
|
|
421
|
+
);
|
|
422
|
+
if (!report) return;
|
|
423
|
+
if (report.status === "closed") return;
|
|
424
|
+
report.deletedAt = /* @__PURE__ */ new Date();
|
|
425
|
+
report.updatedAt = /* @__PURE__ */ new Date();
|
|
426
|
+
await em.flush();
|
|
427
|
+
await emitCrudUndoSideEffects({
|
|
428
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
429
|
+
action: "deleted",
|
|
430
|
+
entity: report,
|
|
431
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
432
|
+
events: reportCrudEvents,
|
|
433
|
+
indexer: reportCrudIndexer
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const updateReportCommand = {
|
|
438
|
+
id: staffTimeReportCommandIds.update,
|
|
439
|
+
async prepare(rawInput, ctx) {
|
|
440
|
+
const parsed = staffTimeReportUpdateSchema.safeParse(rawInput);
|
|
441
|
+
if (!parsed.success) return {};
|
|
442
|
+
const em = ctx.container.resolve("em").fork();
|
|
443
|
+
const before = await loadReportSnapshot(em, parsed.data.id, staffSnapshotScopeFromContext(ctx));
|
|
444
|
+
if (!before) return {};
|
|
445
|
+
return { before: { snapshot: before } };
|
|
446
|
+
},
|
|
447
|
+
async execute(rawInput, ctx) {
|
|
448
|
+
const parsed = staffTimeReportUpdateSchema.parse(rawInput);
|
|
449
|
+
const { translate } = await resolveTranslations();
|
|
450
|
+
const em = ctx.container.resolve("em").fork();
|
|
451
|
+
const scope = commandActorScope(ctx);
|
|
452
|
+
const report = await em.findOne(
|
|
453
|
+
StaffTimeReport,
|
|
454
|
+
applyScopeToWhere({ id: parsed.id, deletedAt: null }, scope)
|
|
455
|
+
);
|
|
456
|
+
if (!report) throw reportNotFoundError(translate);
|
|
457
|
+
ensureTenantScope(ctx, report.tenantId);
|
|
458
|
+
ensureOrganizationScope(ctx, report.organizationId);
|
|
459
|
+
if (report.status === "closed") throw reportClosedError(translate, report.reference);
|
|
460
|
+
const targetCustomerId = parsed.customerId ?? report.customerId;
|
|
461
|
+
let resolved = null;
|
|
462
|
+
await withAtomicFlush(
|
|
463
|
+
em,
|
|
464
|
+
[
|
|
465
|
+
async () => {
|
|
466
|
+
const needsProjectCheck = parsed.timeProjectIds !== void 0 || parsed.customerId !== void 0 && parsed.customerId !== report.customerId;
|
|
467
|
+
if (!needsProjectCheck) return;
|
|
468
|
+
const ids = parsed.timeProjectIds ?? await loadReportProjectIds(em, report.id, scope);
|
|
469
|
+
resolved = await resolveReportProjects(em, ids, targetCustomerId, scope, translate);
|
|
470
|
+
},
|
|
471
|
+
() => {
|
|
472
|
+
const now = /* @__PURE__ */ new Date();
|
|
473
|
+
if (parsed.title !== void 0) report.title = parsed.title;
|
|
474
|
+
if (parsed.periodKind !== void 0) report.periodKind = parsed.periodKind;
|
|
475
|
+
if (parsed.periodFrom !== void 0) report.periodFrom = parsed.periodFrom;
|
|
476
|
+
if (parsed.periodTo !== void 0) report.periodTo = parsed.periodTo;
|
|
477
|
+
if (parsed.grouping !== void 0) report.grouping = parsed.grouping;
|
|
478
|
+
if (parsed.nonbillableMode !== void 0) report.nonbillableMode = parsed.nonbillableMode;
|
|
479
|
+
if (parsed.includeAlreadyReported !== void 0) {
|
|
480
|
+
report.includeAlreadyReported = parsed.includeAlreadyReported;
|
|
481
|
+
}
|
|
482
|
+
if (parsed.showRates !== void 0) report.showRates = parsed.showRates;
|
|
483
|
+
if (parsed.customerId !== void 0) report.customerId = parsed.customerId;
|
|
484
|
+
if (resolved) {
|
|
485
|
+
report.currencyCode = resolved.currencyCode;
|
|
486
|
+
report.customerSnapshot = deriveCustomerSnapshot(resolved.projects) ?? report.customerSnapshot ?? null;
|
|
487
|
+
}
|
|
488
|
+
report.updatedAt = now;
|
|
489
|
+
},
|
|
490
|
+
async () => {
|
|
491
|
+
if (!resolved || parsed.timeProjectIds === void 0) return;
|
|
492
|
+
await replaceReportProjects(em, report, resolved.projects);
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
{ transaction: true, label: staffTimeReportCommandIds.update }
|
|
496
|
+
);
|
|
497
|
+
await emitCrudSideEffects({
|
|
498
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
499
|
+
action: "updated",
|
|
500
|
+
entity: report,
|
|
501
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
502
|
+
events: reportCrudEvents,
|
|
503
|
+
indexer: reportCrudIndexer
|
|
504
|
+
});
|
|
505
|
+
return { reportId: report.id };
|
|
506
|
+
},
|
|
507
|
+
buildLog: async ({ snapshots, ctx }) => {
|
|
508
|
+
const before = snapshots.before?.snapshot;
|
|
509
|
+
if (!before) return null;
|
|
510
|
+
const em = ctx.container.resolve("em").fork();
|
|
511
|
+
const after = await loadReportSnapshot(em, before.id, staffSnapshotScopeFromSnapshot(before));
|
|
512
|
+
if (!after) return null;
|
|
513
|
+
const { translate } = await resolveTranslations();
|
|
514
|
+
return {
|
|
515
|
+
actionLabel: translate("staff.audit.timesheets.reports.update", "Update report"),
|
|
516
|
+
resourceKind: STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
517
|
+
resourceId: before.id,
|
|
518
|
+
tenantId: before.tenantId,
|
|
519
|
+
organizationId: before.organizationId,
|
|
520
|
+
snapshotBefore: before,
|
|
521
|
+
snapshotAfter: after,
|
|
522
|
+
changes: buildChanges(
|
|
523
|
+
before,
|
|
524
|
+
after,
|
|
525
|
+
[...DIFFED_FIELDS]
|
|
526
|
+
),
|
|
527
|
+
payload: { undo: { before, after } }
|
|
528
|
+
};
|
|
529
|
+
},
|
|
530
|
+
undo: async ({ logEntry, ctx }) => {
|
|
531
|
+
const payload = extractUndoPayload(logEntry);
|
|
532
|
+
const before = payload?.before;
|
|
533
|
+
if (!before) return;
|
|
534
|
+
const em = ctx.container.resolve("em").fork();
|
|
535
|
+
const report = await em.findOne(
|
|
536
|
+
StaffTimeReport,
|
|
537
|
+
scopedStaffSnapshotWhere(before.id, staffSnapshotScopeFromSnapshot(before))
|
|
538
|
+
);
|
|
539
|
+
if (!report) return;
|
|
540
|
+
if (report.status === "closed") return;
|
|
541
|
+
const projects = await em.find(StaffTimeProject, {
|
|
542
|
+
id: { $in: before.timeProjectIds },
|
|
543
|
+
tenantId: before.tenantId,
|
|
544
|
+
organizationId: before.organizationId
|
|
545
|
+
});
|
|
546
|
+
await withAtomicFlush(
|
|
547
|
+
em,
|
|
548
|
+
[
|
|
549
|
+
() => {
|
|
550
|
+
report.customerId = before.customerId;
|
|
551
|
+
report.customerSnapshot = before.customerSnapshot;
|
|
552
|
+
report.title = before.title;
|
|
553
|
+
report.periodKind = before.periodKind;
|
|
554
|
+
if (before.periodFrom) report.periodFrom = new Date(before.periodFrom);
|
|
555
|
+
if (before.periodTo) report.periodTo = new Date(before.periodTo);
|
|
556
|
+
report.currencyCode = before.currencyCode;
|
|
557
|
+
report.grouping = before.grouping;
|
|
558
|
+
report.nonbillableMode = before.nonbillableMode;
|
|
559
|
+
report.includeAlreadyReported = before.includeAlreadyReported;
|
|
560
|
+
report.showRates = before.showRates;
|
|
561
|
+
report.updatedAt = /* @__PURE__ */ new Date();
|
|
562
|
+
},
|
|
563
|
+
async () => {
|
|
564
|
+
if (projects.length !== before.timeProjectIds.length) return;
|
|
565
|
+
await replaceReportProjects(em, report, projects);
|
|
566
|
+
}
|
|
567
|
+
],
|
|
568
|
+
{ transaction: true, label: `${staffTimeReportCommandIds.update}.undo` }
|
|
569
|
+
);
|
|
570
|
+
await emitCrudUndoSideEffects({
|
|
571
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
572
|
+
action: "updated",
|
|
573
|
+
entity: report,
|
|
574
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
575
|
+
events: reportCrudEvents,
|
|
576
|
+
indexer: reportCrudIndexer
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const deleteReportCommand = {
|
|
581
|
+
id: staffTimeReportCommandIds.delete,
|
|
582
|
+
async prepare(input, ctx) {
|
|
583
|
+
const id = input?.id;
|
|
584
|
+
if (!id) return {};
|
|
585
|
+
const em = ctx.container.resolve("em").fork();
|
|
586
|
+
const before = await loadReportSnapshot(em, id, staffSnapshotScopeFromContext(ctx));
|
|
587
|
+
if (!before) return {};
|
|
588
|
+
return { before: { snapshot: before } };
|
|
589
|
+
},
|
|
590
|
+
async execute(input, ctx) {
|
|
591
|
+
const { translate } = await resolveTranslations();
|
|
592
|
+
const id = input?.id;
|
|
593
|
+
if (!id) {
|
|
594
|
+
throw new CrudHttpError(400, {
|
|
595
|
+
error: translate("staff.time_tracking.reports.errors.idRequired", "Report id is required.")
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
const em = ctx.container.resolve("em").fork();
|
|
599
|
+
const scope = commandActorScope(ctx);
|
|
600
|
+
const report = await em.findOne(
|
|
601
|
+
StaffTimeReport,
|
|
602
|
+
applyScopeToWhere({ id, deletedAt: null }, scope)
|
|
603
|
+
);
|
|
604
|
+
if (!report) throw reportNotFoundError(translate);
|
|
605
|
+
ensureTenantScope(ctx, report.tenantId);
|
|
606
|
+
ensureOrganizationScope(ctx, report.organizationId);
|
|
607
|
+
if (report.status === "closed") throw reportClosedError(translate, report.reference);
|
|
608
|
+
const now = /* @__PURE__ */ new Date();
|
|
609
|
+
report.deletedAt = now;
|
|
610
|
+
report.updatedAt = now;
|
|
611
|
+
await em.flush();
|
|
612
|
+
await emitCrudSideEffects({
|
|
613
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
614
|
+
action: "deleted",
|
|
615
|
+
entity: report,
|
|
616
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
617
|
+
events: reportCrudEvents,
|
|
618
|
+
indexer: reportCrudIndexer
|
|
619
|
+
});
|
|
620
|
+
return { reportId: report.id };
|
|
621
|
+
},
|
|
622
|
+
buildLog: async ({ snapshots }) => {
|
|
623
|
+
const before = snapshots.before?.snapshot;
|
|
624
|
+
if (!before) return null;
|
|
625
|
+
const { translate } = await resolveTranslations();
|
|
626
|
+
return {
|
|
627
|
+
actionLabel: translate("staff.audit.timesheets.reports.delete", "Delete report"),
|
|
628
|
+
resourceKind: STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
629
|
+
resourceId: before.id,
|
|
630
|
+
tenantId: before.tenantId,
|
|
631
|
+
organizationId: before.organizationId,
|
|
632
|
+
snapshotBefore: before,
|
|
633
|
+
payload: { undo: { before } }
|
|
634
|
+
};
|
|
635
|
+
},
|
|
636
|
+
undo: async ({ logEntry, ctx }) => {
|
|
637
|
+
const payload = extractUndoPayload(logEntry);
|
|
638
|
+
const before = payload?.before;
|
|
639
|
+
if (!before) return;
|
|
640
|
+
const em = ctx.container.resolve("em").fork();
|
|
641
|
+
const report = await em.findOne(
|
|
642
|
+
StaffTimeReport,
|
|
643
|
+
scopedStaffSnapshotWhere(before.id, staffSnapshotScopeFromSnapshot(before))
|
|
644
|
+
);
|
|
645
|
+
if (!report) return;
|
|
646
|
+
report.deletedAt = null;
|
|
647
|
+
report.updatedAt = /* @__PURE__ */ new Date();
|
|
648
|
+
await em.flush();
|
|
649
|
+
await emitCrudUndoSideEffects({
|
|
650
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
651
|
+
action: "created",
|
|
652
|
+
entity: report,
|
|
653
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
654
|
+
events: reportCrudEvents,
|
|
655
|
+
indexer: reportCrudIndexer
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
registerCommand(createReportCommand);
|
|
660
|
+
registerCommand(updateReportCommand);
|
|
661
|
+
registerCommand(deleteReportCommand);
|
|
662
|
+
function reportNotClosedError(translate) {
|
|
663
|
+
return new CrudHttpError(409, {
|
|
664
|
+
code: REPORT_NOT_CLOSED_CODE,
|
|
665
|
+
error: translate(
|
|
666
|
+
"staff.time_tracking.reports.errors.notClosed",
|
|
667
|
+
"This report is not closed, so there is nothing to unlock."
|
|
668
|
+
)
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
function reportEmptyError(translate) {
|
|
672
|
+
return new CrudHttpError(422, {
|
|
673
|
+
code: REPORT_EMPTY_CODE,
|
|
674
|
+
error: translate(
|
|
675
|
+
"staff.time_tracking.reports.errors.empty",
|
|
676
|
+
"This report covers no time entries, so there is nothing to freeze. Adjust the period or the project selection first."
|
|
677
|
+
)
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
const closeReportCommand = {
|
|
681
|
+
id: staffTimeReportCommandIds.close,
|
|
682
|
+
async prepare(rawInput, ctx) {
|
|
683
|
+
const parsed = staffTimeReportCloseSchema.safeParse(rawInput);
|
|
684
|
+
if (!parsed.success) return {};
|
|
685
|
+
const em = ctx.container.resolve("em").fork();
|
|
686
|
+
const before = await loadReportSnapshot(em, parsed.data.id, staffSnapshotScopeFromContext(ctx));
|
|
687
|
+
if (!before) return {};
|
|
688
|
+
return { before: { snapshot: before } };
|
|
689
|
+
},
|
|
690
|
+
async execute(rawInput, ctx) {
|
|
691
|
+
const parsed = staffTimeReportCloseSchema.parse(rawInput);
|
|
692
|
+
const { translate } = await resolveTranslations();
|
|
693
|
+
const em = ctx.container.resolve("em").fork();
|
|
694
|
+
const scope = commandActorScope(ctx);
|
|
695
|
+
const report = await em.findOne(
|
|
696
|
+
StaffTimeReport,
|
|
697
|
+
applyScopeToWhere({ id: parsed.id, deletedAt: null }, scope)
|
|
698
|
+
);
|
|
699
|
+
if (!report) throw reportNotFoundError(translate);
|
|
700
|
+
ensureTenantScope(ctx, report.tenantId);
|
|
701
|
+
ensureOrganizationScope(ctx, report.organizationId);
|
|
702
|
+
if (report.status === "closed") throw reportClosedError(translate, report.reference);
|
|
703
|
+
const dataScope = { tenantId: report.tenantId, organizationId: report.organizationId };
|
|
704
|
+
const rounding = await readRoundingSnapshot(ctx, report.tenantId);
|
|
705
|
+
const actorId = actorUserId(ctx);
|
|
706
|
+
const labels = reportSheetLabels(translate);
|
|
707
|
+
let lockedEntryCount = 0;
|
|
708
|
+
let totals = null;
|
|
709
|
+
let closePlan = [];
|
|
710
|
+
await withAtomicFlush(
|
|
711
|
+
em,
|
|
712
|
+
[
|
|
713
|
+
async () => {
|
|
714
|
+
const timeProjectIds = await loadReportProjectIds(em, report.id, dataScope);
|
|
715
|
+
const data = await loadReportData({
|
|
716
|
+
em,
|
|
717
|
+
scope: dataScope,
|
|
718
|
+
timeProjectIds,
|
|
719
|
+
periodFrom: report.periodFrom,
|
|
720
|
+
periodTo: report.periodTo
|
|
721
|
+
});
|
|
722
|
+
const options = {
|
|
723
|
+
grouping: report.grouping,
|
|
724
|
+
nonbillableMode: report.nonbillableMode,
|
|
725
|
+
includeAlreadyReported: report.includeAlreadyReported ?? false
|
|
726
|
+
};
|
|
727
|
+
const included = selectIncludedEntries(data.entries, options, report.id);
|
|
728
|
+
if (included.length === 0) throw reportEmptyError(translate);
|
|
729
|
+
totals = computeReportTotals({
|
|
730
|
+
entries: data.entries,
|
|
731
|
+
projects: data.projects,
|
|
732
|
+
directory: data.directory,
|
|
733
|
+
options,
|
|
734
|
+
currentReportId: report.id,
|
|
735
|
+
labels
|
|
736
|
+
});
|
|
737
|
+
const projectById = new Map(data.projects.map((project) => [project.id, project]));
|
|
738
|
+
const entryRows = await em.find(StaffTimeEntry, {
|
|
739
|
+
id: { $in: included.map((entry) => entry.id) },
|
|
740
|
+
tenantId: report.tenantId,
|
|
741
|
+
organizationId: report.organizationId
|
|
742
|
+
});
|
|
743
|
+
const entryById = new Map(entryRows.map((row) => [row.id, row]));
|
|
744
|
+
closePlan = included.map((entry) => ({
|
|
745
|
+
entry,
|
|
746
|
+
row: entryById.get(entry.id) ?? null,
|
|
747
|
+
values: resolveEntryValues(entry, projectById.get(entry.timeProjectId) ?? null),
|
|
748
|
+
currencyCode: projectById.get(entry.timeProjectId)?.currencyCode ?? report.currencyCode ?? ""
|
|
749
|
+
}));
|
|
750
|
+
},
|
|
751
|
+
() => {
|
|
752
|
+
if (!totals) throw reportEmptyError(translate);
|
|
753
|
+
const now = /* @__PURE__ */ new Date();
|
|
754
|
+
for (const item of closePlan) {
|
|
755
|
+
em.persist(
|
|
756
|
+
em.create(StaffTimeReportEntry, {
|
|
757
|
+
tenantId: report.tenantId,
|
|
758
|
+
organizationId: report.organizationId,
|
|
759
|
+
reportId: report.id,
|
|
760
|
+
timeEntryId: item.entry.id,
|
|
761
|
+
frozenRawMinutes: item.values.rawMinutes,
|
|
762
|
+
frozenRoundedMinutes: item.values.minutes,
|
|
763
|
+
frozenRateAmount: item.values.rate === null ? null : String(item.values.rate),
|
|
764
|
+
frozenCurrencyCode: item.currencyCode,
|
|
765
|
+
frozenAmount: item.values.amount === null ? null : item.values.amount.toFixed(2),
|
|
766
|
+
frozenIsBillable: item.values.isBillable,
|
|
767
|
+
createdAt: now
|
|
768
|
+
})
|
|
769
|
+
);
|
|
770
|
+
const row = item.row;
|
|
771
|
+
if (!row) continue;
|
|
772
|
+
if (row.lockedReportId) continue;
|
|
773
|
+
row.lockedReportId = report.id;
|
|
774
|
+
row.lockedAt = now;
|
|
775
|
+
row.updatedAt = now;
|
|
776
|
+
lockedEntryCount += 1;
|
|
777
|
+
}
|
|
778
|
+
report.status = "closed";
|
|
779
|
+
report.closedAt = now;
|
|
780
|
+
report.closedByUserId = actorId;
|
|
781
|
+
report.roundingUnitMinutes = rounding.unitMinutes;
|
|
782
|
+
report.roundingDirection = rounding.direction;
|
|
783
|
+
report.totalBillableMinutes = totals.billableMinutes;
|
|
784
|
+
report.totalNonbillableMinutes = totals.nonbillableMinutes;
|
|
785
|
+
report.totalAmount = totals.totalAmount.toFixed(2);
|
|
786
|
+
report.updatedAt = now;
|
|
787
|
+
em.persist(
|
|
788
|
+
em.create(StaffTimeReportEvent, {
|
|
789
|
+
tenantId: report.tenantId,
|
|
790
|
+
organizationId: report.organizationId,
|
|
791
|
+
reportId: report.id,
|
|
792
|
+
eventType: "closed",
|
|
793
|
+
reason: null,
|
|
794
|
+
actorUserId: actorId,
|
|
795
|
+
metadata: {
|
|
796
|
+
frozenEntryCount: closePlan.length,
|
|
797
|
+
lockedEntryCount,
|
|
798
|
+
totalAmount: totals.totalAmount,
|
|
799
|
+
currencyCode: report.currencyCode,
|
|
800
|
+
roundingUnitMinutes: rounding.unitMinutes,
|
|
801
|
+
roundingDirection: rounding.direction
|
|
802
|
+
},
|
|
803
|
+
createdAt: now
|
|
804
|
+
})
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
],
|
|
808
|
+
{ transaction: true, label: staffTimeReportCommandIds.close }
|
|
809
|
+
);
|
|
810
|
+
const resolved = totals;
|
|
811
|
+
const result = {
|
|
812
|
+
reportId: report.id,
|
|
813
|
+
lockedEntryCount,
|
|
814
|
+
totalAmount: resolved?.totalAmount ?? 0,
|
|
815
|
+
totalBillableMinutes: resolved?.billableMinutes ?? 0,
|
|
816
|
+
totalNonbillableMinutes: resolved?.nonbillableMinutes ?? 0
|
|
817
|
+
};
|
|
818
|
+
await emitCrudSideEffects({
|
|
819
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
820
|
+
action: "updated",
|
|
821
|
+
entity: report,
|
|
822
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
823
|
+
events: reportCrudEvents,
|
|
824
|
+
indexer: reportCrudIndexer
|
|
825
|
+
});
|
|
826
|
+
void emitStaffEvent("staff.timesheets.time_report.closed", {
|
|
827
|
+
id: report.id,
|
|
828
|
+
tenantId: report.tenantId,
|
|
829
|
+
organizationId: report.organizationId,
|
|
830
|
+
reference: report.reference,
|
|
831
|
+
reportId: result.reportId,
|
|
832
|
+
lockedEntryCount: result.lockedEntryCount,
|
|
833
|
+
totalBillableMinutes: result.totalBillableMinutes,
|
|
834
|
+
totalNonbillableMinutes: result.totalNonbillableMinutes
|
|
835
|
+
}).catch((err) => {
|
|
836
|
+
logger.error("staff.timesheets emit time_report.closed failed", { err });
|
|
837
|
+
});
|
|
838
|
+
if (lockedEntryCount > 0) {
|
|
839
|
+
void emitStaffEvent("staff.timesheets.time_entry.locked", {
|
|
840
|
+
tenantId: report.tenantId,
|
|
841
|
+
organizationId: report.organizationId,
|
|
842
|
+
reportId: report.id,
|
|
843
|
+
lockedEntryCount
|
|
844
|
+
}).catch((err) => {
|
|
845
|
+
logger.error("staff.timesheets emit time_entry.locked failed", { err });
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return result;
|
|
849
|
+
},
|
|
850
|
+
buildLog: async ({ snapshots, ctx }) => {
|
|
851
|
+
const before = snapshots.before?.snapshot;
|
|
852
|
+
if (!before) return null;
|
|
853
|
+
const em = ctx.container.resolve("em").fork();
|
|
854
|
+
const after = await loadReportSnapshot(em, before.id, staffSnapshotScopeFromSnapshot(before));
|
|
855
|
+
if (!after) return null;
|
|
856
|
+
const { translate } = await resolveTranslations();
|
|
857
|
+
return {
|
|
858
|
+
actionLabel: translate("staff.audit.timesheets.reports.close", "Close and lock report"),
|
|
859
|
+
resourceKind: STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
860
|
+
resourceId: before.id,
|
|
861
|
+
tenantId: before.tenantId,
|
|
862
|
+
organizationId: before.organizationId,
|
|
863
|
+
snapshotBefore: before,
|
|
864
|
+
snapshotAfter: after,
|
|
865
|
+
changes: buildChanges(
|
|
866
|
+
before,
|
|
867
|
+
after,
|
|
868
|
+
[...DIFFED_FIELDS]
|
|
869
|
+
)
|
|
870
|
+
// Deliberately no `undo` payload: unwinding a close is the unlock command,
|
|
871
|
+
// which requires a reason and its own feature. A silent undo of a billing
|
|
872
|
+
// freeze is exactly what US-G3 forbids.
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
const unlockReportCommand = {
|
|
877
|
+
id: staffTimeReportCommandIds.unlock,
|
|
878
|
+
async prepare(rawInput, ctx) {
|
|
879
|
+
const parsed = staffTimeReportUnlockSchema.safeParse(rawInput);
|
|
880
|
+
if (!parsed.success) return {};
|
|
881
|
+
const em = ctx.container.resolve("em").fork();
|
|
882
|
+
const before = await loadReportSnapshot(em, parsed.data.id, staffSnapshotScopeFromContext(ctx));
|
|
883
|
+
if (!before) return {};
|
|
884
|
+
return { before: { snapshot: before } };
|
|
885
|
+
},
|
|
886
|
+
async execute(rawInput, ctx) {
|
|
887
|
+
const parsed = staffTimeReportUnlockSchema.parse(rawInput);
|
|
888
|
+
const { translate } = await resolveTranslations();
|
|
889
|
+
const em = ctx.container.resolve("em").fork();
|
|
890
|
+
const scope = commandActorScope(ctx);
|
|
891
|
+
const report = await em.findOne(
|
|
892
|
+
StaffTimeReport,
|
|
893
|
+
applyScopeToWhere({ id: parsed.id, deletedAt: null }, scope)
|
|
894
|
+
);
|
|
895
|
+
if (!report) throw reportNotFoundError(translate);
|
|
896
|
+
ensureTenantScope(ctx, report.tenantId);
|
|
897
|
+
ensureOrganizationScope(ctx, report.organizationId);
|
|
898
|
+
if (report.status !== "closed") throw reportNotClosedError(translate);
|
|
899
|
+
const actorId = actorUserId(ctx);
|
|
900
|
+
let unlockedEntryCount = 0;
|
|
901
|
+
let frozenEntries = [];
|
|
902
|
+
let lockedRows = [];
|
|
903
|
+
const frozenTotals = {
|
|
904
|
+
totalAmount: report.totalAmount,
|
|
905
|
+
totalBillableMinutes: report.totalBillableMinutes ?? null,
|
|
906
|
+
totalNonbillableMinutes: report.totalNonbillableMinutes ?? null
|
|
907
|
+
};
|
|
908
|
+
await withAtomicFlush(
|
|
909
|
+
em,
|
|
910
|
+
[
|
|
911
|
+
async () => {
|
|
912
|
+
frozenEntries = await em.find(StaffTimeReportEntry, {
|
|
913
|
+
reportId: report.id,
|
|
914
|
+
tenantId: report.tenantId,
|
|
915
|
+
organizationId: report.organizationId
|
|
916
|
+
});
|
|
917
|
+
lockedRows = await em.find(StaffTimeEntry, {
|
|
918
|
+
lockedReportId: report.id,
|
|
919
|
+
tenantId: report.tenantId,
|
|
920
|
+
organizationId: report.organizationId
|
|
921
|
+
});
|
|
922
|
+
},
|
|
923
|
+
() => {
|
|
924
|
+
const now = /* @__PURE__ */ new Date();
|
|
925
|
+
for (const row of lockedRows) {
|
|
926
|
+
row.lockedReportId = null;
|
|
927
|
+
row.lockedAt = null;
|
|
928
|
+
row.updatedAt = now;
|
|
929
|
+
unlockedEntryCount += 1;
|
|
930
|
+
}
|
|
931
|
+
for (const frozen of frozenEntries) em.remove(frozen);
|
|
932
|
+
report.status = "draft";
|
|
933
|
+
report.closedAt = null;
|
|
934
|
+
report.closedByUserId = null;
|
|
935
|
+
report.totalAmount = null;
|
|
936
|
+
report.totalBillableMinutes = null;
|
|
937
|
+
report.totalNonbillableMinutes = null;
|
|
938
|
+
report.updatedAt = now;
|
|
939
|
+
em.persist(
|
|
940
|
+
em.create(StaffTimeReportEvent, {
|
|
941
|
+
tenantId: report.tenantId,
|
|
942
|
+
organizationId: report.organizationId,
|
|
943
|
+
reportId: report.id,
|
|
944
|
+
eventType: "unlocked",
|
|
945
|
+
reason: parsed.reason,
|
|
946
|
+
actorUserId: actorId,
|
|
947
|
+
metadata: {
|
|
948
|
+
unlockedEntryCount,
|
|
949
|
+
frozenEntryCount: frozenEntries.length,
|
|
950
|
+
frozenTotalAmount: frozenTotals.totalAmount,
|
|
951
|
+
frozenBillableMinutes: frozenTotals.totalBillableMinutes,
|
|
952
|
+
frozenNonbillableMinutes: frozenTotals.totalNonbillableMinutes,
|
|
953
|
+
currencyCode: report.currencyCode
|
|
954
|
+
},
|
|
955
|
+
createdAt: now
|
|
956
|
+
})
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
],
|
|
960
|
+
{ transaction: true, label: staffTimeReportCommandIds.unlock }
|
|
961
|
+
);
|
|
962
|
+
await emitCrudSideEffects({
|
|
963
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
964
|
+
action: "updated",
|
|
965
|
+
entity: report,
|
|
966
|
+
identifiers: { id: report.id, organizationId: report.organizationId, tenantId: report.tenantId },
|
|
967
|
+
events: reportCrudEvents,
|
|
968
|
+
indexer: reportCrudIndexer
|
|
969
|
+
});
|
|
970
|
+
void emitStaffEvent("staff.timesheets.time_report.unlocked", {
|
|
971
|
+
id: report.id,
|
|
972
|
+
tenantId: report.tenantId,
|
|
973
|
+
organizationId: report.organizationId,
|
|
974
|
+
reference: report.reference,
|
|
975
|
+
actorUserId: actorId,
|
|
976
|
+
unlockedEntryCount
|
|
977
|
+
}).catch((err) => {
|
|
978
|
+
logger.error("staff.timesheets emit time_report.unlocked failed", { err });
|
|
979
|
+
});
|
|
980
|
+
if (unlockedEntryCount > 0) {
|
|
981
|
+
void emitStaffEvent("staff.timesheets.time_entry.unlocked", {
|
|
982
|
+
tenantId: report.tenantId,
|
|
983
|
+
organizationId: report.organizationId,
|
|
984
|
+
reportId: report.id,
|
|
985
|
+
unlockedEntryCount
|
|
986
|
+
}).catch((err) => {
|
|
987
|
+
logger.error("staff.timesheets emit time_entry.unlocked failed", { err });
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
return { reportId: report.id, unlockedEntryCount };
|
|
991
|
+
},
|
|
992
|
+
buildLog: async ({ snapshots, ctx, input }) => {
|
|
993
|
+
const before = snapshots.before?.snapshot;
|
|
994
|
+
if (!before) return null;
|
|
995
|
+
const em = ctx.container.resolve("em").fork();
|
|
996
|
+
const after = await loadReportSnapshot(em, before.id, staffSnapshotScopeFromSnapshot(before));
|
|
997
|
+
if (!after) return null;
|
|
998
|
+
const { translate } = await resolveTranslations();
|
|
999
|
+
return {
|
|
1000
|
+
actionLabel: translate("staff.audit.timesheets.reports.unlock", "Unlock report entries"),
|
|
1001
|
+
resourceKind: STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
1002
|
+
resourceId: before.id,
|
|
1003
|
+
tenantId: before.tenantId,
|
|
1004
|
+
organizationId: before.organizationId,
|
|
1005
|
+
snapshotBefore: before,
|
|
1006
|
+
snapshotAfter: after,
|
|
1007
|
+
changes: buildChanges(
|
|
1008
|
+
before,
|
|
1009
|
+
after,
|
|
1010
|
+
[...DIFFED_FIELDS]
|
|
1011
|
+
),
|
|
1012
|
+
payload: { reason: input?.reason ?? null }
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
registerCommand(closeReportCommand);
|
|
1017
|
+
registerCommand(unlockReportCommand);
|
|
1018
|
+
export {
|
|
1019
|
+
REPORT_CLOSED_CODE,
|
|
1020
|
+
REPORT_CURRENCY_CONFLICT_CODE,
|
|
1021
|
+
REPORT_EMPTY_CODE,
|
|
1022
|
+
REPORT_NOT_CLOSED_CODE,
|
|
1023
|
+
REPORT_PROJECT_CUSTOMER_MISMATCH_CODE,
|
|
1024
|
+
REPORT_PROJECT_NOT_FOUND_CODE,
|
|
1025
|
+
REPORT_REFERENCE_CONFLICT_CODE,
|
|
1026
|
+
STAFF_TIME_REPORT_RESOURCE_KIND,
|
|
1027
|
+
currencyConflictError,
|
|
1028
|
+
deriveCustomerSnapshot,
|
|
1029
|
+
loadReportProjectIds,
|
|
1030
|
+
loadReportSnapshot,
|
|
1031
|
+
reportClosedError,
|
|
1032
|
+
reportNotFoundError,
|
|
1033
|
+
resolveReportProjects,
|
|
1034
|
+
staffTimeReportCommandIds
|
|
1035
|
+
};
|
|
1036
|
+
//# sourceMappingURL=timesheets-reports.js.map
|