Commit Graph
455 Commits
Author SHA1 Message Date
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
Jeppe Bundgaard 11ac183fb1 Add support for tracking last submitted form and booking object
- Introduced `last_submitted_form` and `form_submission` properties in the `form` class to retain details of the most recently submitted form.
- Updated form submission logic to assign `booking_object` where applicable.
- Enhanced response in `formRoute.php` to include booking data when available.
2025-09-23 16:04:35 +02:00
Jeppe Bundgaard 8604cf39de Add /worker/licenseplates route to retrieve unique license plate statistics
- Introduced new endpoint `/worker/licenseplates` to fetch and analyze distinct license plates from multiple database tables.
- Added functionality to format license plates by removing non-alphanumeric characters and converting them to uppercase.
- Integrated response to include counted plates and total unique plates.
- Improved database query logic to handle multiple tables and columns for license plate retrieval.
2025-09-23 09:14:34 +02:00
Jeppe Bundgaard 09fbbc11bb Add support for handling /files/ requests and temp file attachments in file_server.php
- Updated `file_server.php` to mark files with `temp_file_` in their name as attachments.
- Enhanced routing logic in `index.php` to load `file_server.php` for `/files/` requests.
2025-09-22 17:29:05 +02:00
Jeppe Bundgaard 9d47d98cd6 Add preview support for attachments in file_server.php
- Introduced `preview` query parameter to enable inline file display.
- Adjusted content headers to differentiate between preview and download modes.
- Improved file name handling by removing query strings from URLs.
2025-09-22 13:20:41 +02:00
Jeppe Bundgaard 538aa24dc7 Add order attachments module
- Implemented CRUD operations for order attachments, including adding, listing, downloading, and deleting.
- Updated `db_object_t` and `attachments` to enhance object-attachment interactions with new methods for formatting, creating, and managing attachments.
- Added new routes (`/orders/attachments` and `/attachments/upload`) for attachment-related functionality.
- Adjusted `file_server.php` to handle temp file downloads and attachment storage.
- Improved typing and error handling across attachment helper methods and classes.
2025-09-22 12:31:53 +02:00
Jeppe Bundgaard 33a26cffc5 Implement attachments module with CRUD operations and integration points
- Added `attachments` module for creating, reading, updating, and deleting attachments.
- Introduced new classes such as `attachments`, `attachment_store`, `attachment_content`, and `attachment_relation` to handle attachment operations and their relationships.
- Integrated `attachments` features into `db_object_t` for seamless object-attachment interactions.
- Added `attachments_i` interface for standardized attachments module operations.
- Created `attachmentsRoute` for defining endpoints related to attachments.
- Enabled module configuration through `attachments_enabled_c` for attachment management control.
2025-09-22 10:28:22 +02:00
Jeppe Bundgaard 94bbf0a106 Enhance vehiclesRoute to include customer status checks for known vehicles
- Added logic to determine if a known vehicle has been assigned to a specific customer and retrieve the customer name.
- Integrated checks to handle barred customers by resetting vehicle status to `unknown` and clearing customer details.
- Ensured support for scenarios with multiple known customers, marking vehicles accordingly.
2025-09-18 10:13:29 +02:00
Jeppe Bundgaard e1a5618888 Refactor productsRoute response generation logic to support single-product retrieval and optimize price parsing. 2025-09-17 12:11:25 +02:00
Jeppe Bundgaard 102605f15b Add support for dynamic pricing in productsRoute
- Introduced methods to apply customer-specific discounts and department-based pricing to products and addons.
- Enhanced `productsRoute` to handle optional parameters (`customer_id`, `department_id`, `category`, `id`) for tailored pricing and filtering.
- Updated response generation to include adjusted prices for both products and options based on customer and department context.
- Added helper methods to streamline parameter validation and parsing in `productsRoute`.
- Extended `products_o` to support discount application logic for customer pricing.
2025-09-17 09:59:05 +02:00
Jeppe Bundgaard b87950654b Clarify comment formatting in vehiclesRoute to improve readability. 2025-09-15 15:38:07 +02:00
Jeppe Bundgaard 9ee486a49e Add /vehicles/search route for vehicle registration search
- Introduced a new route `/vehicles/search` to enable searching for vehicles by registration number across multiple categories (e.g., verified, known, booked, unknown).
- Added validation for search parameters, including length and format checks.
- Ensured proper classification of vehicles with clear prioritization and deduplication logic.
- Implemented helper methods to retrieve matching registrations from various sources like bookings, orders, and scanned plates.
- Enhanced response format to include vehicle status, customer details, and references for improved usability.
2025-09-15 15:09:36 +02:00
Jeppe Bundgaard 5b00e47276 Add /vehicles/status route to retrieve vehicle status details
- Introduced a new route `/vehicles/status` to provide detailed vehicle status, including verification, booking, and last order information.
- Added `getLastOrderByPlate` method in `customer_vehicles_o` to retrieve the last order for a vehicle plate.
- Implemented validation for registration number and optional department parameter.
- Enhanced response with multiple status indicators like `verified`, `known`, `booked`, and `card`.
2025-09-15 11:58:32 +02:00
Jeppe Bundgaard c8006bf3bd Add change-password endpoint to user security routes
- Introduced `/account/security/change-password` route to handle password updates.
- Enforced user login and required parameters (`current_password`, `new_password`) for validation.
- Added password validation logic, including constraints on old and new password similarities.
- Integrated logging and detailed error handling for invalid sessions, passwords, and operations.
- Updated user model to support secure password changes.
2025-09-15 09:10:06 +02:00
Jeppe Bundgaard 2dbf318df0 Improve vehicle type determination in xlvask_parser_stor_bil
- Integrated `customer_vehicles_o` to validate vehicle type using customer-based data.
- Added fallback logic in `selectByPlate` to handle exceptions gracefully.
- Enhanced `checkMotorAPI` error handling by returning `false` instead of throwing exceptions.
2025-09-08 13:06:52 +02:00
Jeppe Bundgaard d14316e249 Improve vehicle type determination in xlvask_parser_stor_bil
- Integrated `customer_vehicles_o` to validate vehicle type using customer-based data.
- Added fallback logic in `selectByPlate` to handle exceptions gracefully.
- Enhanced `checkMotorAPI` error handling by returning `false` instead of throwing exceptions.
2025-09-04 14:50:39 +02:00
Jeppe Bundgaard c85c0d824c Extend License Plate Recognizer module with usage info endpoint and enhanced API handling
- Added `get_usage` method in `licenseplaterecognizer` to retrieve module usage statistics from the API.
- Introduced `licenseplaterecognizer_info` class to parse and manage API response data.
- Enhanced API request handling with updated default `api_url` and improved error handling.
- Refined cURL implementation for consistent API interaction.
2025-09-04 12:05:49 +02:00
Jeppe Bundgaard 9ee4cf5ac8 Add water usage calculation to department daily reports
- Introduced `getTransactionsOnDateWaterUsage` method in `department_daily_reports_o` to calculate water usage based on transactions for a given date or date range.
- Updated department daily reports routes to include `water_usage` in the output.
2025-09-03 14:54:30 +02:00
Jeppe Bundgaard 97c448b5b6 Add is_wash field to products and support wash statistics in reports
- Introduced `is_wash` field to `products_o` for marking wash-related products.
- Updated `productsRoute` to handle `is_wash` in product creation and editing.
- Added `getTransactionsOnDateWashesCount` method in `department_daily_reports_o` for calculating wash-related transactions in reports.
- Adjusted department daily reports routes to include wash statistics output.
2025-09-03 14:03:02 +02:00
Jeppe Bundgaard 3dca3c8a24 Add support for date range in department daily reports
- Introduced optional `date_to` parameter across relevant routes and methods for handling date ranges in department daily reports.
- Added `getDate_to` method and refactored date validation logic into `validateDateLocally` for reuse and reduced redundancy.
- Updated SQL queries in `department_daily_reports_o` to support date range queries using `BETWEEN`.
- Enhanced error handling and parameter validation for date-related inputs.
- Cleaned up comments and redundant code for improved readability.
2025-09-03 12:52:03 +02:00
Jeppe Bundgaard c2a5bad0a8 Improve error handling for draft invoice lines and refine invoice collection logic
- Added detailed error handling in `economic_invoices_draft_endpoint` to throw exceptions with line-specific error messages when adding draft invoice lines fails.
- Removed unnecessary `echo` statement from `orderInvoicesRoute`.
- Updated `collected_order_invoices_o` to allow empty invoice collections for customers with fixed price agreements.
2025-09-02 15:49:39 +02:00
Jeppe Bundgaard 6e539a92d6 Remove deprecated scanner test endpoint in moduleScannerRoute
- Deleted the `/modules/scanner/test` route, including unused cURL implementation and base64 image logic.
- Cleaned up related comments and redundant code.
- Updated comments to reflect future usage plans with OpenAI integration.
2025-09-01 10:12:30 +02:00
Jeppe Bundgaard 81aa406fb6 Add License Plate Recognizer integration and vehicle product suggestion route
- Implemented `licensePlateRecognizer` module with configuration classes (`enabled`, `api_key`) and API handling.
- Introduced `moduleConfigRoute` endpoints for fetching and updating `licensePlateRecognizer` configurations.
- Added `vehicleProductSuggestionRoute` with logic to fetch product suggestions based on vehicle plates.
- Extended `moduleScannerRoute` with license plate recognition test and exception handling.
- Updated `index.php` to include `licensePlateRecognizer` class.
2025-09-01 10:11:37 +02:00
Jeppe Bundgaard 7a852f5b54 Add nullable return types and improve exception handling in MotorAPI
- Updated `getCachedResult` methods across `motorapi`, `motorapi_i`, and `motorapi_lookups_o` to return `?object` for nullable results.
- Enhanced error handling in `xlvask_parser_stor_bil` by wrapping `getLicensePlateInformation` in a try-catch block to handle API exceptions gracefully.
- Introduced `cleanJSON` method in `motorapi` to sanitize and validate JSON data, ensuring robust parsing of cached responses.
- Optimized `getCachedResult` logic to handle null and invalid JSON scenarios with detailed error reporting.
2025-08-31 13:33:10 +02:00
Jeppe Bundgaard c95116f2c9 Add float type support and SQL handling for float values in object properties
- Included `float` as a valid type in type validation.
- Added SQL update logic for handling float values in object properties.
2025-08-27 08:40:24 +02:00
Jeppe Bundgaard 455cd14f22 Add latitude and longitude properties to departments
- Introduced `latitude` and `longitude` properties in `departments_o` for geographic data support.
- Updated department routes to handle latitude/longitude in responses and parameter updates.
- Adjusted serialization and object creation to include new properties.
2025-08-26 16:47:36 +02:00
Jeppe Bundgaard 5f400e1dd0 Add advanced invoice handling, cached result lookups, and customer-specific pricing
- Enhanced `orderInvoicesRoute` with `reset`, `unlink`, and `remove-special-arrangements` handlers for invoice actions, improving E-Conomic integration.
- Added `resetPricesOfItemsNotIncludedInInvoice`, `setAllItemsToBeIncludedInInvoice`, and `unlinkFromEconomic` methods in `collected_order_invoices_o` for robust invoice control.
- Introduced `getCustomerProductPrice` in `orders_o` to calculate customer-specific product pricing with discounts.
- Added `getCachedResultsBySubstring` in `motorapi_lookups_o` for efficient cached lookup based on result substrings.
2025-08-25 15:59:03 +02:00
Jeppe Bundgaard 2721ef6620 Update product options defaults and include price in output array
- Set default values for `min` and `max` when null (`0` and `-1` respectively).
- Added `price` property to the output array for enhanced product data completeness.
2025-08-19 14:19:52 +02:00
Jeppe Bundgaard a0fd41fba1 Add image upload support, file handling improvements, and OpenAI integration
- Introduced `uploadRoute` to handle image uploads with MIME type validation and size restrictions.
- Added `upload_store` class for managing file storage and generating presigned URLs for upload/download.
- Enhanced file server to differentiate between PDFs and uploaded files, supporting dynamic content delivery.
- Integrated OpenAI module for License Plate Recognition (LPR), including API configuration and schema validation.
- Updated core structure with new interfaces (`minio_uploads_i`, `openai_i`) and classes (`openai`, `upload_store`).
- Adjusted `index.php` and file routes to support dynamic MIME checks and direct link generation.
2025-08-18 16:50:30 +02:00
Jeppe Bundgaard 841062bfca Add product IDs to category array and update product count calculation 2025-08-13 17:21:51 +02:00
Jeppe Bundgaard f281b1c4d6 Skip orders without registration number and simplify order queries for department-based filtering 2025-08-07 12:19:15 +02:00
Jeppe Bundgaard abd21e0ad7 Add OCR processing integration and module scanner routes
- Implemented `get_ocr_result` method in the `ocr_space` class to interact with the OCR Space API.
- Added `process_ocr` method to `image_processor_t` for handling OCR logic.
- Updated interfaces (`ocr_space_i` and `image_processor_i`) to support OCR functionality.
- Introduced `moduleScannerRoute` with endpoints for testing and license plate recognition workflows.
- Included data validation and exception handling for OCR processing.
2025-08-06 15:19:43 +02:00
Jeppe Bundgaard 69ceafcce6 Add OCR Space module with configuration and image processing support
- Introduced `ocrSpace` module with classes: `ocr_space`, `ocrSpace_c`, and configuration objects for `enabled` and `api_key`.
- Added routes for fetching and updating OCR Space configuration.
- Created `image_processor` class and interface for handling and processing base64-encoded images.
- Integrated new traits and classes for image validation and processing.
- Updated `index.php` to include `ocr_space` and `image_processor`.
2025-08-06 10:27:39 +02:00
Jeppe Bundgaard f98ca5f199 Update getTransactionsForCustomersInDateRange to include exception handling for invalid date ranges and no transactions found 2025-08-04 11:47:29 +02:00
Jeppe Bundgaard c397c20ea7 Refactor discount calculation and integrate MotorAPI checks in XL Vask module
- Updated `orders_o` to use `round` for consistent discounted price calculations.
- Refined `xlvask_parser_stor_bil` with MotorAPI-based vehicle type validation and added `checkMotorAPI` method.
- Optimized `motorapi_lookups_o` license plate validation to streamline database queries.
2025-07-29 15:13:09 +02:00
Jeppe Bundgaard e449b25092 Add Certbot Service with Dockerfile and Adjust Nginx Config Path
- Added `services/certbot/Dockerfile` for Certbot configuration with Ubuntu 22.04.
- Set up volumes, dependencies, and command for automatic certificate renewal.
- Corrected Nginx configuration file path in `services/nginx/Dockerfile`.
2025-07-29 10:52:36 +02:00
Jeppe Bundgaard f5ba9dd891 Add product discount calculation and update handling for dynamic usage logs
- Introduced `getProductDiscountPercentage` method to calculate accurate discounts for users across products, categories, and global settings.
- Adjusted `importUsageLogs` to refine date modifier parameter and enhance `usage log` checks.
- Enhanced `orders_o` to include product discount logic with stricter type casting for consistency.
- Added `updateFieldsWhere` method for selective database updates based on specific conditions.
- Updated `customers_o` to handle updates for existing customers while adding new ones.
2025-07-23 09:31:43 +02:00
Jeppe Bundgaard 16198f49e6 Refactor XL Vask module for better null handling and primary item validation
- Improved null safety by updating product ID retrieval logic in parsers and usage logs.
- Enhanced primary wash item selection with stricter checks for valid product types.
- Adjusted import date modifier in `importUsageLogs` for extended range (`-7 day`).
- Streamlined product and user association in order creation with additional validations.
- Removed redundant checks and refined permission handling in import tasks.
2025-07-21 16:47:05 +02:00
Jeppe Bundgaard 4cc270e258 Refactor order creation to use addArray method and sanitize inputs
- Introduced `addArray` method in `orders_o` for streamlined order creation using an associative array.
- Updated `ordersRoute` to utilize `addArray`, replacing older implementation for better manageability.
- Improved input handling by trimming whitespaces from registration numbers.
- Enhanced product pricing by incorporating department-specific prices and discount percentages.
2025-07-21 13:10:15 +02:00