@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
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import type { AwilixContainer } from 'awilix'
|
|
2
2
|
import {
|
|
3
3
|
canonicalizeResourceTag,
|
|
4
|
-
deriveResourceFromCommandId,
|
|
5
4
|
invalidateCrudCache,
|
|
6
5
|
type CrudCacheIdentifiers,
|
|
7
6
|
} from '@open-mercato/shared/lib/crud/cache'
|
|
8
7
|
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
9
|
-
import {
|
|
8
|
+
import { staffTimeEntryCrudEvents } from '../crud'
|
|
10
9
|
|
|
11
10
|
const logger = createLogger('staff').child({ component: 'timesheets-cache' })
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* The resource tag the CRUD list cache stores time-entry payloads under.
|
|
15
14
|
*
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* it here
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
15
|
+
* `resolveResourceAliasesList` in the CRUD factory prefers the route's `events`
|
|
16
|
+
* config over the create command id, so the tag follows `staff.timesheets.time_entry`
|
|
17
|
+
* canonicalized (underscores become dots) rather than the command-derived
|
|
18
|
+
* `staff.timesheet`. Deriving it here from the very object the route passes as its
|
|
19
|
+
* `events` config keeps the flush tag equal to the store tag; a hand-typed literal is
|
|
20
|
+
* how a custom write route silently flushes nothing (#3143, #3711). The literal
|
|
21
|
+
* fallback only guards against a null derivation at runtime — the unit test pins the
|
|
22
|
+
* derived value so drift fails in CI instead of in production.
|
|
23
23
|
*/
|
|
24
24
|
export const staffTimeEntryCacheResource =
|
|
25
|
-
canonicalizeResourceTag(
|
|
25
|
+
canonicalizeResourceTag(`${staffTimeEntryCrudEvents.module}.${staffTimeEntryCrudEvents.entity}`)
|
|
26
|
+
?? 'staff.timesheets.time.entry'
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Flush the cached time-entry collections and record entries after a committed write.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The consulting-suite response fields on a time-entry row.
|
|
3
|
+
*
|
|
4
|
+
* This used to be a route-private `hooks.afterList` on
|
|
5
|
+
* `/api/staff/timesheets/time-entries`, which made it invisible to the extension
|
|
6
|
+
* system: a third-party enricher for `staff:staff_time_entry` could not see what
|
|
7
|
+
* the hook had already added, and could not compose with it. The logic lives here so
|
|
8
|
+
* the declared enricher in `data/enrichers.ts` owns it and the route keeps only its
|
|
9
|
+
* deprecated wrapper.
|
|
10
|
+
*
|
|
11
|
+
* Money is ADDED for a caller holding `staff.timesheets.rates.view` and is absent
|
|
12
|
+
* for everyone else — `cost`, `currencyCode` and the stored rate override are absent
|
|
13
|
+
* from the payload rather than blanked, which is the module-wide rule
|
|
14
|
+
* (`staff/AGENTS.md` → ACL feature IDs).
|
|
15
|
+
*
|
|
16
|
+
* **The addition is the whole gate, and that is deliberate.** The list route's
|
|
17
|
+
* projection does not select `rate_override_amount` or `rate_currency_code` at all,
|
|
18
|
+
* so an unentitled caller's response carries no money for the same reason a
|
|
19
|
+
* `SELECT` that never named the column carries none. Stripping money after the fact
|
|
20
|
+
* only holds while the stripper runs, and this decoration runs as a NON-critical
|
|
21
|
+
* response enricher: `enricher-runner.ts` leaves the items untouched when one times
|
|
22
|
+
* out or throws, so a subtractive gate here would fail OPEN under load. Reading the
|
|
23
|
+
* two columns here, only for an entitled caller, is fail-closed by construction.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
27
|
+
import { StaffTimeEntry, StaffTimeEntryTag, StaffTimeProject, StaffTimeTag } from '../../data/entities'
|
|
28
|
+
import { entryAmount } from '../time-tracking/cost'
|
|
29
|
+
|
|
30
|
+
export type TimeEntryTagSummary = {
|
|
31
|
+
id: string
|
|
32
|
+
slug: string
|
|
33
|
+
label: string
|
|
34
|
+
color: string | null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type TimeEntryDecorationScope = {
|
|
38
|
+
em: EntityManager
|
|
39
|
+
tenantId: string | null
|
|
40
|
+
organizationId: string | null
|
|
41
|
+
canSeeRates: boolean
|
|
42
|
+
/** Called with a decoration failure; the rows themselves are already correct and scoped. */
|
|
43
|
+
onError?: (err: unknown) => void
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type EntryRow = Record<string, unknown>
|
|
47
|
+
|
|
48
|
+
const FIELD = {
|
|
49
|
+
id: ['id', 'id'],
|
|
50
|
+
roundedMinutes: ['rounded_minutes', 'roundedMinutes'],
|
|
51
|
+
notes: ['notes', 'notes'],
|
|
52
|
+
timeProjectId: ['time_project_id', 'timeProjectId'],
|
|
53
|
+
isBillable: ['is_billable', 'isBillable'],
|
|
54
|
+
rateOverrideAmount: ['rate_override_amount', 'rateOverrideAmount'],
|
|
55
|
+
rateCurrencyCode: ['rate_currency_code', 'rateCurrencyCode'],
|
|
56
|
+
lockedReportId: ['locked_report_id', 'lockedReportId'],
|
|
57
|
+
} as const
|
|
58
|
+
|
|
59
|
+
function readValue(row: EntryRow, field: readonly [string, string]): unknown {
|
|
60
|
+
const snake = row[field[0]]
|
|
61
|
+
if (snake !== undefined) return snake
|
|
62
|
+
return row[field[1]]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function toNullableString(value: unknown): string | null {
|
|
66
|
+
return typeof value === 'string' && value.length > 0 ? value : null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function toNullableNumber(value: unknown): number | null {
|
|
70
|
+
if (value === null || value === undefined) return null
|
|
71
|
+
const parsed = typeof value === 'number' ? value : Number(value)
|
|
72
|
+
return Number.isFinite(parsed) ? parsed : null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function toBoolean(value: unknown, fallback: boolean): boolean {
|
|
76
|
+
if (typeof value === 'boolean') return value
|
|
77
|
+
if (value === 'true' || value === 1) return true
|
|
78
|
+
if (value === 'false' || value === 0) return false
|
|
79
|
+
return fallback
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function loadEntryTags(
|
|
83
|
+
em: EntityManager,
|
|
84
|
+
entryIds: string[],
|
|
85
|
+
tenantId: string,
|
|
86
|
+
organizationId: string,
|
|
87
|
+
): Promise<Map<string, TimeEntryTagSummary[]>> {
|
|
88
|
+
const byEntryId = new Map<string, TimeEntryTagSummary[]>()
|
|
89
|
+
if (entryIds.length === 0) return byEntryId
|
|
90
|
+
const assignments = await em.find(StaffTimeEntryTag, {
|
|
91
|
+
timeEntryId: { $in: entryIds },
|
|
92
|
+
tenantId,
|
|
93
|
+
organizationId,
|
|
94
|
+
})
|
|
95
|
+
if (assignments.length === 0) return byEntryId
|
|
96
|
+
const tags = await em.find(StaffTimeTag, {
|
|
97
|
+
id: { $in: Array.from(new Set(assignments.map((row) => row.tagId))) },
|
|
98
|
+
tenantId,
|
|
99
|
+
organizationId,
|
|
100
|
+
deletedAt: null,
|
|
101
|
+
})
|
|
102
|
+
const tagById = new Map(tags.map((tag) => [tag.id, tag]))
|
|
103
|
+
for (const assignment of assignments) {
|
|
104
|
+
const tag = tagById.get(assignment.tagId)
|
|
105
|
+
if (!tag) continue
|
|
106
|
+
const list = byEntryId.get(assignment.timeEntryId) ?? []
|
|
107
|
+
list.push({ id: tag.id, slug: tag.slug, label: tag.label, color: tag.color ?? null })
|
|
108
|
+
byEntryId.set(assignment.timeEntryId, list)
|
|
109
|
+
}
|
|
110
|
+
return byEntryId
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The two money columns the list projection deliberately does not select, read back
|
|
115
|
+
* only for a caller entitled to them. The rate override keeps the `numeric` string
|
|
116
|
+
* MikroORM hands back, so the wire format of `rate_override_amount` is the one the
|
|
117
|
+
* published response schema always documented.
|
|
118
|
+
*/
|
|
119
|
+
type EntryMoney = { rateOverrideAmount: string | number | null; rateCurrencyCode: string | null }
|
|
120
|
+
|
|
121
|
+
async function loadEntryMoney(
|
|
122
|
+
em: EntityManager,
|
|
123
|
+
entryIds: string[],
|
|
124
|
+
tenantId: string,
|
|
125
|
+
organizationId: string,
|
|
126
|
+
): Promise<Map<string, EntryMoney>> {
|
|
127
|
+
const byId = new Map<string, EntryMoney>()
|
|
128
|
+
if (entryIds.length === 0) return byId
|
|
129
|
+
const entries = await em.find(StaffTimeEntry, {
|
|
130
|
+
id: { $in: entryIds },
|
|
131
|
+
tenantId,
|
|
132
|
+
organizationId,
|
|
133
|
+
})
|
|
134
|
+
for (const entry of entries) {
|
|
135
|
+
byId.set(entry.id, {
|
|
136
|
+
rateOverrideAmount: entry.rateOverrideAmount ?? null,
|
|
137
|
+
rateCurrencyCode: entry.rateCurrencyCode ?? null,
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
return byId
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type ProjectMoney = { hourlyRate: number | null; currencyCode: string | null }
|
|
144
|
+
|
|
145
|
+
async function loadProjectMoney(
|
|
146
|
+
em: EntityManager,
|
|
147
|
+
projectIds: string[],
|
|
148
|
+
tenantId: string,
|
|
149
|
+
organizationId: string,
|
|
150
|
+
): Promise<Map<string, ProjectMoney>> {
|
|
151
|
+
const byId = new Map<string, ProjectMoney>()
|
|
152
|
+
if (projectIds.length === 0) return byId
|
|
153
|
+
const projects = await em.find(StaffTimeProject, {
|
|
154
|
+
id: { $in: projectIds },
|
|
155
|
+
tenantId,
|
|
156
|
+
organizationId,
|
|
157
|
+
deletedAt: null,
|
|
158
|
+
})
|
|
159
|
+
for (const project of projects) {
|
|
160
|
+
byId.set(project.id, {
|
|
161
|
+
hourlyRate: toNullableNumber(project.hourlyRate),
|
|
162
|
+
currencyCode: toNullableString(project.currencyCode),
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
return byId
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Decorates the given rows IN PLACE. Callers that must not touch their input pass
|
|
170
|
+
* shallow copies — which is what the enricher does, so its contract stays additive.
|
|
171
|
+
*/
|
|
172
|
+
export async function decorateTimeEntryRows(
|
|
173
|
+
rows: EntryRow[],
|
|
174
|
+
scope: TimeEntryDecorationScope,
|
|
175
|
+
): Promise<void> {
|
|
176
|
+
if (rows.length === 0) return
|
|
177
|
+
|
|
178
|
+
const { tenantId, organizationId, canSeeRates } = scope
|
|
179
|
+
let tagsByEntryId = new Map<string, TimeEntryTagSummary[]>()
|
|
180
|
+
let moneyByEntryId = new Map<string, EntryMoney>()
|
|
181
|
+
let moneyByProjectId = new Map<string, ProjectMoney>()
|
|
182
|
+
|
|
183
|
+
if (tenantId && organizationId) {
|
|
184
|
+
try {
|
|
185
|
+
const em = scope.em.fork()
|
|
186
|
+
const entryIds = rows
|
|
187
|
+
.map((row) => readValue(row, FIELD.id))
|
|
188
|
+
.filter((value): value is string => typeof value === 'string')
|
|
189
|
+
tagsByEntryId = await loadEntryTags(em, entryIds, tenantId, organizationId)
|
|
190
|
+
if (canSeeRates) {
|
|
191
|
+
moneyByEntryId = await loadEntryMoney(em, entryIds, tenantId, organizationId)
|
|
192
|
+
const projectIds = Array.from(
|
|
193
|
+
new Set(
|
|
194
|
+
rows
|
|
195
|
+
.map((row) => readValue(row, FIELD.timeProjectId))
|
|
196
|
+
.filter((value): value is string => typeof value === 'string'),
|
|
197
|
+
),
|
|
198
|
+
)
|
|
199
|
+
moneyByProjectId = await loadProjectMoney(em, projectIds, tenantId, organizationId)
|
|
200
|
+
}
|
|
201
|
+
} catch (err) {
|
|
202
|
+
// A decoration failure must not fail the list; the entry rows themselves are
|
|
203
|
+
// already correct and scoped.
|
|
204
|
+
scope.onError?.(err)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
for (const row of rows) {
|
|
209
|
+
const entryId = readValue(row, FIELD.id)
|
|
210
|
+
const lockedReportId = toNullableString(readValue(row, FIELD.lockedReportId))
|
|
211
|
+
const roundedMinutes = toNullableNumber(readValue(row, FIELD.roundedMinutes))
|
|
212
|
+
const isBillable = toBoolean(readValue(row, FIELD.isBillable), true)
|
|
213
|
+
|
|
214
|
+
// The published alias: same value, second name, both keys returned.
|
|
215
|
+
row.description = toNullableString(readValue(row, FIELD.notes))
|
|
216
|
+
row.roundedMinutes = roundedMinutes
|
|
217
|
+
row.isLocked = lockedReportId !== null
|
|
218
|
+
row.lockedReportId = lockedReportId
|
|
219
|
+
row.tags = typeof entryId === 'string' ? tagsByEntryId.get(entryId) ?? [] : []
|
|
220
|
+
|
|
221
|
+
if (!canSeeRates) {
|
|
222
|
+
// Belt and braces: the projection selects neither column, so there is
|
|
223
|
+
// normally nothing here to remove. A caller that assembled the row itself
|
|
224
|
+
// still loses the money keys rather than passing them through.
|
|
225
|
+
delete row[FIELD.rateOverrideAmount[0]]
|
|
226
|
+
delete row[FIELD.rateOverrideAmount[1]]
|
|
227
|
+
delete row[FIELD.rateCurrencyCode[0]]
|
|
228
|
+
delete row[FIELD.rateCurrencyCode[1]]
|
|
229
|
+
continue
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const projectId = readValue(row, FIELD.timeProjectId)
|
|
233
|
+
const money = typeof projectId === 'string' ? moneyByProjectId.get(projectId) : undefined
|
|
234
|
+
const stored = typeof entryId === 'string' ? moneyByEntryId.get(entryId) : undefined
|
|
235
|
+
const rateOverrideAmount = stored
|
|
236
|
+
? stored.rateOverrideAmount
|
|
237
|
+
: (readValue(row, FIELD.rateOverrideAmount) as string | number | null | undefined) ?? null
|
|
238
|
+
const rateCurrencyCode = stored
|
|
239
|
+
? stored.rateCurrencyCode
|
|
240
|
+
: toNullableString(readValue(row, FIELD.rateCurrencyCode))
|
|
241
|
+
|
|
242
|
+
row[FIELD.rateOverrideAmount[0]] = rateOverrideAmount
|
|
243
|
+
row[FIELD.rateCurrencyCode[0]] = rateCurrencyCode
|
|
244
|
+
row.currencyCode = toNullableString(rateCurrencyCode) ?? money?.currencyCode ?? null
|
|
245
|
+
// A non-billable entry has no price at all — `null`, never `0`, which would
|
|
246
|
+
// read as free work rather than work that is out of scope.
|
|
247
|
+
row.cost = entryAmount(
|
|
248
|
+
{
|
|
249
|
+
isBillable,
|
|
250
|
+
roundedMinutes: roundedMinutes ?? 0,
|
|
251
|
+
rateOverrideAmount: toNullableNumber(rateOverrideAmount),
|
|
252
|
+
},
|
|
253
|
+
{ hourlyRate: money?.hourlyRate ?? null },
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type ProjectBudgetKind = 'none' | 'hours' | 'amount'
|
|
2
|
+
|
|
3
|
+
export type BudgetBurnTone = 'accent' | 'warning' | 'destructive'
|
|
4
|
+
|
|
5
|
+
export type ProjectBudgetBurn = {
|
|
6
|
+
kind: 'hours' | 'amount'
|
|
7
|
+
budgetValue: number
|
|
8
|
+
usedValue: number
|
|
9
|
+
percent: number
|
|
10
|
+
barPercent: number
|
|
11
|
+
tone: BudgetBurnTone
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type BudgetBurnInput = {
|
|
15
|
+
kind: ProjectBudgetKind | null | undefined
|
|
16
|
+
budgetValue: number | null | undefined
|
|
17
|
+
warnAtPercent: number | null | undefined
|
|
18
|
+
totalMinutes: number
|
|
19
|
+
cost: number | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_BUDGET_WARN_AT_PERCENT = 80
|
|
23
|
+
|
|
24
|
+
function clampPercent(value: number): number {
|
|
25
|
+
if (!Number.isFinite(value) || value < 0) return 0
|
|
26
|
+
return Math.min(100, value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function resolveBudgetWarnAtPercent(warnAtPercent: number | null | undefined): number {
|
|
30
|
+
if (typeof warnAtPercent !== 'number' || !Number.isFinite(warnAtPercent)) {
|
|
31
|
+
return DEFAULT_BUDGET_WARN_AT_PERCENT
|
|
32
|
+
}
|
|
33
|
+
if (warnAtPercent <= 0 || warnAtPercent > 100) return DEFAULT_BUDGET_WARN_AT_PERCENT
|
|
34
|
+
return warnAtPercent
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function computeBudgetBurn(input: BudgetBurnInput): ProjectBudgetBurn | null {
|
|
38
|
+
const kind = input.kind
|
|
39
|
+
if (kind !== 'hours' && kind !== 'amount') return null
|
|
40
|
+
const budgetValue = typeof input.budgetValue === 'number' ? input.budgetValue : null
|
|
41
|
+
if (budgetValue === null || !Number.isFinite(budgetValue) || budgetValue <= 0) return null
|
|
42
|
+
|
|
43
|
+
const usedValue =
|
|
44
|
+
kind === 'hours'
|
|
45
|
+
? Math.max(0, input.totalMinutes) / 60
|
|
46
|
+
: Math.max(0, input.cost ?? 0)
|
|
47
|
+
|
|
48
|
+
const percent = Math.round((usedValue / budgetValue) * 100)
|
|
49
|
+
const warnAt = resolveBudgetWarnAtPercent(input.warnAtPercent)
|
|
50
|
+
const tone: BudgetBurnTone = percent >= 100 ? 'destructive' : percent >= warnAt ? 'warning' : 'accent'
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
kind,
|
|
54
|
+
budgetValue,
|
|
55
|
+
usedValue,
|
|
56
|
+
percent,
|
|
57
|
+
barPercent: clampPercent(percent),
|
|
58
|
+
tone,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeBudgetBurn,
|
|
3
|
+
resolveBudgetWarnAtPercent,
|
|
4
|
+
type ProjectBudgetKind,
|
|
5
|
+
} from './budgetBurn'
|
|
6
|
+
|
|
7
|
+
export const FULL_BUDGET_PERCENT = 100
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Outcome of comparing a project's usage against its budget.
|
|
11
|
+
*
|
|
12
|
+
* - `disabled` — the project has no measurable budget at all (`budget_kind: 'none'`,
|
|
13
|
+
* a null budget, or a budget of zero or less). Never notifies, and clears any
|
|
14
|
+
* marker left behind by a budget that has since been switched off.
|
|
15
|
+
* - `unmeasurable` — the budget is an amount budget but the project cannot price its
|
|
16
|
+
* hours (no rate anywhere, or no currency). Degrades quietly: no notification and
|
|
17
|
+
* the marker is left untouched, because this is an inability to measure rather
|
|
18
|
+
* than usage genuinely dropping.
|
|
19
|
+
* - `evaluated` — usage was compared against the thresholds.
|
|
20
|
+
*/
|
|
21
|
+
export type BudgetThresholdStatus = 'disabled' | 'unmeasurable' | 'evaluated'
|
|
22
|
+
|
|
23
|
+
export type BudgetThresholdInput = {
|
|
24
|
+
budgetKind: ProjectBudgetKind | null | undefined
|
|
25
|
+
budgetValue: number | null | undefined
|
|
26
|
+
budgetWarnAtPercent: number | null | undefined
|
|
27
|
+
budgetAlertedAtPercent: number | null | undefined
|
|
28
|
+
totalMinutes: number
|
|
29
|
+
cost: number | null
|
|
30
|
+
currencyCode?: string | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type BudgetThresholdEvaluation = {
|
|
34
|
+
status: BudgetThresholdStatus
|
|
35
|
+
kind: 'hours' | 'amount' | null
|
|
36
|
+
budgetValue: number | null
|
|
37
|
+
usedValue: number | null
|
|
38
|
+
percent: number | null
|
|
39
|
+
/** The threshold to announce now, or null when nothing new was crossed. */
|
|
40
|
+
crossedThresholdPercent: number | null
|
|
41
|
+
/** The value `budget_alerted_at_percent` should hold after this write. */
|
|
42
|
+
nextAlertedAtPercent: number | null
|
|
43
|
+
shouldPersistAlertedAt: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalizeAlertedAtPercent(value: number | null | undefined): number | null {
|
|
47
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return null
|
|
48
|
+
const rounded = Math.round(value)
|
|
49
|
+
if (rounded <= 0) return null
|
|
50
|
+
return Math.min(rounded, FULL_BUDGET_PERCENT)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function hasBillingCurrency(currencyCode: string | null | undefined): boolean {
|
|
54
|
+
return typeof currencyCode === 'string' && currencyCode.trim().length > 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Decides whether a budget threshold notification is due for a project.
|
|
59
|
+
*
|
|
60
|
+
* Two thresholds exist: the project's `budget_warn_at_percent` (80 by default) and
|
|
61
|
+
* 100. A notification fires only on an UPWARD move into a threshold band that
|
|
62
|
+
* `budget_alerted_at_percent` has not already recorded, so repeated writes at the
|
|
63
|
+
* same usage level stay silent. When one write jumps past both thresholds, only the
|
|
64
|
+
* highest one is announced — a single "budget exhausted" alert beats two alerts
|
|
65
|
+
* describing the same write.
|
|
66
|
+
*
|
|
67
|
+
* The marker follows usage back down: when usage falls under the band it was raised
|
|
68
|
+
* for (an entry deleted or corrected), the marker is lowered to the band usage is
|
|
69
|
+
* actually in — null when it is under every threshold — so a later re-crossing
|
|
70
|
+
* notifies again. Moving down never notifies.
|
|
71
|
+
*
|
|
72
|
+
* Percent is taken from `computeBudgetBurn` so the notification and the burn bar on
|
|
73
|
+
* screens 3 and 4 can never disagree about whether the project is at 80%.
|
|
74
|
+
*/
|
|
75
|
+
export function evaluateBudgetThreshold(input: BudgetThresholdInput): BudgetThresholdEvaluation {
|
|
76
|
+
const alertedAtPercent = normalizeAlertedAtPercent(input.budgetAlertedAtPercent)
|
|
77
|
+
|
|
78
|
+
const burn = computeBudgetBurn({
|
|
79
|
+
kind: input.budgetKind,
|
|
80
|
+
budgetValue: input.budgetValue,
|
|
81
|
+
warnAtPercent: input.budgetWarnAtPercent,
|
|
82
|
+
totalMinutes: input.totalMinutes,
|
|
83
|
+
cost: input.cost,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
if (!burn) {
|
|
87
|
+
return {
|
|
88
|
+
status: 'disabled',
|
|
89
|
+
kind: null,
|
|
90
|
+
budgetValue: null,
|
|
91
|
+
usedValue: null,
|
|
92
|
+
percent: null,
|
|
93
|
+
crossedThresholdPercent: null,
|
|
94
|
+
nextAlertedAtPercent: null,
|
|
95
|
+
shouldPersistAlertedAt: alertedAtPercent !== null,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (burn.kind === 'amount' && (input.cost === null || input.cost === undefined || !hasBillingCurrency(input.currencyCode))) {
|
|
100
|
+
return {
|
|
101
|
+
status: 'unmeasurable',
|
|
102
|
+
kind: burn.kind,
|
|
103
|
+
budgetValue: burn.budgetValue,
|
|
104
|
+
usedValue: null,
|
|
105
|
+
percent: null,
|
|
106
|
+
crossedThresholdPercent: null,
|
|
107
|
+
nextAlertedAtPercent: alertedAtPercent,
|
|
108
|
+
shouldPersistAlertedAt: false,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const warnAtPercent = resolveBudgetWarnAtPercent(input.budgetWarnAtPercent)
|
|
113
|
+
const reachedThresholdPercent =
|
|
114
|
+
burn.percent >= FULL_BUDGET_PERCENT
|
|
115
|
+
? FULL_BUDGET_PERCENT
|
|
116
|
+
: burn.percent >= warnAtPercent
|
|
117
|
+
? warnAtPercent
|
|
118
|
+
: null
|
|
119
|
+
|
|
120
|
+
const crossedThresholdPercent =
|
|
121
|
+
reachedThresholdPercent !== null && (alertedAtPercent === null || reachedThresholdPercent > alertedAtPercent)
|
|
122
|
+
? reachedThresholdPercent
|
|
123
|
+
: null
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
status: 'evaluated',
|
|
127
|
+
kind: burn.kind,
|
|
128
|
+
budgetValue: burn.budgetValue,
|
|
129
|
+
usedValue: burn.usedValue,
|
|
130
|
+
percent: burn.percent,
|
|
131
|
+
crossedThresholdPercent,
|
|
132
|
+
nextAlertedAtPercent: reachedThresholdPercent,
|
|
133
|
+
shouldPersistAlertedAt: reachedThresholdPercent !== alertedAtPercent,
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import type { ProjectBudgetKind } from './budgetBurn'
|
|
3
|
+
|
|
4
|
+
export type TimeProjectBudgetState = {
|
|
5
|
+
timeProjectId: string
|
|
6
|
+
name: string
|
|
7
|
+
ownerUserId: string | null
|
|
8
|
+
budgetKind: ProjectBudgetKind
|
|
9
|
+
budgetValue: number | null
|
|
10
|
+
budgetWarnAtPercent: number | null
|
|
11
|
+
budgetAlertedAtPercent: number | null
|
|
12
|
+
hourlyRate: number | null
|
|
13
|
+
currencyCode: string | null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TimeProjectBudgetScope = {
|
|
17
|
+
em: EntityManager
|
|
18
|
+
tenantId: string
|
|
19
|
+
organizationId: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type BudgetStateRow = {
|
|
23
|
+
time_project_id: string
|
|
24
|
+
name: string | null
|
|
25
|
+
owner_user_id: string | null
|
|
26
|
+
budget_kind: string | null
|
|
27
|
+
budget_value: string | number | null
|
|
28
|
+
budget_warn_at_percent: string | number | null
|
|
29
|
+
budget_alerted_at_percent: string | number | null
|
|
30
|
+
hourly_rate: string | number | null
|
|
31
|
+
currency_code: string | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const BUDGET_KINDS: readonly ProjectBudgetKind[] = ['none', 'hours', 'amount']
|
|
35
|
+
|
|
36
|
+
function toNullableNumber(value: string | number | null | undefined): number | null {
|
|
37
|
+
if (value === null || value === undefined) return null
|
|
38
|
+
const parsed = typeof value === 'number' ? value : Number(value)
|
|
39
|
+
return Number.isFinite(parsed) ? parsed : null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toBudgetKind(value: string | null | undefined): ProjectBudgetKind {
|
|
43
|
+
return BUDGET_KINDS.find((kind) => kind === value) ?? 'none'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Loads the budget state of the project a time entry belongs to, in one scoped
|
|
48
|
+
* round trip. The entry is looked up without a `deleted_at` filter on purpose: a
|
|
49
|
+
* delete is exactly the write that can push usage back under a threshold, and the
|
|
50
|
+
* soft-deleted row is still what tells us which project to re-evaluate.
|
|
51
|
+
*/
|
|
52
|
+
export async function loadTimeProjectBudgetStateForEntry(
|
|
53
|
+
scope: TimeProjectBudgetScope & { timeEntryId: string },
|
|
54
|
+
): Promise<TimeProjectBudgetState | null> {
|
|
55
|
+
const sql = `
|
|
56
|
+
SELECT
|
|
57
|
+
project.id AS time_project_id,
|
|
58
|
+
project.name AS name,
|
|
59
|
+
project.owner_user_id AS owner_user_id,
|
|
60
|
+
project.budget_kind AS budget_kind,
|
|
61
|
+
project.budget_value AS budget_value,
|
|
62
|
+
project.budget_warn_at_percent AS budget_warn_at_percent,
|
|
63
|
+
project.budget_alerted_at_percent AS budget_alerted_at_percent,
|
|
64
|
+
project.hourly_rate AS hourly_rate,
|
|
65
|
+
project.currency_code AS currency_code
|
|
66
|
+
FROM staff_time_entries entry
|
|
67
|
+
JOIN staff_time_projects project
|
|
68
|
+
ON project.id = entry.time_project_id
|
|
69
|
+
AND project.tenant_id = entry.tenant_id
|
|
70
|
+
AND project.organization_id = entry.organization_id
|
|
71
|
+
AND project.deleted_at IS NULL
|
|
72
|
+
WHERE entry.id = ?
|
|
73
|
+
AND entry.tenant_id = ?
|
|
74
|
+
AND entry.organization_id = ?
|
|
75
|
+
LIMIT 1
|
|
76
|
+
`
|
|
77
|
+
|
|
78
|
+
const result = await scope.em.getConnection().execute(sql, [
|
|
79
|
+
scope.timeEntryId,
|
|
80
|
+
scope.tenantId,
|
|
81
|
+
scope.organizationId,
|
|
82
|
+
])
|
|
83
|
+
const rows = (Array.isArray(result) ? result : []) as BudgetStateRow[]
|
|
84
|
+
const row = rows[0]
|
|
85
|
+
if (!row) return null
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
timeProjectId: row.time_project_id,
|
|
89
|
+
name: row.name ?? '',
|
|
90
|
+
ownerUserId: row.owner_user_id ?? null,
|
|
91
|
+
budgetKind: toBudgetKind(row.budget_kind),
|
|
92
|
+
budgetValue: toNullableNumber(row.budget_value),
|
|
93
|
+
budgetWarnAtPercent: toNullableNumber(row.budget_warn_at_percent),
|
|
94
|
+
budgetAlertedAtPercent: toNullableNumber(row.budget_alerted_at_percent),
|
|
95
|
+
hourlyRate: toNullableNumber(row.hourly_rate),
|
|
96
|
+
currencyCode: row.currency_code ?? null,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Compare-and-swap on `budget_alerted_at_percent`, the column that makes the budget
|
|
102
|
+
* notification idempotent. Returns true only for the caller that actually moved the
|
|
103
|
+
* marker, so two concurrent entry writes crossing the same threshold produce one
|
|
104
|
+
* notification rather than two.
|
|
105
|
+
*
|
|
106
|
+
* `updated_at` is deliberately left alone: the marker is platform bookkeeping, not a
|
|
107
|
+
* user edit, and bumping the optimistic-lock version here would make an unrelated
|
|
108
|
+
* open project form fail to save with a spurious 409.
|
|
109
|
+
*/
|
|
110
|
+
export async function claimBudgetThresholdAlert(
|
|
111
|
+
scope: TimeProjectBudgetScope & {
|
|
112
|
+
timeProjectId: string
|
|
113
|
+
expectedAlertedAtPercent: number | null
|
|
114
|
+
nextAlertedAtPercent: number | null
|
|
115
|
+
},
|
|
116
|
+
): Promise<boolean> {
|
|
117
|
+
const sql = `
|
|
118
|
+
UPDATE staff_time_projects
|
|
119
|
+
SET budget_alerted_at_percent = ?
|
|
120
|
+
WHERE id = ?
|
|
121
|
+
AND tenant_id = ?
|
|
122
|
+
AND organization_id = ?
|
|
123
|
+
AND deleted_at IS NULL
|
|
124
|
+
AND budget_alerted_at_percent IS NOT DISTINCT FROM ?
|
|
125
|
+
RETURNING id
|
|
126
|
+
`
|
|
127
|
+
|
|
128
|
+
const result = await scope.em.getConnection().execute(sql, [
|
|
129
|
+
scope.nextAlertedAtPercent,
|
|
130
|
+
scope.timeProjectId,
|
|
131
|
+
scope.tenantId,
|
|
132
|
+
scope.organizationId,
|
|
133
|
+
scope.expectedAlertedAtPercent,
|
|
134
|
+
])
|
|
135
|
+
const rows = (Array.isArray(result) ? result : []) as Array<{ id: string }>
|
|
136
|
+
return rows.length > 0
|
|
137
|
+
}
|