Commit Graph
493 Commits
Author SHA1 Message Date
Jeppe Bundgaard 4cada3c677 Add permissions for editing and deleting own order bookings in orderBookingRoute 2025-11-11 10:31:59 +01:00
Jeppe Bundgaard ff7f87475d Handle boolean conversion, null checks, and object sanitization in db_object_t and enhance parameter validation in orderBookingRoute
- Added boolean to integer conversion in `db_object_t` during database operations.
- Improved handling of null values, numeric types, and sanitized inputs in `db_object_t`.
- Enhanced safety seal parameter validation in `orderBookingRoute` with support for nullable integers.
- Updated `getTargetItems` to retrieve product names for each item in the order.
2025-11-11 09:50:18 +01:00
Jeppe Bundgaard 72c028c0fd Prevent editing of bookings with associated transactions
- Added transaction check in `orderBookingRoute` to block edits on bookings tied to transactions.
- Introduced `hasTransaction` method in `order_bookings_o` to verify transaction association.
2025-11-11 08:04:13 +01:00
Jeppe Bundgaard 5333d430c4 Add conditional check for self-request in userRoute and fix customer_number type in orderBookingRoute
- Updated `getUserId` logic in `userRoute` to allow users to fetch their own user ID without requiring additional permissions.
- Corrected `customer_number` type in `orderBookingRoute` to always return an array.
2025-11-10 17:11:29 +01:00
Jeppe Bundgaard a6d427e3d3 Enhance error handling in productsRoute for customer retrieval
- Added exception handling with logging when fetching customer by ID fails.
- Improved safety checks to ensure customer existence before returning the object.
- Return `null` in case of failure to prevent unhandled errors.
2025-11-10 16:59:41 +01:00
Jeppe Bundgaard a519478788 Implement wash certificate handling for bookings and order processing
- Added functionality to create and attach wash certificates during booking completion.
- Enhanced `completeBooking` to generate and associate wash certificates with orders based on booking items.
- Updated safety seal parameter handling in relevant methods.
- Integrated wash certificate PDF generation with customer branding and order attachment logic.
- Improved file retrieval logic in the `file_server` to handle missing certificates via alternative store lookup.
2025-11-10 15:45:24 +01:00
Jeppe Bundgaard af70b11ad4 Fix logical issue in null value checks for db_object_t where clause construction
- Corrected conditional logic to handle 'is null' string case.
2025-11-10 12:34:40 +01:00
Jeppe Bundgaard ed7ace3a1b Update completeBooking method TODO to include price re-calculation for customer-specific adjustments 2025-11-10 12:13:38 +01:00
Jeppe Bundgaard ad55e97b54 Refactor completeBooking method call and add method skeleton in order_bookings_o
- Updated `completeBooking` method call to directly use `$user->id` without `value()` extraction.
- Added `completeBooking` method skeleton in `order_bookings_o` with placeholders for future implementation.
2025-11-10 12:09:22 +01:00
Jeppe Bundgaard d53dd7645b Add POST route for completing order bookings with authentication and permissions
- Introduced `/order-bookings/complete` route to allow marking bookings as complete.
- Implemented authentication checks and department-level access control.
- Added response handling for successful completion or non-existing bookings.
- Commented out Slack notification in machine button press route for future review.
2025-11-10 12:03:04 +01:00
Jeppe Bundgaard b76c4deaa9 Add notification functionality for new order bookings
- Implemented `onAfterNewBooking` and `notifyNewBooking` methods to handle post-booking notifications.
- Added Slack and SMS notifications for departments upon creating new bookings.
- Enhanced error handling and logging for failed encoding and notification delivery.
- Updated `db_object_t` to JSON encode objects and arrays before database operations.
2025-11-10 11:46:22 +01:00
Jeppe Bundgaard 76483313ec Add DELETE route for deleting order bookings with permission checks
- Introduced `/order-bookings` DELETE route to enable deletion of order bookings.
- Implemented robust permission checks for deleting own and departmental bookings.
- Included detailed access control and error handling for unauthorized operations.
- Ensured proper success and error response handling.
2025-11-10 11:05:52 +01:00
Jeppe Bundgaard c0b6ed6972 Add order_id handling in orderBookingRoute
- Added `order_id` extraction logic with validation in `getTargetOrderId` method.
- Included `order_id` in the data update process for order bookings.
- Updated `order_bookings_o` class to support `order_id` property.
2025-11-10 10:31:57 +01:00
Jeppe Bundgaard 7c7cb03641 Relax minimum length requirement for orderBookingRoute parameters to allow empty strings 2025-11-05 15:44:49 +01:00
Jeppe Bundgaard 6013288d05 Refactor orderBookingRoute parameter handling and validation
- Added optional `required` parameter to `getTarget*` methods for flexible parameter validation.
- Improved null handling and safety checks in parameter extraction processes.
- Enhanced error handling for non-existing order bookings with proper response codes.
- Fixed logical operator issue in permission checks for customer number validation.
2025-11-05 15:13:01 +01:00
Jeppe Bundgaard 7f3089f086 Refactor orderBookingRoute parameter extraction and data update logic
- Added default parameter `false` to all `getTarget*` methods for enhanced flexibility.
- Improved conditional checks before constructing update data array with `isset` for null safety.
- Enhanced parameter validation by ensuring customer number is not empty during permission checks.
2025-11-05 14:22:24 +01:00
Jeppe Bundgaard 0f1efd9306 Implement update functionality in /order-bookings PUT route
- Added parameter extraction and validation for updating order bookings.
- Enhanced permission checks for editing own and departmental bookings.
- Implemented detailed access control logic based on user permissions.
- Built logic for updating booking details with strict type handling.
2025-11-05 14:14:18 +01:00
Jeppe Bundgaard 50a1e5a7df Add PUT route for editing order bookings with permissions
- Introduced a new `/order-bookings` PUT route to enable editing of existing bookings.
- Added permission `edit_bookings` for access control.
- Adjusted parameter type handling with explicit casting for validation.
2025-11-05 14:03:03 +01:00
Jeppe Bundgaard b564d8d500 Add order bookings functionality with permissions and access control
- Introduced `order_bookings_o` class for interacting with the `order_bookings` database table.
- Added `hasDepartmentAccess` method to handle department-level permissions.
- Implemented new routes for creating and retrieving order bookings, including pagination support.
- Enhanced access control to differentiate between own and departmental bookings based on permissions.
- Updated input validation and improved error handling for order bookings.
2025-11-05 13:57:12 +01:00
Jeppe Bundgaard f206e7f4fb Add JSON type support in object property handling
- Added `json` to the list of valid types for object properties.
- Implemented JSON decoding for column values when the type is `json`.
2025-11-05 13:16:31 +01:00
Jeppe Bundgaard 0180523539 Add orderBookingRoute class for handling order bookings
- Introduced a new `orderBookingRoute` to process and validate order booking data.
- Added methods for parameter validation, customer and department identification, and item verification.
- Implemented functionality to handle booking details such as notes, PO numbers, pickup preferences, and datetime inputs.
2025-11-05 12:34:16 +01:00
Jeppe Bundgaard 6f1fc86656 Fix typo in collected order invoice logic comments 2025-11-04 16:58:52 +01:00
Jeppe Bundgaard fbce187787 Add Writerside-based API Reference setup for Bookings_OpenAPIv1
- Introduced new Writerside configuration files and topics for API documentation.
- Added build profiles, variables, and categories setup.
- Created API topics covering various endpoints including bookings, user operations, and administrative tasks.
2025-11-04 16:58:05 +01:00
Jeppe Bundgaard bfed2f231a Add new free subscription addon for "Undervognsskyld pr. enhed" in invoice collection logic 2025-11-04 13:53:01 +01:00
Jeppe Bundgaard dbc96fd0b4 Remove attribute for all associated customers if customer number exists; prevent re-adding exception in invoice collection logic. 2025-11-04 10:29:34 +01:00
Jeppe Bundgaard 6814dcd904 Update booking status logic based on wash certificate conditions
- Ensure `status` is set to `completed` if wash certificate PDF exists but status is not already `completed`.
- Update `washCertificateStatus` to `completed` when `status` is `completed` and it is initially `pending`.
- Adjust `wash_certificate_pdf` and `status` logic in the returned booking object.
2025-10-28 12:32:43 +01:00
Jeppe Bundgaard af6b89ff54 Enhance authentication logic for customers with default passwords
- Added a check to ensure customers with group ID other than 0 cannot use default passwords.
- Implemented logic to auto-set passwords to the last 4 digits of the customer number if no password is set.
- Updated method documentation to include an `@throws Exception` annotation.
2025-10-28 11:06:18 +01:00
Jeppe Bundgaard d06f0cedc3 Add new properties and routes for product and booking enhancements
- Added `virtual_cart` property in `bookings_o` and enhanced its structure method.
- Introduced `display_in_booking_form` and `order_priority` properties in `products_o` with updates to object structure, parsing, and routes.
- Enabled handling of product attributes `display_in_booking_form` and `order_priority` in `productsRoute`.
- Added `booked_invoice_id` reset logic in `collected_order_invoices_o`.
- Introduced `machineButtonPressRoute` to log button press incidents and send Slack notifications.
2025-10-28 09:58:29 +01:00
Jeppe Bundgaard 30b94e89d7 Add PO number support and enhance permissions for order management
- Introduced `po` property in `orders_o` for handling Purchase Order (PO) numbers, including API integration for retrieval and validation.
- Enhanced customer permissions to allow limited order editing (`po` updates) and attachment downloads for their own orders.
- Added new helper methods to `users_o` for attributes like `showPricesOnBookingPage` and `usePONumbers`.
- Improved order item listing logic with distinct permissions for customers' own orders and price visibility.
- Implemented numeric value casting in filters within `db_object_t`.
2025-10-22 11:38:35 +02:00
Jeppe Bundgaard b78d9e0e63 Add email blacklist check to prevent sending to specific addresses
- Added a static blacklist in `sendEmailMailerSend` to skip sending emails to blacklisted addresses.
- Implemented a return condition if the recipient email matches the blacklist.
2025-10-21 08:39:36 +02:00
Jeppe Bundgaard c83aa23312 Add department lanes object and API routes
- Created `department_lanes_o` object to handle department lane operations and data.
- Introduced `/department/lanes` routes for listing, adding, and updating department lanes.
- Integrated user permission checks and logging for route actions.
- Included pagination and filtering capabilities for data retrieval.
2025-10-16 09:42:26 +02:00
Jeppe Bundgaard 3e30505cec Add new debug routes for Worker to integrate Shelly API functionality
- Introduced `/worker/debug`, `/worker/debug/on`, and `/worker/debug/off` routes for testing Shelly device states and switch operations.
- Updated routes to handle device state retrieval and switching using the Shelly API with improved error messaging for disabled endpoints.
2025-10-15 13:21:54 +02:00
Jeppe Bundgaard c775ca7b19 Expand Shelly module capabilities with POST requests and device switch management
- Updated `shelly` class to support POST request handling (`sendPostRequest`) and server URL validation.
- Adjusted `shelly_device_state` to handle object-based `status` and `settings`, adding a `populate` method for data initialization.
- Added `shelly_device_switch` helper to manage switching operations via Shelly API.
- Removed unused `api_url` property in `shelly` class.
- Modified `shelly_i` interface with definitions for `requireValidServerUrl` and `sendPostRequest`.
2025-10-15 13:08:27 +02:00
Jeppe Bundgaard e82b4950b7 Integrate Shelly module with new routes, classes, helpers, and configurations
- Added `shelly` class to manage API operations, handle requests, and validate configurations.
- Introduced `shelly_i` interface and supporting helpers: `shelly_device_state`, `shelly_request_body_get_states`, and `shelly_response_body_get_states`.
- Created new routes for fetching and updating Shelly configurations (`/shelly/config`).
- Added Shelly module configurations: `enabled`, `secret_key`, and `server_url`.
- Implemented `shelly_c` for module setup and configuration handling.
- Integrated Shelly initialization in `index.php`.
2025-10-15 10:54:01 +02:00
Jeppe Bundgaard c97d0e3d39 Add attachment listing to orders API response 2025-10-13 15:38:54 +02:00
Jeppe Bundgaard ce9913429f Integrate caching for CVR lookup, add economic customer creation endpoint, and enhance license plate recognition validation
- Implemented Redis caching for CVR lookups to improve performance and reduce API calls.
- Introduced economic customer creation functionality with new `createCustomer` method and corresponding route.
- Enhanced license plate recognition validation to handle plates shorter than 3 characters.
2025-10-13 13:32:11 +02:00
Jeppe Bundgaard ca29ded6be Integrate Virkdata module with new routes, helpers, and configurations
- Added `virkdata` class to handle API operations for company information retrieval and config validation.
- Introduced `virkdata_i` interface and supporting helpers: `virkdata_request_parameters`, `virkdata_response`, and enums for formats, countries, and error codes.
- Implemented new routes: `/worker/debug`, `/worker/licenseplates`, `/cvr/lookup`, and `/economic/doesCustomerExist`.
- Added module `Virkdata` route for searching company data and fetching/updating configurations (`moduleVirkDataRoute`).
- Created `virkdata` module configurations: `enabled`, `secret_key`, and `monthly_limit`.
- Integrated virkdata initialization in `index.php`.
2025-10-12 12:50:57 +02:00
Jeppe Bundgaard 6f68713c7a Comment out invoiceAllOrdersIndividually attribute initialization in users_o 2025-10-08 12:53:15 +02:00
Jeppe Bundgaard c6713f6865 Return newly added customer note as array in API response
- Updated `addNote` in `users_o` to return the `customer_notes_o` object.
- Modified `customerNotes` endpoint to include note details in the success response.
- Introduced `asArray` method in `customer_notes_o` for structured API responses.
2025-10-07 23:41:57 +02:00
Jeppe Bundgaard 276ad2154f Add customer search method with filters and pagination to endpoint
- Introduced `search` method in `economic_customers_endpoint` to retrieve customers based on filters and pagination parameters.
- Enhanced response handling with JSON decoding for structured data retrieval.
2025-10-06 16:38:11 +02:00
Jeppe Bundgaard f59852375f Refactor department handling in invoice drafting and order retrieval
- Simplified department retrieval in `economic_invoice_draft.php` by streamlining logic for default department usage.
- Enhanced `getDepartmentByOrderId` in `orders_o` to ensure correct department is fetched based on given `order_id`.
- Updated discount line logic to leverage appropriate department dimension values.
2025-10-06 12:28:35 +02:00
Jeppe Bundgaard fbbcf7e85d Add collective subscription price aggregation and department distribution parsing
- Enhanced `getTransactionsWithItemsNotIncludedInInvoices` to aggregate total subscription prices and calculate department-based distribution.
- Added processing to parse department IDs into human-readable names.
- Updated response to include aggregated subscription results under `collective_subscription_results`.
2025-10-01 19:13:18 +02:00
Jeppe Bundgaard 13ee541d57 Prevent environmental and oil fees for customer 999 with onlyTankCleaning attribute 2025-10-01 16:38:27 +02:00
Jeppe Bundgaard 8e6ad68253 Add environmental and oil fee calculation to invoice drafts
- Introduced `add_environmental_and_oil_fees` in `economic_invoices_draft_endpoint` to compute and add fees to drafts.
- Added `addEnvironmentalAndOilFeesToDraft` in `collected_order_invoices_o` to conditionally apply fees for customers with the `onlyTankCleaning` attribute.
2025-10-01 16:04:01 +02:00
Jeppe Bundgaard ed8a6454a6 Introduce subscription fallback mechanisms for vehicles with no transactions
- Added `attemptSubscriptionFallbacks` method in `InvoicingPeriodRoute` to handle vehicle subscription fallbacks through department-based strategies.
- Enhanced `customer_vehicles_o` with `getLastTransactions` for retrieving recent transactions.
- Updated `users_o` to support nullable return type for `getDefaultDepartment`.
2025-10-01 15:30:56 +02:00
Jeppe Bundgaard 86acc3a183 Add invoicing distribution endpoints and subscription processing features
- Introduced new endpoints for invoicing distribution: `/superuser/invoicing/period/distribution/fixed-pricing` and `/superuser/invoicing/period/distribution/wash-subscriptions`.
- Enhanced `customer_vehicles_o` with `getSubscriptionAppliedTransactionsFromList` method for transaction filtering based on subscriptions.
- Added `getNetAmountForOrderItemsOriginal` to `orders_o` for calculating the original net amount of order items.
- Introduced parsing utilities for department-based aggregation in invoicing.
- Extended `products_o` with `getSubscriptionMonthlyPrice` to calculate subscription pricing.
- Added `getFieldsWhereIn` to `db_object_t` for advanced database querying.
2025-10-01 10:21:58 +02:00
Jeppe Bundgaard 69625c4fe3 Ensure requireSelected is called in getEconomicCustomerDiscountPercentage 2025-09-30 15:55:04 +02:00
Jeppe Bundgaard e69d328105 Add xlvask_parser_afstr_mning helper for handling drainage-related product parsing
- Introduced the `xlvask_parser_afstr_mning.php` class extending `xlvask_product_parser`.
- Updated `xlvask_helpers.php` to include the new parser.
2025-09-30 15:54:43 +02:00
Jeppe Bundgaard dfc7738a62 Add handheld order processing indicator and caching functionality
- Introduced `is_handheld` field in order creation to identify orders from handheld devices.
- Added logic to set, cache, and expire pending handheld orders automatically at midnight.
- Enhanced `orders_o` class with `setPendingHandheldIndicator` and `isPendingHandheld` methods.
- Updated order processing flow to include `pending_handheld` indicator in responses.
2025-09-25 12:33:09 +02:00
Jeppe Bundgaard 4c7084ee7b Invalidate order cache on updates and adjust delete logic for order_items_o
- Added `objectChanged()` to notify the order object when items are updated or deleted.
- Refactored `delete()` method to ensure the order is informed before executing the database query.
2025-09-24 13:00:38 +02:00