Commit Graph
797 Commits
Author SHA1 Message Date
Jeppe Bundgaard 16094575a7 Refactor ordersRoute, vehiclesRoute, and related routes for subuser permission handling
- Integrate `subusers_permission_node_key` for dynamic subuser-specific permission checks.
- Refactor authentication and permission logic to streamline checks for own vs. department-level access.
- Simplify error handling and enforce scoped permissions for vehicles, orders, and their attachments.
- Localize permission labels and descriptions to Danish for relevant modules.
2026-02-12 15:52:37 +01:00
Jeppe Bundgaard f265a83034 Refactor route_t and orderBookingRoute to simplify permission handling
- Add reusable helpers: `isOwnCustomerContext`, `resolveEffectiveCustomerNumber`, and `allowOwnOrDepartmentAccess` in `route_t` for streamlined permission checks.
- Replace inlined permission logic in `orderBookingRoute` with common helpers for creating, viewing, editing, and deleting bookings.
- Localize permission names, descriptions, and labels to Danish across relevant modules.
- Improve error handling and simplify context resolution for subuser and department-level permissions.
2026-02-12 15:43:02 +01:00
Jeppe Bundgaard cd894b4e3b Refactor orderBookingRoute to integrate subuser-specific permission checks
- Add dynamic authentication and subuser permission handling using `subusers_permission_node_key`.
- Refactor route-level permission logic for creating, viewing, editing, and deleting bookings to respect subuser context.
- Ensure proper error handling for unauthorized access and enforce departmental scope for admin-level actions.
2026-02-12 15:37:03 +01:00
Jeppe Bundgaard 497ef1496b Add subuser permission evaluation system and extend subuser-related route handling
- Introduce `hasPermission` method in `subusers_o` for permission checks tied to customer context.
- Update `/subusers/me` route to return subuser grants with normalized permissions and metadata.
- Add `get_subuser_customer_number_target` in `authentication` to resolve customer context from request headers.
- Refactor route-level permission checks to handle subuser grants dynamically.
- Introduce CLI test scripts for subuser grants and permission node mappings.
- Add test coverage for subuser grants and permission nodes in new test classes.
2026-02-12 15:29:43 +01:00
Jeppe Bundgaard 6375bc7f12 Add explicit fail condition for subuser node key in route permissions
- Ensure permissions pass only if an explicit subuser node key is granted.
- Prevent fallback to classic user permissions in this authentication branch.
2026-02-12 14:28:36 +01:00
Jeppe Bundgaard f2244f5d0d Initialize permission node containers and handle uninitialized properties in subuser_user_grant to ensure proper grant resolution logic. 2026-02-12 14:08:01 +01:00
Jeppe Bundgaard 953067cba5 Extend subuser session handling and refactor permissions in order booking routes
- Add token creation for subusers in `subusers_o` during session generation.
- Refactor `orderBookingRoute` to use dynamic subuser permission definitions with `subusers_permission_node_key`.
2026-02-12 14:01:05 +01:00
Jeppe Bundgaard d26b94de3b Integrate subuser permission node system and refactor route-level permissions
- Add `permission_node` DTO to link classic permissions with subuser-specific nodes.
- Extend `authentication` to support subuser resolution via tokens.
- Introduce route traits for permission evaluation with subuser context.
- Update `requirePermission` and `hasPermission` to handle subuser grants dynamically.
- Implement fallback mechanisms for customer number context in subuser permissions.
2026-02-12 13:54:28 +01:00
Jeppe Bundgaard 2159cd293c Extend type property in tokens_o to support AUTH_TOKEN_SUBUSER 2026-02-12 13:40:19 +01:00
Jeppe Bundgaard 0fddaa79a7 Add name field to /subusers/grants response for improved subuser data clarity
- Retrieve and include the `name` field from the `subusers_o` object in the grant response.
2026-02-12 13:35:47 +01:00
Jeppe Bundgaard 62a7f8d259 Handle bool and json types in object_property and normalize permissions in subuser_grants_o
- Add support for `bool` and `json` types when updating database values in `object_property`.
- Normalize `permissions` handling in `subuser_grants_o` to ensure consistent API output for array data.
2026-02-12 13:19:57 +01:00
Jeppe Bundgaard dcf4252218 Refactor /subusers/grants update logic and require explicit autoloading for subuser module
- Replace route method for updating grants (`PATCH` to `PUT`) and streamline grant updates by directly modifying object properties instead of using manual data arrays.
- Introduce parameter validation for consistency and permission checks for cross-customer grant management.
- Require autoloading for all subuser module components (interfaces, traits, helpers, classes, and permissions) to improve modularity and maintainability.
2026-02-12 13:17:10 +01:00
Jeppe Bundgaard e9e0b3e19e Add include_non_enabled parameter to /subusers endpoint
- Allow listing subusers with only non-enabled grants by introducing an optional `include_non_enabled` query parameter.
- Update SQL query logic to conditionally include non-enabled subuser grants.
- Extend OpenAPI documentation to reflect the new parameter with its description and schema.
2026-02-11 17:58:55 +01:00
Jeppe Bundgaard 34ea4937e0 Add /subusers and /subusers/{id} endpoints for subuser management with permission-based visibility
- Implement routes to list and retrieve subusers based on grant visibility tied to the authenticated user's customer number.
- Extend OpenAPI documentation with detailed descriptions, parameters, and response schemas for the new endpoints.
2026-02-11 17:56:59 +01:00
Jeppe Bundgaard 6b90fe8d8e Refactor /subusers/grants to use paginated response and update dependencies
- Replace manual grant data processing with `listObjectsWithPaginationIfSet` for cleaner pagination and mapping logic.
- Include `subusers_permission_node_key` helper in dependencies.
2026-02-11 17:50:43 +01:00
Jeppe Bundgaard 59040b9cee Add session-based customer number fallback for subuser filtering
- Update `/subusers` route to check the current session user's `customer_number` when no filter is provided.
2026-02-11 17:44:49 +01:00
Jeppe Bundgaard 89b8587dfc Update OpenAPI documentation with new API structure and subuser registration flow
- Add detailed API info, authentication methods, and permission requirements.
- Introduce comprehensive tags for endpoints covering key modules such as Users, Orders, Bookings, Payments, and more.
- Define `/subusers` endpoint for creating subuser registrations with CVR validation and SMS setup flow.
- Update schemas for user and subuser properties, including notifications and timestamps.
2026-02-11 17:39:36 +01:00
Jeppe Bundgaard 354ad86de3 Add CRUD operations for subuser grants and list permission nodes
- Implement routes for managing subuser grants: listing, creating, updating, and deleting.
- Add endpoint to fetch available permission nodes grouped by type.
- Extend `subuser_grants_o` with new utility methods, including `asArray`.
- Update OpenAPI documentation to include new endpoints and schemas.
2026-02-11 17:25:53 +01:00
Jeppe Bundgaard a4f71261d9 Update subuser_grants_o to use default permissions and remove hardcoded driver permission
- Define `defaultPermissions` constant in `subuser_grants_o` for managing default subuser permissions.
- Adjust `add` method to use `defaultPermissions` instead of a hardcoded array.
- Update `/subusers` route to reflect this change.
2026-02-11 17:16:17 +01:00
Jeppe Bundgaard c83b7d49e4 Add permission node system and extend subuser grants functionality
- Introduce a comprehensive permission system for subusers, including permission nodes and types with support for vehicles, bookings, orders, subusers, and self-serve modules.
- Implement `subusers_user`, `subuser_user_grant`, and `subusers_permission_node` classes for managing subuser permissions and grants.
- Extend `subuser_grants_o` with methods to retrieve permissions for subusers linked to customers.
- Add traits and enumerations to streamline permission handling across modules.
- Update subuser session handling to include token-based subuser lookups.
2026-02-11 17:13:25 +01:00
Jeppe Bundgaard 6ad28a26eb Add passkeysRoute for managing user passkeys and extend OpenAPI documentation
- Introduce `passkeysRoute` with operations to list, create, rename, and delete passkeys for authenticated users.
- Update OpenAPI with endpoints and request/response schemas for passkey management.
2026-02-11 15:59:10 +01:00
Jeppe Bundgaard a37e01f7f3 Update passkeys_o timestamps to use timestamp type instead of string 2026-02-11 15:47:41 +01:00
Jeppe Bundgaard fa5a4bf1bf Add passkeys_o class for managing passkey records in the database
- Define object properties for passkey details (credential ID, public key, algorithm, etc.).
- Implement `add` method for creating passkey entries with validation and JSON encoding.
- Include database table structure and property setup within the class.
2026-02-11 15:47:20 +01:00
Jeppe Bundgaard 54de81269b Add /subusers/auth/password endpoint for subuser authentication using password and identifier types 2026-02-11 14:57:46 +01:00
Jeppe Bundgaard 0f5156cdac Add subuser authentication via password and session generation
- Add `/subusers/auth/password` route for subuser authentication using password or other username types (phone, ID, etc.).
- Implement `getSubuserByUsername` in `subusers_o` for retrieving subusers by username.
- Introduce `generateSession` in `subusers_o` for creating and caching session tokens with expiration logic.
2026-02-11 14:51:17 +01:00
Jeppe Bundgaard 937c1d7af5 Add token invalidation and improve email validation in subuser setup flow
- Introduce `invalidateSetupToken` method in `subusers_o` to invalidate setup tokens after registration completion.
- Replace regex with `filter_var` for stricter email format validation.
- Update registration link domain from `web.truckwash.dk` to `truckwash.io`.
2026-02-11 14:40:09 +01:00
Jeppe Bundgaard 66a008fc73 Add subuser_grants_o class and integrate subuser grant creation into /subusers route
- Introduce `subuser_grants_o` for managing subuser grant records in the database.
- Add logic to `/subusers` route for creating grant entries upon subuser creation.
2026-02-10 16:35:50 +01:00
Jeppe Bundgaard aae4139fea Update registration link and success message for subuser setup
- Change the registration link domain from `truckwash.io` to `web.truckwash.dk`.
- Update the response message to indicate successful setup completion.
2026-02-10 16:24:41 +01:00
Jeppe Bundgaard 2206a3dc46 Extend OpenAPI with subuser registration and setup endpoints
- Add `/subusers` route for subuser creation using CVR and phone validation.
- Introduce `/subusers/setup` with token validation and subuser setup completion.
- Define detailed request/response schemas for both endpoints.
2026-02-10 16:21:55 +01:00
Jeppe Bundgaard 9862a1856e Add subuser management route and token-based setup flow
- Introduce `/subusers` route for creating subusers and linking them to companies via phone number validation.
- Add token-based subuser setup flow including token generation, validation, and expiration handling.
- Extend `subusers_o` with methods for subuser lookup, token handling, and secure password management.
- Implement enhanced input validation for subuser creation, ensuring stricter checks for name, username, and email fields.
2026-02-10 16:20:02 +01:00
Jeppe Bundgaard 130cacddaf Add password management methods to subusers_o
- Introduce `setPassword` method for securely updating subuser passwords with validation and hashing.
- Enhance `add` method with stricter password validation and error handling.
- Refactor exception handling and standardize imports for improved clarity.
2026-02-10 14:07:11 +01:00
Jeppe Bundgaard 9e21212785 Add subusers_o class for managing subusers in the database
- Define object properties for subuser details (username, password, email, etc.).
- Implement methods for adding subuser records with validation and password hashing.
- Include database table structure and property setup within the class.
2026-02-10 14:05:31 +01:00
Jeppe Bundgaard 330ac4370f Add getWashesInTimeRange method to orders_o for fetching orders within specified daily time range
- Introduce filtering by time range and optional department ID.
- Validate inputs and ensure robust exception handling for invalid ranges.
- Optimize SQL queries for performance with joins and distinct order retrieval.
2026-02-10 14:05:22 +01:00
Jeppe Bundgaard ed1751ec2c Comment out administration fee enforcement in collected_order_invoices_o for debugging purposes. 2026-02-10 12:36:53 +01:00
Jeppe Bundgaard 8a5a7294ab Refactor invoice comparison logic and deprecate temporary route
- Enhance `/collected-invoices/economic/compare` with improved HTTP status determination and response structure.
- Add handling for `draft_total` and `booked_total` comparisons against internal totals.
- Deprecate `/tmp-customer-list-overcharged` route with error response.
- Update OpenAPI documentation for `compareCollectedInvoiceEconomic` endpoint.
- Introduce `CollectedInvoiceEconomicCompareResponse` schema for consistent API responses.
- Comment out unused return data and debug code for clarity.
2026-02-03 15:08:21 +01:00
Jeppe Bundgaard 58a5f5a26a Add route to compare collected order invoices with E-Conomic
- Introduce `/collected-invoices/economic/compare` endpoint for superusers.
- Enable validation and comparison of draft and booked invoice totals from E-Conomic against internal data.
- Add detailed error handling and warnings for mismatches and retrieval failures.
2026-02-03 12:19:56 +01:00
Jeppe Bundgaard 5aa575268f Add booked invoice helper and retrieval methods
- Introduce `economic_invoice_booked` helper for normalizing booked invoice data.
- Add `getFromId` method to fetch booked invoice details by ID.
- Extend `economic` class with `getInvoiceBookedFromExternalId` for external ID-based retrieval.
- Update imports and economic helper class registrations to include booked invoice functionality.
2026-02-03 12:19:42 +01:00
Jeppe Bundgaard ab93866295 Add Redis connection checks and optimize caching for collected order invoices
- Enhance Redis methods (`exists`, `setEx`, `delete`, `get`, `set`) to ensure connection before execution.
- Introduce short-lived caching for collected order invoices to minimize redundant processing and improve performance.
- Add `pagination_helper` for dynamic WHERE clause construction in queries.
- Refactor net amount calculation in `collected_order_invoices_o` for efficiency with batch processing.
- Extend `listObjectsWithPaginationIfSet` to support additional WHERE clauses.
2026-02-03 11:43:56 +01:00
Jeppe Bundgaard 7aa397acda Add historical invoicing endpoint and enhance permission checks
- Introduce `/superuser/invoicing/period/distribution/wash-subscriptions/historical` endpoint to retrieve historical subscription orders with detailed processing, filtering, and summary calculations.
- Reinstate permission checks for invoicing period distribution endpoints.
- Add Slack notifications for subscription price distribution summaries.
- Refine department ID handling by excluding automatic department (ID 10) during processing.
2026-02-03 09:24:58 +01:00
Jeppe Bundgaard c6cbdea3ee Add getObjectsWhereClause method to db_object_t with deprecation notice
- Introduce `getObjectsWhereClause` for fetching objects using custom where clauses.
- Mark the method as deprecated due to its vulnerability to SQL injection; recommend safer alternatives (`getFieldsWhere`, `getFieldsWhereIn`).
2026-02-03 09:24:07 +01:00
Jeppe Bundgaard ecd40e0b4f Update date handling logic and add isEmpty method in collected_order_invoices_o
- Refactor date calculation to use `closed_at` for determining monthly ranges.
- Fix SQL query to use `closed_at` instead of `created_at` for filtering orders.
- Add `isEmpty` method to check if an invoice collection has any orders.
2026-02-03 09:22:40 +01:00
Jeppe Bundgaard 4778486dac Add SSL mode support for database backups and enhance directory creation checks
- Introduce SSL mode configuration (`ssl_mode`) for `mysqldump` to support secure database backups.
- Update database backup logic to handle SSL options (`DISABLED`, `PREFERRED`, `REQUIRED`, `VERIFY_CA`, `VERIFY_IDENTITY`).
- Improve directory creation checks in backup logic with additional error handling.
- Update `config.example.php` to include `ssl_mode` configuration.
2026-02-02 14:24:28 +01:00
Jeppe Bundgaard 08077df618 Add getOrderItemObjects and getProduct methods, and enhance Slack notifications in invoicing routes
- Introduce `getOrderItemObjects` in `orders_o` to retrieve item objects for an order.
- Add `getProduct` in `order_items_o` for product retrieval by item.
- Enhance Slack notification logic in invoicing routes for better error reporting and fixed pricing summaries.
- Temporarily comment out permission checks in certain invoicing endpoints for debugging purposes.
2026-02-02 12:57:27 +01:00
Jeppe Bundgaard c591439240 Refactor goals_progress_alert_renderer to separate period department lines from totals
- Introduce `periodLines` array for improved clarity and logic separation.
- Update total expression to include period label for better formatting.
- Move department lines and blanks to `periodLines` and merge into output at the end of each period.
2026-02-02 11:25:45 +01:00
Jeppe Bundgaard 4816075041 Add total progress summary line in goals_progress_alert_renderer
- Include total progress calculations across departments for each period.
- Add percentage comparison against target when applicable.
2026-02-02 10:42:33 +01:00
Jeppe Bundgaard 17325f565e Update Slack notification logic and refine COUNT_ONLY summary rendering
- Swap `send_message` with `send_webhook_message` to fix departmental Slack notification issues.
- Adjust `COUNT_ONLY` in `renderDanishPeriodSummary` to exclude targets for raw count-focused alerts.
2026-01-29 20:31:05 +01:00
Jeppe Bundgaard 4f9c91dceb Refactor goals_progress_alert_renderer for improved date handling and department target calculations
- Replace immutable/mutable `DateTime` conversions with safer handling in target and progress calculations.
- Update `getDailyTarget` to normalize timeframes and improve operating day computations.
- Refine department-specific target calculation logic for enhanced accuracy in multi-department setups.
2026-01-29 20:24:47 +01:00
Jeppe Bundgaard cd2190d976 Refactor goals_progress_alert_renderer for enhanced department summary rendering
- Simplify multi-period department progress calculations by restructuring logic to render by period first.
- Add support for daily target calculations and timeframe-based target adjustments in `goals_criteria`.
- Introduce `countOperatingDaysInTimeframe` and related helper methods for improved alert scheduling and progress tracking.
2026-01-29 20:20:05 +01:00
Jeppe Bundgaard b3b12b58fd Refactor goals_criteria and goals_progress_alert_renderer for improved department filtering and summary rendering
- Add cloning logic in `withDepartmentFilter` to avoid mutating original `goals_criteria` objects.
- Rename method parameter in `render` and refactor `renderDanishPeriodSummary` for enhanced readability and flexibility.
- Introduce helper methods for date range and criteria window adjustments to streamline department progress calculations.
2026-01-29 19:42:03 +01:00
Jeppe Bundgaard 84bfbdad25 Refactor Slack notifications and enhance departmental progress calculation
- Replace `send_webhook_message` with `send_message` for improved Slack notification rendering using `goals_progress_alert_renderer`.
- Add methods for calculating and retrieving departmental progress and distribution in `goals_criteria`.
- Update `renderDanishPeriodSummary` and Slack cron logic to support departmental-specific summaries.
- Include departmental progress in serialized goal objects for better reporting.
2026-01-29 18:30:04 +01:00