@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,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sheet of screen 14, built once and reused by the detail page, the exports
|
|
3
|
+
* and the close command.
|
|
4
|
+
*
|
|
5
|
+
* The one rule that matters here is the difference between a draft and a closed
|
|
6
|
+
* report:
|
|
7
|
+
*
|
|
8
|
+
* - a **draft** is computed live, so it moves when an entry is edited or the
|
|
9
|
+
* rounding rule changes — by design, and screen 16 says so;
|
|
10
|
+
* - a **closed** report renders exactly what it froze. Its lines come from the
|
|
11
|
+
* `staff_time_report_entries` snapshots, so a later rounding change, a rate
|
|
12
|
+
* change or an unlocked-and-edited entry cannot restate an invoice a client
|
|
13
|
+
* already holds (risk R1).
|
|
14
|
+
*
|
|
15
|
+
* Both paths go through the same `computeReportTotals`, which is what keeps the
|
|
16
|
+
* preview, the sheet and the freeze records arithmetically identical.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
20
|
+
import type { StaffTimeReport } from '../../data/entities'
|
|
21
|
+
import { loadReportData, type ReportDataScope } from './loadReportData'
|
|
22
|
+
import { normalizeReportGrouping } from './reportGroupings'
|
|
23
|
+
import {
|
|
24
|
+
computeReportTotals,
|
|
25
|
+
resolveReportCurrency,
|
|
26
|
+
type ReportDirectory,
|
|
27
|
+
type ReportGrouping,
|
|
28
|
+
type ReportInputEntry,
|
|
29
|
+
type ReportInputProject,
|
|
30
|
+
type ReportNonBillableMode,
|
|
31
|
+
type ReportTotals,
|
|
32
|
+
} from './reportTotals'
|
|
33
|
+
|
|
34
|
+
export type ReportSheetLabels = {
|
|
35
|
+
unassignedTask: string
|
|
36
|
+
unassignedPerson: string
|
|
37
|
+
nonbillableGroup: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type BuildReportSheetInput = {
|
|
41
|
+
em: EntityManager
|
|
42
|
+
scope: ReportDataScope
|
|
43
|
+
report: StaffTimeReport
|
|
44
|
+
timeProjectIds: readonly string[]
|
|
45
|
+
labels: ReportSheetLabels
|
|
46
|
+
/** Overrides the report's stored grouping, for an export that re-groups. */
|
|
47
|
+
grouping?: ReportGrouping
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ReportSheet = {
|
|
51
|
+
totals: ReportTotals
|
|
52
|
+
entries: ReportInputEntry[]
|
|
53
|
+
projects: ReportInputProject[]
|
|
54
|
+
directory: ReportDirectory
|
|
55
|
+
currencyCode: string | null
|
|
56
|
+
grouping: ReportGrouping
|
|
57
|
+
nonbillableMode: ReportNonBillableMode
|
|
58
|
+
isClosed: boolean
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function toDate(value: Date | string | null | undefined, fallback: Date): Date {
|
|
62
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value
|
|
63
|
+
if (typeof value === 'string') {
|
|
64
|
+
const parsed = new Date(value)
|
|
65
|
+
if (!Number.isNaN(parsed.getTime())) return parsed
|
|
66
|
+
}
|
|
67
|
+
return fallback
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function buildReportSheet(input: BuildReportSheetInput): Promise<ReportSheet> {
|
|
71
|
+
const { em, scope, report, labels } = input
|
|
72
|
+
const isClosed = report.status === 'closed'
|
|
73
|
+
const grouping = normalizeReportGrouping(input.grouping ?? report.grouping)
|
|
74
|
+
const nonbillableMode = report.nonbillableMode as ReportNonBillableMode
|
|
75
|
+
|
|
76
|
+
const data = await loadReportData({
|
|
77
|
+
em,
|
|
78
|
+
scope,
|
|
79
|
+
timeProjectIds: input.timeProjectIds,
|
|
80
|
+
periodFrom: toDate(report.periodFrom, new Date(0)),
|
|
81
|
+
periodTo: toDate(report.periodTo, new Date()),
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// A closed report shows only what it froze. An entry logged into the period
|
|
85
|
+
// AFTER the report closed is genuinely new work and belongs to the next
|
|
86
|
+
// report — screen 15 note 2 is explicit that the lock covers entries, not
|
|
87
|
+
// tasks, so logging more time on the same task must stay possible.
|
|
88
|
+
const entries = isClosed
|
|
89
|
+
? data.entries.filter((entry) => entry.frozen?.reportId === report.id)
|
|
90
|
+
: data.entries
|
|
91
|
+
|
|
92
|
+
const totals = computeReportTotals({
|
|
93
|
+
entries,
|
|
94
|
+
projects: data.projects,
|
|
95
|
+
directory: data.directory,
|
|
96
|
+
options: {
|
|
97
|
+
grouping,
|
|
98
|
+
nonbillableMode,
|
|
99
|
+
includeAlreadyReported: report.includeAlreadyReported ?? false,
|
|
100
|
+
},
|
|
101
|
+
currentReportId: report.id,
|
|
102
|
+
labels,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const currency = resolveReportCurrency(
|
|
106
|
+
data.projects.map((project) => ({
|
|
107
|
+
id: project.id,
|
|
108
|
+
name: project.name,
|
|
109
|
+
currencyCode: project.currencyCode,
|
|
110
|
+
})),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
totals,
|
|
115
|
+
entries,
|
|
116
|
+
projects: data.projects,
|
|
117
|
+
directory: data.directory,
|
|
118
|
+
// A closed report keeps the currency it was closed with, even if a project
|
|
119
|
+
// has since been relabelled (risk R11).
|
|
120
|
+
currencyCode: isClosed ? report.currencyCode : currency.ok ? currency.currencyCode : report.currencyCode,
|
|
121
|
+
grouping,
|
|
122
|
+
nonbillableMode,
|
|
123
|
+
isClosed,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one read that feeds every report surface: the live preview of screen 13,
|
|
3
|
+
* the sheet of screen 14, the close command's freeze records and the exports.
|
|
4
|
+
*
|
|
5
|
+
* It is deliberately a single loader rather than one query per surface, because
|
|
6
|
+
* a preview that counts different hours from the sheet it generates — or from
|
|
7
|
+
* the snapshot the close writes — is the failure mode this whole phase exists to
|
|
8
|
+
* prevent. Everything downstream consumes the same `ReportInputEntry[]`.
|
|
9
|
+
*
|
|
10
|
+
* Scoping is not optional here: every query carries `tenantId` and
|
|
11
|
+
* `organizationId`, and the project ids are expected to have been narrowed by
|
|
12
|
+
* `resolveProjectAccess` before they arrive.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
16
|
+
import { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
17
|
+
import {
|
|
18
|
+
StaffTeamMember,
|
|
19
|
+
StaffTimeEntry,
|
|
20
|
+
StaffTimeProject,
|
|
21
|
+
StaffTimeReport,
|
|
22
|
+
StaffTimeReportEntry,
|
|
23
|
+
StaffTimeTask,
|
|
24
|
+
} from '../../data/entities'
|
|
25
|
+
import type { FrozenEntryValues, ReportDirectory, ReportInputEntry, ReportInputProject } from './reportTotals'
|
|
26
|
+
|
|
27
|
+
export type ReportDataScope = {
|
|
28
|
+
tenantId: string
|
|
29
|
+
organizationId: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type LoadReportDataInput = {
|
|
33
|
+
em: EntityManager
|
|
34
|
+
scope: ReportDataScope
|
|
35
|
+
timeProjectIds: readonly string[]
|
|
36
|
+
periodFrom: Date
|
|
37
|
+
periodTo: Date
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ReportData = {
|
|
41
|
+
projects: ReportInputProject[]
|
|
42
|
+
entries: ReportInputEntry[]
|
|
43
|
+
directory: ReportDirectory
|
|
44
|
+
/** Raw project rows, kept so callers can assert currency without a second read. */
|
|
45
|
+
projectRows: StaffTimeProject[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function toNumberOrNull(value: unknown): number | null {
|
|
49
|
+
if (value === null || value === undefined) return null
|
|
50
|
+
const parsed = typeof value === 'number' ? value : Number.parseFloat(String(value))
|
|
51
|
+
return Number.isFinite(parsed) ? parsed : null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function toIsoDate(value: Date | string | null | undefined): string {
|
|
55
|
+
if (!value) return ''
|
|
56
|
+
if (value instanceof Date) {
|
|
57
|
+
if (Number.isNaN(value.getTime())) return ''
|
|
58
|
+
const year = value.getFullYear()
|
|
59
|
+
const month = String(value.getMonth() + 1).padStart(2, '0')
|
|
60
|
+
const day = String(value.getDate()).padStart(2, '0')
|
|
61
|
+
return `${year}-${month}-${day}`
|
|
62
|
+
}
|
|
63
|
+
return String(value).slice(0, 10)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* D-2 caps nesting at one level, so a task's root is either itself or its
|
|
68
|
+
* parent. The fallback to the task's own id keeps a line visible even if a
|
|
69
|
+
* parent row has since been hard-removed.
|
|
70
|
+
*/
|
|
71
|
+
function resolveRootTaskId(taskId: string | null, parentById: ReadonlyMap<string, string | null>): string | null {
|
|
72
|
+
if (!taskId) return null
|
|
73
|
+
const parent = parentById.get(taskId)
|
|
74
|
+
if (!parent) return taskId
|
|
75
|
+
return parent
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function loadReportData(input: LoadReportDataInput): Promise<ReportData> {
|
|
79
|
+
const { em, scope, periodFrom, periodTo } = input
|
|
80
|
+
const projectIds = Array.from(new Set(input.timeProjectIds.filter((id) => typeof id === 'string' && id.length > 0)))
|
|
81
|
+
if (projectIds.length === 0) {
|
|
82
|
+
return {
|
|
83
|
+
projects: [],
|
|
84
|
+
entries: [],
|
|
85
|
+
directory: { taskLabelById: {}, personLabelById: {} },
|
|
86
|
+
projectRows: [],
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const projectRows = await em.find(StaffTimeProject, {
|
|
91
|
+
id: { $in: projectIds },
|
|
92
|
+
tenantId: scope.tenantId,
|
|
93
|
+
organizationId: scope.organizationId,
|
|
94
|
+
deletedAt: null,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const entryRows = await em.find(StaffTimeEntry, {
|
|
98
|
+
timeProjectId: { $in: projectIds },
|
|
99
|
+
tenantId: scope.tenantId,
|
|
100
|
+
organizationId: scope.organizationId,
|
|
101
|
+
deletedAt: null,
|
|
102
|
+
date: { $gte: periodFrom, $lte: periodTo },
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const taskIds = Array.from(
|
|
106
|
+
new Set(entryRows.map((entry) => entry.taskId).filter((id): id is string => typeof id === 'string' && id.length > 0)),
|
|
107
|
+
)
|
|
108
|
+
const taskRows =
|
|
109
|
+
taskIds.length > 0
|
|
110
|
+
? await em.find(StaffTimeTask, {
|
|
111
|
+
id: { $in: taskIds },
|
|
112
|
+
tenantId: scope.tenantId,
|
|
113
|
+
organizationId: scope.organizationId,
|
|
114
|
+
})
|
|
115
|
+
: []
|
|
116
|
+
|
|
117
|
+
// A child task's parent is not necessarily among the entries' tasks, so the
|
|
118
|
+
// parents are fetched in a second pass to give the rolled-up line its label.
|
|
119
|
+
const parentIds = Array.from(
|
|
120
|
+
new Set(
|
|
121
|
+
taskRows
|
|
122
|
+
.map((task) => task.parentTaskId)
|
|
123
|
+
.filter((id): id is string => typeof id === 'string' && id.length > 0 && !taskIds.includes(id)),
|
|
124
|
+
),
|
|
125
|
+
)
|
|
126
|
+
const parentRows =
|
|
127
|
+
parentIds.length > 0
|
|
128
|
+
? await em.find(StaffTimeTask, {
|
|
129
|
+
id: { $in: parentIds },
|
|
130
|
+
tenantId: scope.tenantId,
|
|
131
|
+
organizationId: scope.organizationId,
|
|
132
|
+
})
|
|
133
|
+
: []
|
|
134
|
+
|
|
135
|
+
const parentById = new Map<string, string | null>()
|
|
136
|
+
const taskLabelById: Record<string, string> = {}
|
|
137
|
+
for (const task of [...taskRows, ...parentRows]) {
|
|
138
|
+
parentById.set(task.id, task.parentTaskId ?? null)
|
|
139
|
+
taskLabelById[task.id] = task.title
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const staffMemberIds = Array.from(
|
|
143
|
+
new Set(
|
|
144
|
+
entryRows
|
|
145
|
+
.map((entry) => entry.staffMemberId)
|
|
146
|
+
.filter((id): id is string => typeof id === 'string' && id.length > 0),
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
const memberRows =
|
|
150
|
+
staffMemberIds.length > 0
|
|
151
|
+
? await findWithDecryption(
|
|
152
|
+
em,
|
|
153
|
+
StaffTeamMember,
|
|
154
|
+
{
|
|
155
|
+
id: { $in: staffMemberIds },
|
|
156
|
+
tenantId: scope.tenantId,
|
|
157
|
+
organizationId: scope.organizationId,
|
|
158
|
+
},
|
|
159
|
+
{},
|
|
160
|
+
scope,
|
|
161
|
+
)
|
|
162
|
+
: []
|
|
163
|
+
const personLabelById: Record<string, string> = {}
|
|
164
|
+
for (const member of memberRows) personLabelById[member.id] = member.displayName
|
|
165
|
+
|
|
166
|
+
const frozenByEntryId = await loadFrozenValues(
|
|
167
|
+
em,
|
|
168
|
+
scope,
|
|
169
|
+
entryRows.map((entry) => entry.id),
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
const entries: ReportInputEntry[] = entryRows.map((entry) => ({
|
|
173
|
+
id: entry.id,
|
|
174
|
+
timeProjectId: entry.timeProjectId ?? '',
|
|
175
|
+
taskId: entry.taskId ?? null,
|
|
176
|
+
rootTaskId: resolveRootTaskId(entry.taskId ?? null, parentById),
|
|
177
|
+
staffMemberId: entry.staffMemberId ?? null,
|
|
178
|
+
date: toIsoDate(entry.date),
|
|
179
|
+
durationMinutes: entry.durationMinutes ?? 0,
|
|
180
|
+
roundedMinutes: entry.roundedMinutes ?? null,
|
|
181
|
+
isBillable: entry.isBillable ?? true,
|
|
182
|
+
rateOverrideAmount: toNumberOrNull(entry.rateOverrideAmount),
|
|
183
|
+
description: entry.notes ?? null,
|
|
184
|
+
frozen: frozenByEntryId.get(entry.id) ?? null,
|
|
185
|
+
}))
|
|
186
|
+
|
|
187
|
+
const projects: ReportInputProject[] = projectRows.map((project) => ({
|
|
188
|
+
id: project.id,
|
|
189
|
+
name: project.name,
|
|
190
|
+
hourlyRate: toNumberOrNull(project.hourlyRate),
|
|
191
|
+
currencyCode: project.currencyCode ?? null,
|
|
192
|
+
}))
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
projects,
|
|
196
|
+
entries,
|
|
197
|
+
directory: { taskLabelById, personLabelById },
|
|
198
|
+
projectRows,
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* D-5's indexed lookup. `staff_time_report_entries` is authoritative for "has
|
|
204
|
+
* this hour been billed already?", and only rows belonging to a **closed**
|
|
205
|
+
* report count: a freeze record left behind by a report that has since been
|
|
206
|
+
* unlocked must not keep an hour out of the next invoice.
|
|
207
|
+
*/
|
|
208
|
+
export async function loadFrozenValues(
|
|
209
|
+
em: EntityManager,
|
|
210
|
+
scope: ReportDataScope,
|
|
211
|
+
timeEntryIds: readonly string[],
|
|
212
|
+
): Promise<Map<string, FrozenEntryValues>> {
|
|
213
|
+
const ids = Array.from(new Set(timeEntryIds.filter((id) => typeof id === 'string' && id.length > 0)))
|
|
214
|
+
const result = new Map<string, FrozenEntryValues>()
|
|
215
|
+
if (ids.length === 0) return result
|
|
216
|
+
|
|
217
|
+
const rows = await em.find(StaffTimeReportEntry, {
|
|
218
|
+
timeEntryId: { $in: ids },
|
|
219
|
+
tenantId: scope.tenantId,
|
|
220
|
+
organizationId: scope.organizationId,
|
|
221
|
+
})
|
|
222
|
+
if (rows.length === 0) return result
|
|
223
|
+
|
|
224
|
+
const reportIds = Array.from(new Set(rows.map((row) => row.reportId)))
|
|
225
|
+
const reports = await em.find(StaffTimeReport, {
|
|
226
|
+
id: { $in: reportIds },
|
|
227
|
+
tenantId: scope.tenantId,
|
|
228
|
+
organizationId: scope.organizationId,
|
|
229
|
+
status: 'closed',
|
|
230
|
+
deletedAt: null,
|
|
231
|
+
})
|
|
232
|
+
const reportById = new Map(reports.map((report) => [report.id, report]))
|
|
233
|
+
|
|
234
|
+
for (const row of rows) {
|
|
235
|
+
const report = reportById.get(row.reportId)
|
|
236
|
+
if (!report) continue
|
|
237
|
+
result.set(row.timeEntryId, {
|
|
238
|
+
reportId: report.id,
|
|
239
|
+
reference: report.reference ?? null,
|
|
240
|
+
title: report.title ?? null,
|
|
241
|
+
rawMinutes: row.frozenRawMinutes ?? 0,
|
|
242
|
+
roundedMinutes: row.frozenRoundedMinutes ?? 0,
|
|
243
|
+
rateAmount: toNumberOrNull(row.frozenRateAmount),
|
|
244
|
+
currencyCode: row.frozenCurrencyCode ?? null,
|
|
245
|
+
amount: toNumberOrNull(row.frozenAmount),
|
|
246
|
+
isBillable: row.frozenIsBillable ?? true,
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return result
|
|
251
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal, dependency-free PDF writer — just enough to print the report sheet
|
|
3
|
+
* of screen 14 as the client-facing document US-G4 asks for.
|
|
4
|
+
*
|
|
5
|
+
* The repository has no PDF library and adding a production dependency is an
|
|
6
|
+
* "ask first" change, so this emits PDF 1.4 directly: a catalog, a pages tree,
|
|
7
|
+
* two base-14 fonts and one content stream per page. Nothing here is a general
|
|
8
|
+
* PDF toolkit; it lays out left-aligned and right-aligned text runs on a fixed
|
|
9
|
+
* grid, which is exactly what a table of hours and amounts needs.
|
|
10
|
+
*
|
|
11
|
+
* **Polish text is the reason for the encoding work.** The mockups are Polish
|
|
12
|
+
* and a report is a client-facing document, so `ą ć ę ł ń ś ź ż` must survive.
|
|
13
|
+
* WinAnsiEncoding covers `ó`/`Ó` and nothing else Polish, so the remaining
|
|
14
|
+
* sixteen glyphs are mapped into unused low code points through a `/Differences`
|
|
15
|
+
* array using their standard Adobe glyph names. A character with no mapping is
|
|
16
|
+
* rendered as `?` rather than being dropped, so a missing glyph is visible
|
|
17
|
+
* rather than silently changing a name.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type PdfTextAlign = 'left' | 'right'
|
|
21
|
+
|
|
22
|
+
export type PdfCell = {
|
|
23
|
+
text: string
|
|
24
|
+
x: number
|
|
25
|
+
align?: PdfTextAlign
|
|
26
|
+
bold?: boolean
|
|
27
|
+
size?: number
|
|
28
|
+
/** Grey for hints and secondary text; black otherwise. */
|
|
29
|
+
muted?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type PdfLine =
|
|
33
|
+
| { kind: 'cells'; cells: PdfCell[] }
|
|
34
|
+
| { kind: 'rule' }
|
|
35
|
+
| { kind: 'space'; height: number }
|
|
36
|
+
|
|
37
|
+
export type PdfDocumentInput = {
|
|
38
|
+
title: string
|
|
39
|
+
lines: PdfLine[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const PDF_CONTENT_TYPE = 'application/pdf'
|
|
43
|
+
|
|
44
|
+
const PAGE_WIDTH = 595.28
|
|
45
|
+
const PAGE_HEIGHT = 841.89
|
|
46
|
+
const MARGIN_X = 42
|
|
47
|
+
const MARGIN_TOP = 56
|
|
48
|
+
const MARGIN_BOTTOM = 48
|
|
49
|
+
const LINE_HEIGHT = 14
|
|
50
|
+
const DEFAULT_SIZE = 9
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Glyphs Polish needs that WinAnsiEncoding does not carry, parked in unused
|
|
54
|
+
* low code points and declared through /Differences.
|
|
55
|
+
*/
|
|
56
|
+
const DIFFERENCE_GLYPHS: Array<[string, number, string]> = [
|
|
57
|
+
['ą', 1, 'aogonek'],
|
|
58
|
+
['ć', 2, 'cacute'],
|
|
59
|
+
['ę', 3, 'eogonek'],
|
|
60
|
+
['ł', 4, 'lslash'],
|
|
61
|
+
['ń', 5, 'nacute'],
|
|
62
|
+
['ś', 6, 'sacute'],
|
|
63
|
+
['ź', 7, 'zacute'],
|
|
64
|
+
['ż', 8, 'zdotaccent'],
|
|
65
|
+
['Ą', 9, 'Aogonek'],
|
|
66
|
+
['Ć', 10, 'Cacute'],
|
|
67
|
+
['Ę', 11, 'Eogonek'],
|
|
68
|
+
['Ł', 12, 'Lslash'],
|
|
69
|
+
['Ń', 13, 'Nacute'],
|
|
70
|
+
['Ś', 14, 'Sacute'],
|
|
71
|
+
['Ź', 15, 'Zacute'],
|
|
72
|
+
['Ż', 16, 'Zdotaccent'],
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
/** Characters WinAnsiEncoding already carries at a code above ASCII. */
|
|
76
|
+
const WIN_ANSI_EXTRAS: Record<string, number> = {
|
|
77
|
+
'ó': 0xf3,
|
|
78
|
+
'Ó': 0xd3,
|
|
79
|
+
'é': 0xe9,
|
|
80
|
+
'è': 0xe8,
|
|
81
|
+
'ä': 0xe4,
|
|
82
|
+
'ö': 0xf6,
|
|
83
|
+
'ü': 0xfc,
|
|
84
|
+
'ß': 0xdf,
|
|
85
|
+
'á': 0xe1,
|
|
86
|
+
'í': 0xed,
|
|
87
|
+
'ñ': 0xf1,
|
|
88
|
+
'ú': 0xfa,
|
|
89
|
+
'–': 0x96,
|
|
90
|
+
'—': 0x97,
|
|
91
|
+
'·': 0xb7,
|
|
92
|
+
'€': 0x80,
|
|
93
|
+
'„': 0x84,
|
|
94
|
+
'”': 0x94,
|
|
95
|
+
'’': 0x92,
|
|
96
|
+
'‘': 0x91,
|
|
97
|
+
'…': 0x85,
|
|
98
|
+
'°': 0xb0,
|
|
99
|
+
'×': 0xd7,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const ENCODING_MAP: Map<string, number> = (() => {
|
|
103
|
+
const map = new Map<string, number>()
|
|
104
|
+
for (let code = 32; code <= 126; code += 1) map.set(String.fromCharCode(code), code)
|
|
105
|
+
for (const [char, code] of Object.entries(WIN_ANSI_EXTRAS)) map.set(char, code)
|
|
106
|
+
for (const [char, code] of DIFFERENCE_GLYPHS) map.set(char, code)
|
|
107
|
+
return map
|
|
108
|
+
})()
|
|
109
|
+
|
|
110
|
+
export function encodePdfText(value: string): string {
|
|
111
|
+
let out = ''
|
|
112
|
+
for (const char of value) {
|
|
113
|
+
const code = ENCODING_MAP.get(char) ?? 0x3f
|
|
114
|
+
const byte = String.fromCharCode(code)
|
|
115
|
+
if (byte === '(' || byte === ')' || byte === '\\') out += `\\${byte}`
|
|
116
|
+
else out += byte
|
|
117
|
+
}
|
|
118
|
+
return out
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Helvetica advance widths (1/1000 em) for the printable ASCII range, used to
|
|
123
|
+
* right-align the money and hours columns. Characters outside the table fall
|
|
124
|
+
* back to the average width, which is close enough for the accented letters and
|
|
125
|
+
* only ever shifts a right-aligned label by a hair.
|
|
126
|
+
*/
|
|
127
|
+
const HELVETICA_WIDTHS: Record<string, number> = (() => {
|
|
128
|
+
const widths: Record<string, number> = {}
|
|
129
|
+
const groups: Array<[number, string]> = [
|
|
130
|
+
[278, ' !I|jltfi.,:;\'`'],
|
|
131
|
+
[355, '"'],
|
|
132
|
+
[556, '#$0123456789+<=>~'],
|
|
133
|
+
[889, '%'],
|
|
134
|
+
[667, '&BCDEHKNRSUVXY'],
|
|
135
|
+
[333, '()[]{}/\\*-r'],
|
|
136
|
+
[584, '^'],
|
|
137
|
+
[500, '?_'],
|
|
138
|
+
[1015, '@'],
|
|
139
|
+
[722, 'ADGHOQ'],
|
|
140
|
+
[611, 'FPZ'],
|
|
141
|
+
[944, 'M'],
|
|
142
|
+
[778, 'W'],
|
|
143
|
+
[556, 'abcdeghknopqsu'],
|
|
144
|
+
[222, 'i'],
|
|
145
|
+
[500, 'yvz'],
|
|
146
|
+
[833, 'm'],
|
|
147
|
+
[722, 'w'],
|
|
148
|
+
[333, 'JLT'],
|
|
149
|
+
]
|
|
150
|
+
for (const [width, chars] of groups) {
|
|
151
|
+
for (const char of chars) widths[char] = width
|
|
152
|
+
}
|
|
153
|
+
return widths
|
|
154
|
+
})()
|
|
155
|
+
|
|
156
|
+
export function measureText(text: string, size: number, bold: boolean): number {
|
|
157
|
+
let units = 0
|
|
158
|
+
for (const char of text) units += HELVETICA_WIDTHS[char] ?? 556
|
|
159
|
+
// Helvetica-Bold runs a touch wider; a flat factor is accurate enough for
|
|
160
|
+
// right-aligning a column and avoids shipping a second width table.
|
|
161
|
+
const factor = bold ? 1.03 : 1
|
|
162
|
+
return (units / 1000) * size * factor
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
type PageContent = string[]
|
|
166
|
+
|
|
167
|
+
function buildPages(input: PdfDocumentInput): PageContent[] {
|
|
168
|
+
const pages: PageContent[] = []
|
|
169
|
+
let current: PageContent = []
|
|
170
|
+
let y = PAGE_HEIGHT - MARGIN_TOP
|
|
171
|
+
|
|
172
|
+
const pushPage = () => {
|
|
173
|
+
if (current.length > 0) pages.push(current)
|
|
174
|
+
current = []
|
|
175
|
+
y = PAGE_HEIGHT - MARGIN_TOP
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
for (const line of input.lines) {
|
|
179
|
+
const height = line.kind === 'space' ? line.height : LINE_HEIGHT
|
|
180
|
+
if (y - height < MARGIN_BOTTOM) pushPage()
|
|
181
|
+
|
|
182
|
+
if (line.kind === 'space') {
|
|
183
|
+
y -= line.height
|
|
184
|
+
continue
|
|
185
|
+
}
|
|
186
|
+
if (line.kind === 'rule') {
|
|
187
|
+
current.push(
|
|
188
|
+
`0.8 0.8 0.8 RG 0.5 w ${MARGIN_X} ${(y - 4).toFixed(2)} m ${(PAGE_WIDTH - MARGIN_X).toFixed(2)} ${(y - 4).toFixed(2)} l S`,
|
|
189
|
+
)
|
|
190
|
+
y -= LINE_HEIGHT
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (const cell of line.cells) {
|
|
195
|
+
const size = cell.size ?? DEFAULT_SIZE
|
|
196
|
+
const font = cell.bold ? '/F2' : '/F1'
|
|
197
|
+
const width = measureText(cell.text, size, cell.bold === true)
|
|
198
|
+
const x = cell.align === 'right' ? cell.x - width : cell.x
|
|
199
|
+
const colour = cell.muted ? '0.45 0.45 0.45 rg' : '0 0 0 rg'
|
|
200
|
+
current.push(
|
|
201
|
+
`BT ${colour} ${font} ${size} Tf 1 0 0 1 ${x.toFixed(2)} ${y.toFixed(2)} Tm (${encodePdfText(cell.text)}) Tj ET`,
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
y -= LINE_HEIGHT
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
pushPage()
|
|
208
|
+
return pages.length > 0 ? pages : [[]]
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function buildPdf(input: PdfDocumentInput): Buffer {
|
|
212
|
+
const pages = buildPages(input)
|
|
213
|
+
const objects: string[] = []
|
|
214
|
+
|
|
215
|
+
const differences = DIFFERENCE_GLYPHS.map(([, code, glyph]) => `${code} /${glyph}`).join(' ')
|
|
216
|
+
const pageObjectStart = 6
|
|
217
|
+
const pageIds = pages.map((_, index) => pageObjectStart + index * 2)
|
|
218
|
+
|
|
219
|
+
objects[1] = '<< /Type /Catalog /Pages 2 0 R >>'
|
|
220
|
+
objects[2] = `<< /Type /Pages /Kids [${pageIds.map((id) => `${id} 0 R`).join(' ')}] /Count ${pages.length} >>`
|
|
221
|
+
objects[3] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding 5 0 R >>'
|
|
222
|
+
objects[4] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding 5 0 R >>'
|
|
223
|
+
objects[5] = `<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [${differences}] >>`
|
|
224
|
+
|
|
225
|
+
pages.forEach((content, index) => {
|
|
226
|
+
const pageId = pageIds[index]
|
|
227
|
+
const contentId = pageId + 1
|
|
228
|
+
const stream = content.join('\n')
|
|
229
|
+
objects[pageId] =
|
|
230
|
+
`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${PAGE_WIDTH} ${PAGE_HEIGHT}] ` +
|
|
231
|
+
`/Resources << /Font << /F1 3 0 R /F2 4 0 R >> >> /Contents ${contentId} 0 R >>`
|
|
232
|
+
objects[contentId] = `<< /Length ${Buffer.byteLength(stream, 'latin1')} >>\nstream\n${stream}\nendstream`
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
const chunks: Buffer[] = [Buffer.from('%PDF-1.4\n', 'latin1')]
|
|
236
|
+
let offset = chunks[0].length
|
|
237
|
+
const offsets: number[] = []
|
|
238
|
+
|
|
239
|
+
for (let id = 1; id < objects.length; id += 1) {
|
|
240
|
+
const body = objects[id]
|
|
241
|
+
if (body === undefined) continue
|
|
242
|
+
offsets[id] = offset
|
|
243
|
+
const chunk = Buffer.from(`${id} 0 obj\n${body}\nendobj\n`, 'latin1')
|
|
244
|
+
chunks.push(chunk)
|
|
245
|
+
offset += chunk.length
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const maxId = objects.length
|
|
249
|
+
const xrefOffset = offset
|
|
250
|
+
const xrefRows = ['0000000000 65535 f \n']
|
|
251
|
+
for (let id = 1; id < maxId; id += 1) {
|
|
252
|
+
const at = offsets[id]
|
|
253
|
+
xrefRows.push(at === undefined ? '0000000000 65535 f \n' : `${String(at).padStart(10, '0')} 00000 n \n`)
|
|
254
|
+
}
|
|
255
|
+
chunks.push(
|
|
256
|
+
Buffer.from(
|
|
257
|
+
`xref\n0 ${maxId}\n${xrefRows.join('')}trailer\n<< /Size ${maxId} /Root 1 0 R >>\nstartxref\n${xrefOffset}\n%%EOF\n`,
|
|
258
|
+
'latin1',
|
|
259
|
+
),
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
return Buffer.concat(chunks)
|
|
263
|
+
}
|