Compare commits

..

45 Commits

Author SHA1 Message Date
joelthomastrenser 70bce90865 Merge branch 'feature-file-management' into feature 2026-05-22 17:21:03 +05:30
joelthomastrenser a32e5b07ae Merge branch 'feature-notification-management' into feature 2026-05-22 15:47:57 +05:30
joelthomastrenser 1a77e85daa Merge branch 'feature-admin-management' into feature 2026-05-22 14:19:36 +05:30
Avinash Rajesh dd738be4de Add standardized documentation headers 2026-05-22 12:59:36 +05:30
joelthomastrenser 401a5d8369 Merge branch 'feature-payment-management' into feature 2026-05-22 12:47:18 +05:30
joelthomastrenser 80e860bd12 Merge branch 'feature-inventory-management' into feature 2026-05-22 12:37:34 +05:30
joelthomastrenser 9eaf81ca3d Merge branch 'feature-service-management' into feature 2026-05-22 12:28:53 +05:30
joelthomastrenser ba5f96c22d Implement serialization/deserialization and persistent storage across services
- Add serialize/deserialize support for core models
- Add file-based load/save functions in management services
- Introduce FileManager, Config, Utility and helper utilities
- Persist observer IDs for notification services
- Resolve object relationships during load (services, bookings, invoices, job cards)
- Add controller-level loadSystemData/saveSystemData
- Load data at app startup and save on shutdown
2026-05-22 12:13:17 +05:30
Avinash Rajesh 6ca659c573 Add standardized documentation headers 2026-05-22 11:27:49 +05:30
Avinash Rajesh 7e9cc27f1c Merge branch 'feature-inventory-management-inv004' into feature-inventory-management 2026-05-21 20:14:03 +05:30
Avinash Rajesh 1377d5fb39 Merge branch 'feature-inventory-management-inv003' into feature-inventory-management 2026-05-21 20:11:55 +05:30
Avinash Rajesh d33f0aa8dc Merge branch 'feature-inventory-management-inv002' into feature-inventory-management 2026-05-21 20:09:53 +05:30
Avinash Rajesh 337fb00e1f Merge branch 'feature-admin-management-menu' into feature-admin-management 2026-05-21 19:41:39 +05:30
Avinash Rajesh 33a3677f6e Merge branch 'feature-admin-management-adm007' into feature-admin-management 2026-05-21 19:22:52 +05:30
Avinash Rajesh 3a8db0cdae Merge branch 'feature-admin-management-adm006' into feature-admin-management 2026-05-21 19:16:50 +05:30
Avinash Rajesh 7c993521a2 Merge branch 'feature-admin-management-adm005' into feature-admin-management 2026-05-21 19:10:58 +05:30
Avinash Rajesh ef2fa6d521 Merge branch 'feature-admin-management-adm004' into feature-admin-management 2026-05-21 19:06:44 +05:30
Avinash Rajesh c8647eedd9 Merge branch 'feature-admin-management-adm003' into feature-admin-management 2026-05-21 19:02:57 +05:30
Avinash Rajesh 665d9192fa Merge branch 'feature-admin-management-adm002' into feature-admin-management 2026-05-21 18:55:23 +05:30
Jissin Mathew 0adb864329 Merge branch 'feature-service-management-ser005' into feature-service-management 2026-05-21 18:34:12 +05:30
Jissin Mathew a3ad4d2e00 Merge branch 'feature-payment-management-pay003' into feature-payment-management 2026-05-21 18:11:09 +05:30
Jissin Mathew 86fd32bd2b Merge branch 'feature-service-management-ser004' into feature-service-management 2026-05-21 17:26:27 +05:30
Jissin Mathew fceb1cbec6 Merge branch 'feature-service-management-ser003' into feature-service-management 2026-05-21 17:10:53 +05:30
Jissin Mathew 53ff70a85f Merge branch 'feature-service-management-ser002' into feature-service-management 2026-05-21 16:54:07 +05:30
Jissin Mathew 4a4309d585 Merge branch 'feature-payment-management-pay002' into feature-payment-management 2026-05-21 16:20:42 +05:30
Jissin Mathew 61f70a54f6 Implement Generate Invoice
<UserStory> PAY001: Generate Invoice </UserStory>

<Changes>
    1. Added Utility.h to project configuration for supporting invoice generation utilities.
    2. Updated Invoice model to use string-based keys for parts mapping instead of integer keys.
    3. Implemented PaymentManagementService::generateInvoice to aggregate labour cost, parts cost, and apply discounts.
    4. Integrated invoice creation with Factory to instantiate Invoice objects and persist them into datastore.
    5. Enhanced Enums with PaymentMode::NOTSET to handle default invoice state.
</Changes>

<Test>

 Acceptance Criteria:
 1. Invoice auto-generates for each service booking once jobs are completed.
 2. Invoice shows a clear breakdown of charges including labour cost, parts cost, discount, and total amount.

 Precondition:
  1. Service booking exists with at least one service and required inventory items.
  2. Datastore is available for storing invoices.
  3. Payment mode and status enums are properly configured.

 Steps:
  1. Complete all jobs in a service booking.
    - Verify that PaymentManagementService::generateInvoice is triggered.
  2. Check datastore for newly created invoice.
    - Verify that invoice contains booking ID, labour cost, parts cost, discount, and total amount.
  3. Inspect invoice details.
    - Verify that breakdown of charges is accurate and discount is applied correctly.
  4. Confirm invoice status.
    - Verify that invoice is created with PaymentMode::NOTSET and PaymentStatus::PENDING.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 16:05:10 +05:30
Avinash Rajesh d161ac313c Implement Change Password Functionality
<UserStory> ADM005: Change Password </UserStory>

<Changes>
    1. Added AuthenticationManagementService::changePassword to update the authenticated user’s password with validation.
    2. Integrated Controller::changePassword to delegate password update requests to AuthenticationManagementService.
    3. Enhanced AdminMenu::changePassword to prompt for new password, validate strength using Validator, and confirm update.
    4. Added error handling to prevent password change when no user is logged in.
    5. Provided user feedback messages for invalid password attempts and successful updates.
</Changes>

<Test>

  Precondition:
  1. Admin is logged into the system.
  2. AuthenticationManagementService maintains active session.
  3. Validator is available for password strength checks.

  Steps:
  1. Navigate to Admin Menu and select "Change Password".
  2. Enter old password incorrectly.
    - Verify that system rejects the attempt and displays error.
  3. Enter new password that fails validation (length/complexity).
    - Verify that system rejects with "Error: Password is not strong enough!".
  4. Enter valid old password and strong new password.
    - Verify that system confirms "Password changed successfully" and updates the user’s password.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:12:16 +05:30
Jissin Mathew 461857f971 Implement View Invoices for Customer
<UserStory> PAY003: View Invoices </UserStory>

<Changes>
    1. Added CustomerMenu::viewInvoices to fetch invoices via Controller and display them to the customer.
    2. Implemented displayInvoices helper to show invoice details including booking, vehicle, technician, discount, total amount, invoice date, and payment status.
    3. Enhanced invoice display to include a tabular breakdown of inventory items (ItemName, Quantity, Price) used in the service.
    4. Updated ServiceBooking to store assigned technician as a const User* for richer technician details in invoice output.
</Changes>

<Test>

 Acceptance Criteria:
 1. Invoice details should show total cost and discounts.
 2. Invoice details should show list of parts used.

 Precondition:
  1. Customer is logged into the system.
  2. At least one invoice exists for the customer in the datastore.
  3. Inventory items are linked to the invoice.

 Steps:
  1. Navigate to Customer menu and choose "View Invoices".
    - Verify that the system lists invoice details including booking ID, vehicle info, technician, discount, total amount, invoice date, and payment status.
  2. Check the parts list under each invoice.
    - Verify that inventory items are displayed in tabular form with ItemName, Quantity, and Price.
  3. Confirm that discounts and total cost are shown correctly.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 15:09:16 +05:30
Avinash Rajesh fa08d4a90f Implement Login Functionality
<UserStory> ADM003: Login </UserStory>

<Changes>
    1. Added credential input handling in UserInterface::login with username and password prompts.
    2. Integrated Controller::login to validate credentials and retrieve authenticated user.
    3. Implemented role-based menu navigation: Admin → AdminMenu, Technician → TechnicianMenu, Customer → CustomerMenu.
    4. Added error handling for invalid credentials and unknown user types with clear feedback messages.
    5. Included util::clear for screen refresh and structured output formatting during login.
</Changes>

<Test>

  Precondition:
  1. Valid user accounts exist in the system (Admin, Technician, Customer).
  2. Controller is connected to UserManagementService for authentication.
  3. UserInterface is initialized with role-specific menus.

  Steps:
  1. Launch UserInterface and select "Login".
  2. Enter incorrect username or password.
    - Verify that system displays "Error: Invalid Username or Password".
  3. Enter valid admin credentials.
    - Verify that AdminMenu is displayed successfully.
  4. Enter valid technician or customer credentials.
    - Verify that TechnicianMenu or CustomerMenu is displayed accordingly.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:09:04 +05:30
Jissin Mathew cb3bed4050 Implement Complete Payments
<UserStory> PAY002: Complete Payments </UserStory>

<Changes>
    1. Integrated Controller with PaymentManagementService to support payment completion workflow.
    2. Implemented PaymentManagementService::completePayment with validation for invoice ID, payment mode, and status update.
    3. Enhanced CustomerMenu with helper functions to display pending invoices in tabular format and allow index-based selection.
    4. Added CustomerMenu::selectPaymentMode to capture payment mode choice (OFFLINE/ONLINE).
    5. Updated CustomerMenu::completePayments to handle invoice selection, payment mode input, and trigger payment completion via Controller.
    6. Implemented notification logic to send confirmation to customers upon successful payment.
</Changes>

<Test>

 Acceptance Criteria:
 1. Payment status marked completed.
 2. Confirmation message shown.
 3. Confirmation notification sent.

 Precondition:
  1. Customer is logged into the system.
  2. At least one pending invoice exists for the customer.
  3. Datastore is available for storing invoices and updating payment status.

 Steps:
  1. Navigate to Customer menu and choose "Complete Payments".
    - Verify that the system lists pending invoices with tabular details.
  2. Select an invoice by index.
    - Verify that the chosen invoice is retrieved correctly.
  3. Enter payment mode (OFFLINE/ONLINE).
    - Verify that the selected mode is applied to the invoice.
  4. Confirm payment completion.
    - Verify that the invoice status changes to COMPLETED.
    - Verify that a confirmation message is displayed.
    - Verify that a notification is sent to the customer.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 15:08:25 +05:30
Avinash Rajesh b230e3062c Implement Remove Customer or Technician Functionality
<UserStory> ADM002: Remove Technician or Customer </UserStory>

<Changes>
    1. Integrated UserManagementService and ServiceManagementService into Controller for user removal operations.
    2. Added Controller::removeUser to validate user existence, cancel related service bookings and technician jobs, and mark user inactive.
    3. Updated JobCard and ServiceBooking models to use util::ServiceJobStatus consistently and store technician references as User* instead of strings.
    4. Extended util::ServiceJobStatus enum with PENDING and CANCELLED states, including string conversion support.
    5. Implemented ServiceManagementService methods to cancel customer service bookings and technician jobs, with inventory restocking and notifications.
    6. Enhanced AdminMenu::removeUser to list active users, validate index input, confirm deletion, and invoke Controller::removeUser.
    7. Added helper functions in AdminMenu to filter active users and display them with formatted output including user type.
</Changes>

<Test>

  Precondition:
  1. Admin is logged into the system.
  2. Technician accounts exist in the system.
  3. Technician has active job assignments.

  Steps:
  1. Navigate to Admin Menu and select "Remove User".
  2. System displays list of active users with IDs, usernames, and user types.
    - Verify that inactive users are excluded from the list.
  3. Admin selects technician ID for removal.
    - Verify that system confirms deletion before proceeding.
  4. Technician is removed from job assignment list.
    - Verify that associated jobs are cancelled, inventory is restocked, and notifications are sent.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:07:25 +05:30
Avinash Rajesh 2bdf0eb741 Implement Add Technician Functionality
<UserStory> ADM001: Add Technician </UserStory>

<Changes>
    1. Added UserManagementService integration in Controller to support technician account creation.
    2. Updated Controller::createTechnician method to call createUser with util::UserType::TECHNICIAN.
    3. Renamed parameter from 'phone' to 'phoneNumber' for clarity and consistency.
    4. Enhanced AdminMenu::addTechnician with input validation for password, email, and phone number.
    5. Added success and error handling messages in AdminMenu for technician creation workflow.
</Changes>

<Test>

  Precondition:
  1. Admin is logged into the system.
  2. UserManagementService is available and connected.
  3. No existing technician account with the same username/email.

  Steps:
  1. Navigate to Admin Menu and select "Add Technician".
  2. Enter technician details (username, password, email, phone number).
    - Verify that invalid password/email/phone inputs are rejected with error messages.
  3. Enter valid technician details.
    - Verify that uniqueness is checked and duplicate accounts are not created.
  4. Submit valid details.
    - Verify that technician account is created successfully and confirmation message is displayed.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:06:32 +05:30
Avinash Rajesh ef41fec208 Implement Check Availability Status Functionality
<UserStory> INV004: Check Availability Status </UserStory>

<Changes>
    1. Updated Controller to delegate getInventoryItem calls to InventoryManagementService.
    2. Implemented InventoryManagementService::getInventoryItem to fetch items from datastore by ID.
    3. Enhanced AdminMenu with checkStockAvailability function:
       - Accepts part ID as input.
       - Retrieves item details from Controller.
       - Displays item information (ID, part name, quantity) if found and active.
       - Handles inactive or missing items gracefully.
</Changes>

<Test>

  Precondition:
  1. Admin user is logged into the system.
  2. Inventory contains multiple items with unique IDs.
  3. DataStore is initialized and accessible.

  Steps:
  1. Navigate to Admin Menu and select "Check Stock Availability".
    - Verify that the system prompts for an Item ID.
  2. Enter a valid Item ID for an active item.
    - Verify that the system displays the item’s details including current quantity.
  3. Enter an Item ID that does not exist.
    - Verify that the system displays “Item not found”.
  4. Enter an Item ID for an inactive item.
    - Verify that the system does not display details and indicates the item is inactive.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:04:37 +05:30
Avinash Rajesh 3594fa4f26 Implement Remove Stock Functionality
<UserStory> INV003: Remove Stock </UserStory>

<Changes>
    1. Integrated InventoryManagementService into Controller to handle removal of inventory items.
    2. Implemented InventoryManagementService::removeInventoryItem to mark items as INACTIVE in the datastore.
    3. Enhanced AdminMenu with removeInventoryItem workflow:
       - Displays inventory list with index, ID, part name, quantity, and price.
       - Allows admin to select item by index for removal.
       - Provides confirmation message after successful deletion.
    4. Added static helper function displayInventoryWithItems in AdminMenu for modularized inventory display.
</Changes>

<Test>

  Precondition:
  1. Admin user is logged into the system.
  2. Inventory contains multiple items with unique IDs.
  3. DataStore is initialized and accessible.

  Steps:
  1. Navigate to Admin Menu and select "Remove Inventory Item".
    - Verify that the system displays all inventory items with ID, part name, quantity, and price.
  2. Select an item by entering its index.
    - Verify that the system removes the item and displays a confirmation message.
  3. Attempt to remove an item with an invalid index.
    - Verify that the system rejects the input and shows an error message.
  4. Navigate to "View Stock Levels".
    - Verify that the removed item no longer appears in the inventory list.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:03:03 +05:30
Jissin Mathew 8162a2fe3d Implement Update Service Status
<UserStory> SER005: Update Service Status </UserStory>

<Changes>
    1. Integrated Controller with ServiceManagementService to support job completion workflow.
    2. Implemented ServiceManagementService::completeJob with validation for technician assignment, job existence, and status transition.
    3. Enhanced TechnicianMenu with job selection helper to display assigned jobs, allow index-based selection, and handle invalid choices.
    4. Updated TechnicianMenu::completeJob to mark job as completed via Controller and provide user feedback.
    5. Added logic to check if all jobs in a booking are completed, triggering invoice generation and customer notification.
</Changes>

<Test>

 Acceptance Criteria:
 1. Status updates are visible to customers immediately after technician marks job as completed.

 Precondition:
  1. Technician is logged into the system.
  2. At least one active job card is assigned to the technician.
  3. Datastore contains valid service bookings linked to jobs.

 Steps:
  1. Navigate to Technician menu and choose "Complete Job".
    - Verify that the system lists active jobs with index-based selection.
  2. Select a job card by index.
    - Verify that the job status changes from STARTED to COMPLETED.
  3. Check customer view.
    - Verify that the updated status is reflected in the customer’s booking history.
  4. If all jobs in the booking are completed:
    - Verify that an invoice is generated and a notification is sent to the customer.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 15:02:46 +05:30
Avinash Rajesh 6a8b845efa Implement Add Stock functionality
<UserStory> INV002: Add Stock </UserStory>

<Changes>
    1. Added Controller integration with InventoryManagementService to support adding new inventory items and updating existing stock quantities.
    2. Implemented InventoryManagementService::addInventoryItem to create new items via Factory and insert them into the DataStore.
    3. Implemented InventoryManagementService::addInventoryItemStock to update stock quantities for existing items.
    4. Enhanced AdminMenu with options to add new items or update stock quantities, including input validation and confirmation messages.
    5. Added helper functions in AdminMenu to display inventory items and handle quantity updates interactively.
    6. Included necessary headers (InventoryItem, Factory, iomanip) for new functionality.
</Changes>

<Test>

  Precondition:
  1. Admin user is logged into the system.
  2. Inventory contains existing items with unique IDs.
  3. DataStore is accessible and initialized.

  Steps:
  1. Navigate to Admin Menu and select "Add Inventory Item".
    - Verify that the system prompts for part name, quantity, and price.
  2. Enter details for a new item with a unique part name and ID.
    - Verify that the item is successfully added and a confirmation message is displayed.
  3. Attempt to add an item with a duplicate ID.
    - Verify that the system rejects the duplicate and displays an error message.
  4. Select "Add Quantity" option for an existing item.
    - Verify that the system updates the stock quantity and displays the new total in the confirmation message.
  5. Navigate to "View Stock Levels".
    - Verify that the updated stock quantity is reflected in the inventory list.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:00:59 +05:30
Jissin Mathew fc7bb2569b Implement View Service History
<UserStory> SER004: View Service History </UserStory>

<Changes>
    1. Added integration between Controller and ServiceManagementService to fetch service bookings by customer ID.
    2. Enhanced ServiceBooking model to store technician as a User* instead of a string for richer details.
    3. Implemented Controller::getServiceBookingsByUser to return a read-only map of bookings for safe access.
    4. Updated CustomerMenu::viewServiceHistory to display bookings in tabular format with aligned columns.
    5. Added condition check to show technician name if assigned, otherwise display "Not Assigned".
    6. Included booking status and discount percentage in the service history output.
</Changes>

<Test>

 Acceptance Criteria:
 1. System should fetch real-time status.
 2. Status should update automatically when technician changes it.
 3. Customer should be able to view history.

  Precondition:
  1. Customer is logged into the console application.
  2. At least one active service booking exists for the customer.
  3. Technician has permission to update booking status.

  Steps:
  1. Navigate to Customer menu and choose "View Service History".
    - Verify that the console displays current booking status along with technician assignment.
  2. Technician updates the status of a booking.
    - Verify that the console view reflects the updated status automatically.
  3. Customer views service history again.
    - Verify that the history shows the latest status changes.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 14:59:18 +05:30
Avinash Rajesh 9f882610b3 Implement View Stock Level Functionality
<UserStory> INV001: View Stock Level </UserStory>

<Changes>
    1. Integrated InventoryManagementService into Controller to provide read-only access to inventory items.
    2. Added implementation for InventoryManagementService::getInventoryItems to fetch data from DataStore.
    3. Enhanced AdminMenu with viewStockLevels functionality to display inventory details (ID, part name, quantity, price).
    4. Updated NotificationManagementService interface to provide concrete implementations for sendNotification, attach, detach, and notify methods.
    5. Included necessary headers (InventoryItem, InventoryManagementService, iomanip) for new functionality.
</Changes>

<Test>

  Precondition:
  1. Admin user is logged into the system.
  2. Inventory contains multiple items with varying stock levels.
  3. Notification service is active and users are registered.

  Steps:
  1. Navigate to Admin Menu and select "View Stock Levels".
    - Verify that the system displays all inventory items with ID, part name, quantity, and price.
  2. Check items with sufficient stock.
    - Verify that they are displayed normally without highlighting.
  3. Check items with low stock threshold.
    - Verify that these items are highlighted to indicate low availability.
  4. Trigger a notification for a low-stock item.
    - Verify that the notification is sent to registered users successfully.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 14:57:16 +05:30
Jissin Mathew 70e1ef66d4 Implement Remove Service for admin
<UserStory> SER003: Remove Service </UserStory>

<Changes>
    1. Added integration between Controller and ServiceManagementService to support service removal.
    2. Implemented ServiceManagementService::removeService with validation for service existence and marking as INACTIVE.
    3. Enhanced Controller::getServices to return a read-only map of services for safe UI access.
    4. Added AdminMenu::selectServicesToRemove helper to list active services in tabular format and capture user choice.
    5. Updated AdminMenu::removeService to prompt for service selection, delegate removal to Controller, and display success/failure messages.
</Changes>

<Test>

 Acceptance Criteria:
 1. Admin selects service ID.
 2. System confirms deletion.
 3. Service removed from customer menu.

  Precondition:
  1. Admin is logged into the system.
  2. At least one active service exists in the datastore.
  3. Customer menu displays available services.

  Steps:
  1. Navigate to Admin menu and choose "Remove Service".
    - Verify that the system lists active services in tabular format.
  2. Select a service ID from the list.
    - Verify that the system confirms deletion.
  3. Check customer menu.
    - Verify that the removed service no longer appears.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 14:54:33 +05:30
Jissin Mathew e7f1b51d05 Implement Create Service for admin
<UserStory> SER002: Create Service </UserStory>

<Changes>
    1. Added integration between Controller and ServiceManagementService to support service creation.
    2. Implemented ServiceManagementService::createService with validation for duplicate service IDs and insertion into datastore.
    3. Enhanced AdminMenu with selectInventoryItems helper to display inventory in tabular format, allow selection, and handle exit condition.
    4. Updated AdminMenu::createService to prompt for service name, allow inventory selection, capture labour cost, and create service via Controller.
</Changes>

<Test>

 Acceptance Criteria:
 1. Admin enters new service name.
 2. Admin selects required parts for the services.
 3. Service created and visible to customers.

  Precondition:
  1. Admin is logged into the system.
  2. Inventory contains at least one active item.
  3. Datastore is available for storing services.

  Steps:
  1. Navigate to Admin menu and choose "Create Service".
    - Verify that the system prompts for service name.
  2. Select inventory items from the tabular list.
    - Verify that inactive items are skipped and active items can be added.
  3. Enter labour cost and confirm creation.
    - Verify that the service is created successfully and stored in datastore.
  4. Check customer view.
    - Verify that the newly created service is visible to customers.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 14:51:59 +05:30
Jissin Sam Mathew 9b7d9cf7c1 Implement Assign Job to Technician functionality
<UserStory> SER001: Assign job to technician </UserStory>

<Changes>
    1. Added ServiceManagementService logic to retrieve service bookings and create job cards for assigned technicians.
    2. Added UserManagementService support to retrieve technicians by user type and fetch technician details by ID.
    3. Connected Controller methods with ServiceManagementService and UserManagementService for service booking retrieval, technician listing, and job card creation.
    4. Updated JobCard model to use util::ServiceJobStatus consistently and simplified constructor initialization for assigned and completion timestamps.
    5. Added PENDING status in ServiceJobStatus enum for identifying unassigned service bookings.
    6. Implemented AdminMenu job assignment flow to list pending service bookings, display available technicians, allow technician selection, and assign jobs for services in the booking.
    7. Added notification trigger during job card creation for assigned technicians.
</Changes>

<Test>

Job assignment functionality validation

Precondition:
1. System is running.
2. Pending service bookings are available in the system.
3. Technician users are available in the system.
4. Admin user is logged in and admin menu is active.

Steps:
1. Launch the application and log in as an admin.
2. Select the Assign Job option from the admin menu.
3. View the list of available pending service bookings.
   - Verify that pending bookings are displayed.
4. Select a valid service booking.
5. View the list of available technicians.
   - Verify that technicians are listed for selection.
6. Select a technician to assign the job.
   - Verify that job cards are created for services in the booking.
   - Verify that assigned jobs are visible in the technician’s menu.
   - Verify that a confirmation message is shown.
   - Verify that a confirmation notification is sent to the assigned technician.

</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 14:50:43 +05:30
Avinash Rajesh a6e19017ca Implement Create Combo Package Functionality
<UserStory> ADM006:Create Combo Package </UserStory>

<Changes>
    1. Added ServiceManagementService::createComboPackage to validate package name, included services, and discount percentage before creation.
    2. Integrated Controller::createComboPackage to delegate combo package creation to ServiceManagementService.
    3. Enhanced AdminMenu::createComboPackages to allow admin input for package name, service selection, and discount percentage.
    4. Implemented service validation to ensure only active services are selectable and that duplicate combos are prevented.
    5. Added formatted output for service listing with cost calculation and confirmation messages upon successful package creation.
</Changes>

<Test>

  Precondition:
  1. Admin is logged into the system.
  2. At least two active services exist in the system.
  3. ServiceManagementService is connected to DataStore for services and combo packages.

  Steps:
  1. Navigate to Admin Menu and select "Create Combo Package".
  2. Enter package name, select two active services, and provide discount percentage.
    - Verify that system validates service IDs and ensures discount is between 0 and 100.
  3. Attempt to create a package with invalid service IDs or duplicate services.
    - Verify that system rejects with appropriate error messages.
  4. Enter valid package details.
    - Verify that combo package is saved successfully and visible to customers.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 13:08:24 +05:30
Avinash Rajesh ab6eed5ee6 Implement Remove Combo Package for admin
<UserStory> SER003: Remove Combo Package </UserStory>

<Changes>

Added integration between Controller and ServiceManagementService to support combo package removal.

Implemented ServiceManagementService::removeComboPackage with validation for package ID and marking state as INACTIVE.

Enhanced AdminMenu with displayComboPackagesWithIndex helper to show packages in tabular format with index.

Updated AdminMenu::selectComboPackage to allow selection of active packages only and return selected package ID.

Updated AdminMenu::removeComboPackage to prompt for selection, confirm removal, and provide success/failure feedback.
</Changes>

<Test>

Acceptance Criteria:

Admin selects package ID.

System confirms deletion.

Package removed from customer menu.

Precondition:

Admin is logged into the system.

At least one active combo package exists.

Datastore is available for storing combo packages.

Steps:

Navigate to Admin menu and choose "Remove Combo Package".

Verify that the system displays available active packages in tabular format with index.

Select a package ID from the list.

Verify that inactive packages are skipped and only active ones are selectable.

Confirm removal.

Verify that the package is marked INACTIVE and removed from customer menu.

Check customer view.

Verify that the removed package is no longer visible to customers.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 12:44:00 +05:30
joelthomastrenser 454af1b4ef Implement Admin and Technician Menus
Changes:
  - Added Admin Menu display with menu options
  - Added Technician Menu display with menu options
  - Added menu choice handling using switch case
  - Connected menu options to corresponding functions
  - Added invalid choice message
  - Added logout handling
  - Added missing function declarations in TechnicianMenu header
2026-05-21 10:46:23 +05:30
Avinash Rajesh df769a7528 Implement Logout functionality
<UserStory> ADM004: Logout </UserStory>

<Changes>
    1. Added AuthenticationManagementService::logout to clear authenticated user session.
    2. Integrated logout handling in Controller::logout to delegate session termination.
    3. Updated AdminMenu::logout and TechnicianMenu::logout to call Controller::logout for consistent session management.
    4. Extended TechnicianMenu.h with logout method declaration.
    5. Ensured session termination returns control to main menu after logout.
</Changes>

<Test>

  Precondition:
  1. User is logged into the system (Admin or Technician).
  2. AuthenticationManagementService maintains active session.
  3. Controller is connected to AuthenticationManagementService.

  Steps:
  1. Navigate to Admin or Technician Menu.
  2. Select "Logout" option.
    - Verify that AuthenticationManagementService::logout clears authenticated user.
  3. Session is terminated.
    - Verify that system confirms logout and invalidates session.
  4. Console returns to main menu.
    - Verify that user is redirected to main menu and must log in again to continue.
</Test>

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 10:39:53 +05:30
35 changed files with 2567 additions and 1458 deletions
@@ -233,6 +233,12 @@
<ClInclude Include="models\ComboPackage.h"> <ClInclude Include="models\ComboPackage.h">
<Filter>Header Files\Models</Filter> <Filter>Header Files\Models</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="views\MenuHelper.h">
<Filter>Header Files\Views</Filter>
</ClInclude>
<ClInclude Include="utilities\Utility.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
<ClInclude Include="utilities\Config.h"> <ClInclude Include="utilities\Config.h">
<Filter>Header Files\Utilities</Filter> <Filter>Header Files\Utilities</Filter>
</ClInclude> </ClInclude>
@@ -245,11 +251,5 @@
<ClInclude Include="utilities\FileHelper.h"> <ClInclude Include="utilities\FileHelper.h">
<Filter>Header Files\Utilities</Filter> <Filter>Header Files\Utilities</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="utilities\Utility.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
<ClInclude Include="views\MenuHelper.h">
<Filter>Header Files\Views</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,22 +1,29 @@
/* /*
File: Controller.cpp File: Controller.cpp
Description: Implementation file containing the method definitions of the Description: Implementation file containing the method definitions
Controller class, including authentication, user creation, of the Controller class, which manages user authentication,
service purchasing, and system checks. inventory, services, bookings, and notifications.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#include <stdexcept>
#include "Controller.h" #include "Controller.h"
#include "ComboPackage.h"
#include "Enums.h" #include "Enums.h"
#include "InventoryItem.h"
#include "Invoice.h"
#include "JobCard.h"
#include "Service.h"
#include "ServiceBooking.h"
#include "User.h" #include "User.h"
#include "User.h"
#include <stdexcept>
/* /*
Function: login Function: login
Description: Authenticates a user by delegating to the authentication management service. Description: Authenticates a user based on provided credentials.
Parameter: const std::string& username - users username Parameter: const std::string& username - the username of the user
const std::string& password - users password const std::string& password - the password of the user
Return type: bool - true if login successful, false otherwise Return type: bool
*/ */
bool Controller::login(const std::string& username, const std::string& password) bool Controller::login(const std::string& username, const std::string& password)
{ {
@@ -25,7 +32,8 @@ bool Controller::login(const std::string& username, const std::string& password)
/* /*
Function: logout Function: logout
Description: Logs out the currently authenticated user. Description: Logs out the currently authenticated user by delegating
to the authentication management service.
Parameter: None Parameter: None
Return type: void Return type: void
*/ */
@@ -36,8 +44,9 @@ void Controller::logout()
/* /*
Function: changePassword Function: changePassword
Description: Changes the password of the currently authenticated user. Description: Updates the password of the authenticated user by delegating
Parameter: const std::string& newPassword - new password to set to the authentication management service.
Parameter: const std::string& newPassword - the new password to set
Return type: void Return type: void
*/ */
void Controller::changePassword(const std::string& newPassword) void Controller::changePassword(const std::string& newPassword)
@@ -45,44 +54,31 @@ void Controller::changePassword(const std::string& newPassword)
m_authenticationManagementService.changePassword(newPassword); m_authenticationManagementService.changePassword(newPassword);
} }
/*
Function: createCustomer
Description: Creates a new customer account with the provided details.
Parameter: const std::string& username - customers username
const std::string& name - customers name
const std::string& password - customers password
const std::string& email - customers email
const std::string& phone - customers phone number
Return type: void
*/
void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone) void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone)
{ {
m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER); m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER);
} }
/*
Function: getAuthenticatedUser
Description: Retrieves the currently authenticated user.
Parameter: None
Return type: const User* - pointer to the authenticated user
*/
const User* Controller::getAuthenticatedUser() const User* Controller::getAuthenticatedUser()
{ {
return m_authenticationManagementService.getAuthenticatedUser(); return m_authenticationManagementService.getAuthenticatedUser();
} }
void Controller::createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone)
{
}
/* /*
Function: updateUserDetails Function: createTechnician
Description: Updates the email and phone details of the currently authenticated user. Description: Creates a new technician account with provided details by
Parameter: const std::string& email - new email address delegating to the user management service.
const std::string& phone - new phone number Parameter: const std::string& username - technician's username
const std::string& password - technician's password
const std::string& email - technician's email address
const std::string& phoneNumber - technician's phone number
Return type: void Return type: void
*/ */
void Controller::createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phoneNumber)
{
m_userManagementService.createUser(username, name, password, email, phoneNumber, util::UserType::TECHNICIAN);
}
void Controller::updateUserDetails(const std::string& email, const std::string& phone) void Controller::updateUserDetails(const std::string& email, const std::string& phone)
{ {
User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser();
@@ -95,120 +91,258 @@ void Controller::updateUserDetails(const std::string& email, const std::string&
util::Map<std::string, const Service*> Controller::getServices() util::Map<std::string, const Service*> Controller::getServices()
{ {
return util::Map<std::string, const Service*>(); util::Map<std::string, Service*> currentServices = m_serviceManagementService.getServices();
} util::Map<std::string, const Service*> readOnlyServices;
for (int iterator = 0; iterator < currentServices.getSize(); iterator++)
util::Map<std::string, const ComboPackage*> Controller::getComboPackages() {
{ readOnlyServices.insert(currentServices.getValueAt(iterator)->getId(), currentServices.getValueAt(iterator));
return util::Map<std::string, const ComboPackage*>(); }
return readOnlyServices;
} }
/* /*
Function: purchaseService Function: getComboPackages
Description: Purchases one or more services for a vehicle by delegating to the service management service. Description: Retrieves all available combo packages from the service
Parameter: const util::Vector<std::string>& serviceIDs - IDs of services to purchase management service and constructs a read-only map.
const std::string& vehicleNumber - vehicle registration number Parameter: None
const std::string& vehicleBrand - brand of the vehicle Return type: util::Map<std::string, const ComboPackage*>
const std::string& vehicleModel - model of the vehicle
Return type: void
*/ */
util::Map<std::string, const ComboPackage*> Controller::getComboPackages()
{
util::Map<std::string, ComboPackage*> currentAvailableComboPackages = m_serviceManagementService.getComboPackages();
util::Map<std::string, const ComboPackage*> readOnlyComboPackages;
for (int iterator = 0; iterator < currentAvailableComboPackages.getSize(); iterator++)
{
ComboPackage* currentComboPackage = currentAvailableComboPackages.getValueAt(iterator);
if (currentComboPackage)
{
readOnlyComboPackages.insert(currentComboPackage->getId(), currentComboPackage);
}
}
return readOnlyComboPackages;
}
void Controller::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) void Controller::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{ {
m_serviceManagementService.purchaseService(serviceIDs, vehicleNumber, vehicleBrand, vehicleModel); m_serviceManagementService.purchaseService(serviceIDs, vehicleNumber, vehicleBrand, vehicleModel);
} }
/*
Function: purchaseComboPackage
Description: Purchases a combo package for a vehicle by delegating to the service management service.
Parameter: const std::string& comboPackageID - ID of the combo package
const std::string& vehicleNumber - vehicle registration number
const std::string& vehicleBrand - brand of the vehicle
const std::string& vehicleModel - model of the vehicle
Return type: void
*/
void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{ {
m_serviceManagementService.purchaseComboPackage(comboPackageID, vehicleNumber, vehicleBrand, vehicleModel); m_serviceManagementService.purchaseComboPackage(comboPackageID, vehicleNumber, vehicleBrand, vehicleModel);
} }
/*
Function: getInventoryItems
Description: Retrieves all inventory items from the inventory management service
and constructs a read-only map for external use.
Parameter: None
Return type: util::Map<std::string, const InventoryItem*>
*/
util::Map<std::string, const InventoryItem*> Controller::getInventoryItems() util::Map<std::string, const InventoryItem*> Controller::getInventoryItems()
{ {
return util::Map<std::string, const InventoryItem*>(); auto inventoryIems = m_inventoryManagementService.getInventoryItems();
util::Map<std::string, const InventoryItem*> readOnlyInventoryItems;
int inventoryItemsMapSize = inventoryIems.getSize();
for (int index = 0; index < inventoryItemsMapSize; index++)
{
readOnlyInventoryItems.insert(inventoryIems.getKeyAt(index), inventoryIems.getValueAt(index));
}
return readOnlyInventoryItems;
} }
/*
Function: getInventoryItem
Description: Retrieves a specific inventory item by its ID from the inventory management service.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: const InventoryItem*
*/
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID) const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
{ {
return nullptr; return m_inventoryManagementService.getInventoryItem(inventoryItemID);
} }
/*
Function: addInventoryItem
Description: Adds a new inventory item with specified details to the inventory management service.
Parameter: const std::string& partName - name of the part
int quantity - quantity of the part
double price - price of the part
Return type: void
*/
void Controller::addInventoryItem(const std::string& partName, int quantity, double price) void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
{ {
m_inventoryManagementService.addInventoryItem(partName, quantity, price);
} }
/*
Function: removeInventoryItem
Description: Removes an inventory item from the inventory management service by its ID.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: void
*/
void Controller::removeInventoryItem(const std::string& inventoryItemID) void Controller::removeInventoryItem(const std::string& inventoryItemID)
{ {
m_inventoryManagementService.removeInventoryItem(inventoryItemID);
}
/*
Function: addInventoryItemStock
Description: Adds stock to an existing inventory item in the inventory management service.
Parameter: const std::string& selectedItemId - ID of the inventory item
int quantity - quantity to add
Return type: void
*/
void Controller::addInventoryItemStock(const std::string& selectedItemId, int quantity)
{
m_inventoryManagementService.addInventoryItemStock(selectedItemId, quantity);
} }
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings() util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
{ {
return util::Map<std::string, const ServiceBooking*>(); auto serviceBookings = m_serviceManagementService.getServiceBookings();
util::Map<std::string, const ServiceBooking*> readOnlyServiceBookings;
for (int iterator = 0; iterator < serviceBookings.getSize(); iterator++)
{
readOnlyServiceBookings.insert(serviceBookings.getKeyAt(iterator), serviceBookings.getValueAt(iterator));
}
return readOnlyServiceBookings;
} }
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookingsByUser(const std::string userID) util::Map<std::string, const ServiceBooking*> Controller::getServiceBookingsByUser(const std::string userID)
{ {
return util::Map<std::string, const ServiceBooking*>(); util::Map<std::string, const ServiceBooking*> readOnlyServiceBookingsByUserMap;
util::Map<std::string, ServiceBooking*> currentServiceBookingsByUser = m_serviceManagementService.getServiceBookings(userID);
for (int iterator = 0; iterator < currentServiceBookingsByUser.getSize(); iterator++)
{
readOnlyServiceBookingsByUserMap.insert(currentServiceBookingsByUser.getValueAt(iterator)->getId(), currentServiceBookingsByUser.getValueAt(iterator));
}
return readOnlyServiceBookingsByUserMap;
} }
/*
Function: getUsers
Description: Retrieves all users from the user management service and
constructs a read-only map.
Parameter: None
Return type: util::Map<std::string, const User*>
*/
util::Map<std::string, const User*> Controller::getUsers() util::Map<std::string, const User*> Controller::getUsers()
{ {
return util::Map<std::string, const User*>(); auto listOfUsers = m_userManagementService.getUsers();
util::Map<std::string, const User*> readOnlyUserList;
for (int iterator = 0; iterator < listOfUsers.getSize(); iterator++)
{
readOnlyUserList.insert(listOfUsers.getKeyAt(iterator), listOfUsers.getValueAt(iterator));
}
return readOnlyUserList;
} }
util::Map<std::string, const User*> Controller::getUsers(util::UserType userType) util::Map<std::string, const User*> Controller::getUsers(util::UserType userType)
{ {
return util::Map<std::string, const User*>(); auto userMap = m_userManagementService.getUsers(userType);
util::Map<std::string, const User*> readOnlyUserMap;
for (int iterator = 0; iterator < userMap.getSize(); iterator++)
{
readOnlyUserMap.insert(userMap.getKeyAt(iterator), userMap.getValueAt(iterator));
}
return readOnlyUserMap;
} }
void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID) void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{ {
m_serviceManagementService.createJobCard(bookingID, technicianID, serviceID);
} }
void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost) void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{ {
m_serviceManagementService.createService(name, inventoryItemIDs, laborCost);
} }
void Controller::removeService(const std::string& serviceID) void Controller::removeService(const std::string& serviceID)
{ {
m_serviceManagementService.removeService(serviceID);
} }
util::Map<std::string, const JobCard*> Controller::getJobCardsByUser() util::Map<std::string, const JobCard*> Controller::getJobCardsByUser()
{ {
return util::Map<std::string, const JobCard*>(); const User* currentUser = getAuthenticatedUser();
auto jobCardsAssignedToTechnician = m_serviceManagementService.getJobCards(currentUser->getId());
util::Map<std::string, const JobCard*> readOnlyJobCardMap;
for (int iterator = 0; iterator < jobCardsAssignedToTechnician.getSize(); iterator++)
{
JobCard* currentJobCard = jobCardsAssignedToTechnician.getValueAt(iterator);
readOnlyJobCardMap.insert(currentJobCard->getId(), currentJobCard);
}
return readOnlyJobCardMap;
} }
void Controller::completeJob(const std::string& jobID) void Controller::completeJob(const std::string& jobID)
{ {
m_serviceManagementService.completeJob(jobID);
} }
/*
Function: removeUser
Description: Removes a user by ID. Cancels associated service bookings
and technician jobs before removing the user from the system.
Parameter: const std::string& userID - ID of the user to remove
Return type: void
*/
void Controller::removeUser(const std::string& userID) void Controller::removeUser(const std::string& userID)
{ {
User* user = m_userManagementService.getUser(userID);
if (!user)
{
throw std::runtime_error("Error User not Found.\n");
}
m_serviceManagementService.cancelCustomerServiceBookings(userID);
m_serviceManagementService.cancelTechnicianJobs(userID);
m_userManagementService.removeUser(userID);
} }
/*
Function: createComboPackage
Description: Creates a new combo package with specified services and discount
percentage by delegating to the service management service.
Parameter: const std::string& name - name of the combo package
const util::Vector<std::string>& serviceIDs - list of service IDs
double discountPercentage - discount percentage for the package
Return type: void
*/
void Controller::createComboPackage(const std::string& name, const util::Vector<std::string>& serviceIDs, double discountPercentage) void Controller::createComboPackage(const std::string& name, const util::Vector<std::string>& serviceIDs, double discountPercentage)
{ {
m_serviceManagementService.createComboPackage(name, serviceIDs, discountPercentage);
} }
/*
Function: removeComboPackage
Description: Removes a combo package by ID by delegating to the service
management service.
Parameter: const std::string& comboPackageID - ID of the combo package
Return type: void
*/
void Controller::removeComboPackage(const std::string& comboPackageID) void Controller::removeComboPackage(const std::string& comboPackageID)
{ {
m_serviceManagementService.removeComboPackage(comboPackageID);
} }
util::Map<std::string, const Invoice*> Controller::getInvoicesByUser() util::Map<std::string, const Invoice*> Controller::getInvoicesByUser()
{ {
return util::Map<std::string, const Invoice*>(); User* currentUser = m_authenticationManagementService.getAuthenticatedUser();
util::Map<std::string, Invoice*> currentUserInvoices = m_paymentManagementService.getInvoices(currentUser->getId());
util::Map<std::string, const Invoice*> userInvoicesReadOnly;
for (int iterator = 0; iterator < currentUserInvoices.getSize(); iterator++)
{
Invoice* currentInvoice = currentUserInvoices.getValueAt(iterator);
userInvoicesReadOnly.insert(currentInvoice->getId(), currentInvoice);
}
return userInvoicesReadOnly;
} }
void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode) void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
{ {
m_paymentManagementService.completePayment(invoiceID, paymentMode);
} }
/* /*
@@ -289,16 +423,6 @@ void Controller::configureNotifications(bool paymentNotifications, bool serviceN
} }
} }
/*
Function: loadSystemData
Description: Loads all system data from persistent storage into memory.
Invokes the respective management services to load users, inventory items, services,
combo packages, service bookings, job cards, invoices, and observers.
Parameters:
- None
Returns:
- void
*/
void Controller::loadSystemData() void Controller::loadSystemData()
{ {
m_userManagementService.loadUsers(); m_userManagementService.loadUsers();
@@ -313,16 +437,6 @@ void Controller::loadSystemData()
m_inventoryManagementService.loadObservers(); m_inventoryManagementService.loadObservers();
} }
/*
Function: saveSystemData
Description: Saves all system data from memory back to persistent storage.
Invokes the respective management services to save users, inventory items, services,
combo packages, service bookings, job cards, invoices, and observers.
Parameters:
- None
Returns:
- void
*/
void Controller::saveSystemData() void Controller::saveSystemData()
{ {
m_userManagementService.saveUsers(); m_userManagementService.saveUsers();
@@ -339,8 +453,9 @@ void Controller::saveSystemData()
/* /*
Function: runSystemChecks Function: runSystemChecks
Description: Runs system checks to ensure critical configurations, such as verifying admin existence. Description: Executes system checks including sending low stock alerts
Parameter: None and payment reminders.
Parameters: None
Return type: void Return type: void
*/ */
void Controller::runSystemChecks() void Controller::runSystemChecks()
@@ -1,8 +1,8 @@
/* /*
File: Controller.h File: Controller.h
Description: Header file declaring the Controller class, which coordinates Description: Header file declaring the Controller class, which manages
authentication, user management, service management, inventory, user authentication, inventory, services, bookings, job cards,
and notifications across the Vehicle Service System. invoices, and notifications in the system.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
@@ -15,10 +15,6 @@ Date:19-May-2026
#include "PaymentManagementService.h" #include "PaymentManagementService.h"
#include "ServiceManagementService.h" #include "ServiceManagementService.h"
#include "UserManagementService.h" #include "UserManagementService.h"
#include "InventoryManagementService.h"
#include "UserManagementService.h"
#include "ServiceManagementService.h"
#include "PaymentManagementService.h"
class Service; class Service;
class ComboPackage; class ComboPackage;
@@ -43,7 +39,7 @@ public:
void changePassword(const std::string& newPassword); void changePassword(const std::string& newPassword);
void createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone); void createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone);
const User* getAuthenticatedUser(); const User* getAuthenticatedUser();
void createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone); void createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phoneNumber);
void updateUserDetails(const std::string& email, const std::string& phone); void updateUserDetails(const std::string& email, const std::string& phone);
util::Map<std::string, const Service*> getServices(); util::Map<std::string, const Service*> getServices();
util::Map<std::string, const ComboPackage*> getComboPackages(); util::Map<std::string, const ComboPackage*> getComboPackages();
@@ -52,6 +48,7 @@ public:
util::Map<std::string, const InventoryItem*> getInventoryItems(); util::Map<std::string, const InventoryItem*> getInventoryItems();
const InventoryItem* getInventoryItem(const std::string& inventoryItemID); const InventoryItem* getInventoryItem(const std::string& inventoryItemID);
void addInventoryItem(const std::string& partName, int quantity, double price); void addInventoryItem(const std::string& partName, int quantity, double price);
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
void removeInventoryItem(const std::string& inventoryItemID); void removeInventoryItem(const std::string& inventoryItemID);
util::Map<std::string, const ServiceBooking*> getServiceBookings(); util::Map<std::string, const ServiceBooking*> getServiceBookings();
util::Map<std::string, const ServiceBooking*> getServiceBookingsByUser(const std::string userID); util::Map<std::string, const ServiceBooking*> getServiceBookingsByUser(const std::string userID);
@@ -56,19 +56,6 @@ ComboPackage::ComboPackage(const std::string& packageName, double discountPercen
} }
} }
/*
Function: ComboPackage (parameterized constructor with ID)
Description: Initializes a combo package with an existing ID, name, discount percentage,
service IDs, and state. Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique ID of the package
- packageName: const std::string&, name of the package
- discountPercentage: double, discount percentage applied
- serviceIDs: const util::Vector<std::string>&, IDs of services included
- status: util::State, state of the package (ACTIVE/INACTIVE)
Returns:
- A new ComboPackage object
*/
ComboPackage::ComboPackage(const std::string& id, const std::string& packageName, double discountPercentage, const util::Vector<std::string>& serviceIDs, util::State status) ComboPackage::ComboPackage(const std::string& id, const std::string& packageName, double discountPercentage, const util::Vector<std::string>& serviceIDs, util::State status)
: m_id(id), : m_id(id),
m_packageName(packageName), m_packageName(packageName),
@@ -225,14 +212,6 @@ void ComboPackage::setState(util::State status)
m_status = status; m_status = status;
} }
/*
Function: getServiceIDsAsString (static helper)
Description: Converts a vector of service IDs into a single string separated by '|'.
Parameters:
- serviceIDs: const util::Vector<std::string>&, vector of service IDs
Returns:
- std::string: Concatenated service IDs string
*/
static std::string getServiceIDsAsString(const util::Vector<std::string>& serviceIDs) static std::string getServiceIDsAsString(const util::Vector<std::string>& serviceIDs)
{ {
int numberOfServices = serviceIDs.getSize(); int numberOfServices = serviceIDs.getSize();
@@ -248,14 +227,6 @@ static std::string getServiceIDsAsString(const util::Vector<std::string>& servic
return serviceIDsString; return serviceIDsString;
} }
/*
Function: getServiceIDsAsVector (static helper)
Description: Converts a string of service IDs separated by '|' into a vector.
Parameters:
- serviceIDsString: const std::string&, concatenated service IDs string
Returns:
- util::Vector<std::string>: Vector of service IDs
*/
static util::Vector<std::string> getServiceIDsAsVector(const std::string& serviceIDsString) static util::Vector<std::string> getServiceIDsAsVector(const std::string& serviceIDsString)
{ {
util::Vector<std::string> serviceIDs; util::Vector<std::string> serviceIDs;
@@ -268,14 +239,6 @@ static util::Vector<std::string> getServiceIDsAsVector(const std::string& servic
return serviceIDs; return serviceIDs;
} }
/*
Function: serialize
Description: Serializes the combo package into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized combo package record
*/
std::string ComboPackage::serialize() const std::string ComboPackage::serialize() const
{ {
std::ostringstream serializedComboPackage; std::ostringstream serializedComboPackage;
@@ -287,16 +250,6 @@ std::string ComboPackage::serialize() const
return serializedComboPackage.str(); return serializedComboPackage.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a ComboPackage object.
Parameters:
- record: const std::string&, serialized combo package record
Returns:
- ComboPackage*: Pointer to the deserialized ComboPackage object
Throws:
- std::runtime_error if data is invalid
*/
ComboPackage* ComboPackage::deserialize(const std::string& record) ComboPackage* ComboPackage::deserialize(const std::string& record)
{ {
std::string id, packageName; std::string id, packageName;
@@ -327,14 +280,6 @@ ComboPackage* ComboPackage::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for combo package serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,PackageName,DiscountPercentage,ServiceIDs,Status")
*/
std::string ComboPackage::getHeaders() std::string ComboPackage::getHeaders()
{ {
return "ID,PackageName,DiscountPercentage,ServiceIDs,Status"; return "ID,PackageName,DiscountPercentage,ServiceIDs,Status";
@@ -8,9 +8,9 @@ Date: 19-May-2026
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include "InventoryItem.h"
#include "Factory.h" #include "Factory.h"
#include "StringHelper.h" #include "StringHelper.h"
#include "InventoryItem.h"
int InventoryItem::m_uid = 0; int InventoryItem::m_uid = 0;
@@ -47,19 +47,6 @@ InventoryItem::InventoryItem(const std::string& partName, int quantity, double p
m_status(util::State::ACTIVE), m_status(util::State::ACTIVE),
m_price(price) {} m_price(price) {}
/*
Function: InventoryItem (parameterized constructor with ID)
Description: Initializes an inventory item with an existing ID, part name, quantity,
price, and state. Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique ID of the item
- partName: const std::string&, name of the part
- quantity: int, quantity of the part
- price: double, price of the part
- status: util::State, state of the item (ACTIVE/INACTIVE)
Returns:
- A new InventoryItem object
*/
InventoryItem::InventoryItem(const std::string& id, const std::string& partName, int quantity, double price, util::State status) InventoryItem::InventoryItem(const std::string& id, const std::string& partName, int quantity, double price, util::State status)
: m_id(id), : m_id(id),
m_partName(partName), m_partName(partName),
@@ -204,14 +191,6 @@ void InventoryItem::setState(util::State status)
m_status = status; m_status = status;
} }
/*
Function: serialize
Description: Serializes the inventory item into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized inventory item record
*/
std::string InventoryItem::serialize() const std::string InventoryItem::serialize() const
{ {
std::ostringstream serializedInventoryItem; std::ostringstream serializedInventoryItem;
@@ -223,16 +202,6 @@ std::string InventoryItem::serialize() const
return serializedInventoryItem.str(); return serializedInventoryItem.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into an InventoryItem object.
Parameters:
- record: const std::string&, serialized inventory item record
Returns:
- InventoryItem*: Pointer to the deserialized InventoryItem object
Throws:
- std::runtime_error if data is invalid
*/
InventoryItem* InventoryItem::deserialize(const std::string& record) InventoryItem* InventoryItem::deserialize(const std::string& record)
{ {
std::string id, partName; std::string id, partName;
@@ -264,15 +233,7 @@ InventoryItem* InventoryItem::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for inventory item serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,PartName,Quantity,Price,Status")
*/
std::string InventoryItem::getHeaders() std::string InventoryItem::getHeaders()
{ {
return "ID,PartName,Quantity,Price,Status"; return "ID,PartName,Quantity,Price,Status";
} }
@@ -58,7 +58,8 @@ Invoice::Invoice(
const std::string& bookingId, const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
const util::Timestamp& invoiceDate, const util::Timestamp& invoiceDate,
double laborCost, const util::Map<std::string, double laborCost,
const util::Map<std::string,
InventoryItem*>& parts, InventoryItem*>& parts,
double partsCost, double partsCost,
double discountPercentage, double discountPercentage,
@@ -121,12 +122,6 @@ Invoice::Invoice(
} }
} }
/*
Function: getId
Description: Retrieves the unique ID of the invoice.
Returns:
- const std::string& representing the invoice ID.
*/
const std::string& Invoice::getId() const const std::string& Invoice::getId() const
{ {
return m_id; return m_id;
@@ -176,14 +171,6 @@ double Invoice::getLaborCost() const
return m_laborCost; return m_laborCost;
} }
/*
Function: getPartIDs
Description: Retrieves the IDs of parts used in the invoice.
Parameters:
- None
Returns:
- const util::Vector<std::string>&: Part IDs
*/
const util::Vector<std::string>& Invoice::getPartIDs() const const util::Vector<std::string>& Invoice::getPartIDs() const
{ {
return m_partIDs; return m_partIDs;
@@ -193,7 +180,7 @@ const util::Vector<std::string>& Invoice::getPartIDs() const
Function: getParts Function: getParts
Description: Retrieves the map of inventory items used in the service. Description: Retrieves the map of inventory items used in the service.
Returns: Returns:
- const util::Map<int, InventoryItem*>& representing the parts. - const util::Map<std::string, InventoryItem*>& representing the parts.
*/ */
const util::Map<std::string, InventoryItem*>& Invoice::getParts() const const util::Map<std::string, InventoryItem*>& Invoice::getParts() const
{ {
@@ -429,14 +416,6 @@ void Invoice::setStatus(util::PaymentStatus status)
m_status = status; m_status = status;
} }
/*
Function: getPartIDsAsString (static helper)
Description: Converts a vector of part IDs into a single string separated by '|'.
Parameters:
- partIDs: const util::Vector<std::string>&, vector of part IDs
Returns:
- std::string: Concatenated part IDs string
*/
static std::string getPartIDsAsString(const util::Vector<std::string>& partIDs) static std::string getPartIDsAsString(const util::Vector<std::string>& partIDs)
{ {
int numberOfParts = partIDs.getSize(); int numberOfParts = partIDs.getSize();
@@ -452,14 +431,6 @@ static std::string getPartIDsAsString(const util::Vector<std::string>& partIDs)
return partIDsString; return partIDsString;
} }
/*
Function: getPartIDsAsVector (static helper)
Description: Converts a string of part IDs separated by '|' into a vector.
Parameters:
- partIDsString: const std::string&, concatenated part IDs string
Returns:
- util::Vector<std::string>: Vector of part IDs
*/
static util::Vector<std::string> getPartIDsAsVector(const std::string& partIDsString) static util::Vector<std::string> getPartIDsAsVector(const std::string& partIDsString)
{ {
util::Vector<std::string> partIDs; util::Vector<std::string> partIDs;
@@ -472,14 +443,6 @@ static util::Vector<std::string> getPartIDsAsVector(const std::string& partIDsSt
return partIDs; return partIDs;
} }
/*
Function: serialize
Description: Serializes the invoice into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized invoice record
*/
std::string Invoice::serialize() const std::string Invoice::serialize() const
{ {
std::ostringstream serializedInvoice; std::ostringstream serializedInvoice;
@@ -497,16 +460,6 @@ std::string Invoice::serialize() const
return serializedInvoice.str(); return serializedInvoice.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into an Invoice object.
Parameters:
- record: const std::string&, serialized invoice record
Returns:
- Invoice*: Pointer to the deserialized Invoice object
Throws:
- std::runtime_error if data is invalid
*/
Invoice* Invoice::deserialize(const std::string& record) Invoice* Invoice::deserialize(const std::string& record)
{ {
std::string id, bookingId; std::string id, bookingId;
@@ -559,15 +512,7 @@ Invoice* Invoice::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for invoice serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,BookingID,InvoiceDate,LaborCost,PartIDs,PartsCost,DiscountPercentage,TotalAmount,PaymentDate,PaymentMethod,Status")
*/
std::string Invoice::getHeaders() std::string Invoice::getHeaders()
{ {
return "ID,BookingID,InvoiceDate,LaborCost,PartIDs,PartsCost,DiscountPercentage,TotalAmount,PaymentDate,PaymentMethod,Status"; return "ID,BookingID,InvoiceDate,LaborCost,PartIDs,PartsCost,DiscountPercentage,TotalAmount,PaymentDate,PaymentMethod,Status";
} }
@@ -40,8 +40,8 @@ public:
const std::string& bookingId, const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
const util::Timestamp& invoiceDate, const util::Timestamp& invoiceDate,
double laborCost, const util::Map<std::string, double laborCost,
InventoryItem*>& parts, const util::Map<std::string,InventoryItem*>& parts,
double partsCost, double partsCost,
double discountPercentage, double discountPercentage,
double totalAmount, double totalAmount,
@@ -1,12 +1,11 @@
/* /*
File: JobCard.cpp File: JobCard.cpp
Description: Implements the JobCard class which represents a technicians job assignment in the Vehicle Service Management System. Description: Implementation file containing the method definitions of the
Provides constructors, accessors, and mutators for job details such as ID, booking, service, technician, JobCard class, including constructors, getters, and setters
assigned date, completion date, and job status. for job card attributes.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include "JobCard.h" #include "JobCard.h"
@@ -34,19 +33,18 @@ JobCard::JobCard()
/* /*
Function: JobCard Function: JobCard
Description: Parameterized constructor that initializes a new job card with a unique ID and specified details. Description: Parameterized constructor that initializes a job card with
Parameters: booking, service, technician, and status details.
- bookingId: ID of the associated service booking. Parameter: const std::string& bookingId - ID of the booking
- booking: Pointer to the ServiceBooking object. ServiceBooking* booking - pointer to the booking object
- service: Pointer to the Service object. Service* service - pointer to the service object
- serviceId: ID of the associated service. const std::string& serviceId - ID of the service
- technicianId: ID of the assigned technician. const std::string& technicianId - ID of the technician
- technician: Pointer to the User object representing the technician. User* technician - pointer to the technician object
- assignedDate: Timestamp of when the job was assigned. const util::Timestamp& assignedDate - date when job was assigned
- status: Current status of the job (STARTED/COMPLETED). util::ServiceJobStatus status - current status of the job
- completionDate: Timestamp of when the job was completed. const util::Timestamp& completionDate - date when job was completed
Returns: Return type: Constructor
- A new JobCard object.
*/ */
JobCard::JobCard(const std::string& bookingId, JobCard::JobCard(const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
@@ -69,22 +67,6 @@ JobCard::JobCard(const std::string& bookingId,
m_status(status), m_status(status),
m_completionDate(completionDate) {} m_completionDate(completionDate) {}
/*
Function: JobCard (parameterized constructor with ID)
Description: Initializes a job card with an existing ID, booking ID, service ID,
technician ID, assignment date, completion date, and status.
Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique job card ID
- bookingId: const std::string&, ID of the booking
- serviceId: const std::string&, ID of the service
- technicianId: const std::string&, ID of the technician
- assignedDate: const util::Timestamp&, date of assignment
- status: util::ServiceJobStatus, job status
- completionDate: const util::Timestamp&, date of completion
Returns:
- A new JobCard object
*/
JobCard::JobCard(const std::string& id, JobCard::JobCard(const std::string& id,
const std::string& bookingId, const std::string& bookingId,
const std::string& serviceId, const std::string& serviceId,
@@ -201,9 +183,9 @@ const util::Timestamp& JobCard::getAssignedDate() const
/* /*
Function: getStatus Function: getStatus
Description: Retrieves the current status of the job. Description: Retrieves the current status of the job card.
Returns: Parameter: None
- ServiceJobStatus representing the job status. Return type: util::ServiceJobStatus
*/ */
util::ServiceJobStatus JobCard::getStatus() const util::ServiceJobStatus JobCard::getStatus() const
{ {
@@ -327,11 +309,9 @@ void JobCard::setAssignedDate(const util::Timestamp& assignedDate)
/* /*
Function: setStatus Function: setStatus
Description: Sets the current status of the job. Description: Sets the status of the job card.
Parameters: Parameter: util::ServiceJobStatus status - new job status
- status: New job status value. Return type: void
Returns:
- void
*/ */
void JobCard::setStatus(util::ServiceJobStatus status) void JobCard::setStatus(util::ServiceJobStatus status)
{ {
@@ -351,14 +331,6 @@ void JobCard::setCompletionDate(const util::Timestamp& completionDate)
m_completionDate = completionDate; m_completionDate = completionDate;
} }
/*
Function: serialize
Description: Serializes the job card into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized job card record
*/
std::string JobCard::serialize() const std::string JobCard::serialize() const
{ {
std::ostringstream serializedJobCard; std::ostringstream serializedJobCard;
@@ -372,16 +344,6 @@ std::string JobCard::serialize() const
return serializedJobCard.str(); return serializedJobCard.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a JobCard object.
Parameters:
- record: const std::string&, serialized job card record
Returns:
- JobCard*: Pointer to the deserialized JobCard object
Throws:
- std::runtime_error if timestamp parsing fails
*/
JobCard* JobCard::deserialize(const std::string& record) JobCard* JobCard::deserialize(const std::string& record)
{ {
std::string id, bookingId, serviceId, technicianId; std::string id, bookingId, serviceId, technicianId;
@@ -417,14 +379,6 @@ JobCard* JobCard::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for job card serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate")
*/
std::string JobCard::getHeaders() std::string JobCard::getHeaders()
{ {
return "ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate"; return "ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate";
@@ -1,13 +1,14 @@
/* /*
File: JobCard.h File: JobCard.h
Description: Declares the JobCard class which represents a technicians job assignment in the Vehicle Service Management System. Description: Header file declaring the JobCard class, which represents
Each job card includes booking details, associated service, technician information, assigned and completion dates, and job status. a service job card containing booking, service, technician,
and status details.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h"
#include "Timestamp.h" #include "Timestamp.h"
#include "Enums.h" #include "Enums.h"
@@ -29,7 +30,6 @@ private:
util::Timestamp m_assignedDate; util::Timestamp m_assignedDate;
util::ServiceJobStatus m_status; util::ServiceJobStatus m_status;
util::Timestamp m_completionDate; util::Timestamp m_completionDate;
public: public:
JobCard(); JobCard();
JobCard(const std::string& bookingId, JobCard(const std::string& bookingId,
@@ -45,19 +45,6 @@ Notification::Notification(const std::string& recipientUserId, User* recipient,
m_message(message), m_message(message),
m_createdAt(createdAt) {} m_createdAt(createdAt) {}
/*
Function: Notification (parameterized constructor with ID)
Description: Initializes a notification with an existing ID, recipient details,
title, message, and creation timestamp. Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique notification ID
- recipientUserId: const std::string&, ID of the recipient user
- title: const std::string&, notification title
- message: const std::string&, notification message
- createdAt: const util::Timestamp&, timestamp of creation
Returns:
- A new Notification object
*/
Notification::Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt) Notification::Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt)
: m_id(id), : m_id(id),
m_recipientUserId(recipientUserId), m_recipientUserId(recipientUserId),
@@ -217,14 +204,6 @@ void Notification::setCreatedAt(const util::Timestamp& createdAt)
m_createdAt = createdAt; m_createdAt = createdAt;
} }
/*
Function: serialize
Description: Serializes the notification into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized notification record
*/
std::string Notification::serialize() const std::string Notification::serialize() const
{ {
std::ostringstream serializedNotification; std::ostringstream serializedNotification;
@@ -236,16 +215,6 @@ std::string Notification::serialize() const
return serializedNotification.str(); return serializedNotification.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a Notification object.
Parameters:
- record: const std::string&, serialized notification record
Returns:
- Notification*: Pointer to the deserialized Notification object
Throws:
- std::runtime_error if timestamp parsing fails
*/
Notification* Notification::deserialize(const std::string& record) Notification* Notification::deserialize(const std::string& record)
{ {
std::string id, recipientUserId, title, message, createdAtTimestampString; std::string id, recipientUserId, title, message, createdAtTimestampString;
@@ -273,14 +242,6 @@ Notification* Notification::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for notification serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,RecipientID,Title,Message,Timestamp")
*/
std::string Notification::getHeaders() std::string Notification::getHeaders()
{ {
return "ID,RecipientID,Title,Message,Timestamp"; return "ID,RecipientID,Title,Message,Timestamp";
@@ -54,19 +54,6 @@ Service::Service(const std::string& name, const util::Map<std::string, Inventory
} }
} }
/*
Function: Service (parameterized constructor with ID)
Description: Initializes a service with an existing ID, name, inventory item IDs,
labor cost, and state. Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique service ID
- name: const std::string&, name of the service
- requiredInventoryItemIDs: const util::Vector<std::string>&, IDs of required inventory items
- laborCost: double, labor cost of the service
- status: util::State, state of the service (ACTIVE/INACTIVE)
Returns:
- A new Service object
*/
Service::Service(const std::string& id, const std::string& name, const util::Vector<std::string>& requiredInventoryItemIDs, double laborCost, util::State status) Service::Service(const std::string& id, const std::string& name, const util::Vector<std::string>& requiredInventoryItemIDs, double laborCost, util::State status)
: m_id(id), : m_id(id),
m_name(name), m_name(name),
@@ -103,14 +90,6 @@ const std::string& Service::getName() const
return m_name; return m_name;
} }
/*
Function: getRequiredInventoryItemIDs
Description: Retrieves the IDs of required inventory items for the service.
Parameters:
- None
Returns:
- const util::Vector<std::string>&: Inventory item IDs
*/
const util::Vector<std::string>& Service::getRequiredInventoryItemIDs() const const util::Vector<std::string>& Service::getRequiredInventoryItemIDs() const
{ {
return m_requiredInventoryItemIDs; return m_requiredInventoryItemIDs;
@@ -221,14 +200,6 @@ void Service::setState(util::State status)
m_status = status; m_status = status;
} }
/*
Function: getInventoryItemIDsAsString (static helper)
Description: Converts a vector of inventory item IDs into a single string separated by '|'.
Parameters:
- inventoryItemIds: const util::Vector<std::string>&, vector of inventory item IDs
Returns:
- std::string: Concatenated inventory item IDs string
*/
static std::string getInventoryItemIDsAsString(const util::Vector<std::string>& inventoryItemIds) static std::string getInventoryItemIDsAsString(const util::Vector<std::string>& inventoryItemIds)
{ {
int numberOfInventoryItems = inventoryItemIds.getSize(); int numberOfInventoryItems = inventoryItemIds.getSize();
@@ -244,14 +215,6 @@ static std::string getInventoryItemIDsAsString(const util::Vector<std::string>&
return inventoryItemIDs; return inventoryItemIDs;
} }
/*
Function: getInventoryItemIDsAsVector (static helper)
Description: Converts a string of inventory item IDs separated by '|' into a vector.
Parameters:
- inventoryItemIDsString: const std::string&, concatenated inventory item IDs string
Returns:
- util::Vector<std::string>: Vector of inventory item IDs
*/
static util::Vector<std::string> getInventoryItemIDsAsVector(const std::string& inventoryItemIDsString) static util::Vector<std::string> getInventoryItemIDsAsVector(const std::string& inventoryItemIDsString)
{ {
util::Vector<std::string> inventoryItemIDs; util::Vector<std::string> inventoryItemIDs;
@@ -264,14 +227,6 @@ static util::Vector<std::string> getInventoryItemIDsAsVector(const std::string&
return inventoryItemIDs; return inventoryItemIDs;
} }
/*
Function: serialize
Description: Serializes the service into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized service record
*/
std::string Service::serialize() const std::string Service::serialize() const
{ {
std::ostringstream serializedService; std::ostringstream serializedService;
@@ -283,16 +238,6 @@ std::string Service::serialize() const
return serializedService.str(); return serializedService.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a Service object.
Parameters:
- record: const std::string&, serialized service record
Returns:
- Service*: Pointer to the deserialized Service object
Throws:
- std::runtime_error if labor cost parsing fails
*/
Service* Service::deserialize(const std::string& record) Service* Service::deserialize(const std::string& record)
{ {
std::string id, name; std::string id, name;
@@ -323,14 +268,6 @@ Service* Service::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for service serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,Name,InventoryIDs,LaborCost,Status")
*/
std::string Service::getHeaders() std::string Service::getHeaders()
{ {
return "ID,Name,InventoryIDs,LaborCost,Status"; return "ID,Name,InventoryIDs,LaborCost,Status";
@@ -20,8 +20,10 @@ int ServiceBooking::m_uid = 0;
Function: ServiceBooking Function: ServiceBooking
Description: Default constructor that initializes a new service booking with a unique ID, Description: Default constructor that initializes a new service booking with a unique ID,
null customer, and zero discount percentage. null customer, and zero discount percentage.
Parameters: None Parameters:
Returns: A new ServiceBooking object. - None
Returns:
- A new ServiceBooking object.
*/ */
ServiceBooking::ServiceBooking() ServiceBooking::ServiceBooking()
: m_id("SRV" + std::to_string(++m_uid)), : m_id("SRV" + std::to_string(++m_uid)),
@@ -31,21 +33,18 @@ ServiceBooking::ServiceBooking()
/* /*
Function: ServiceBooking Function: ServiceBooking
Description: Parameterized constructor that initializes a new service booking with a unique ID and specified details. Description: Parameterized constructor that initializes a service booking
Parameters: with customer, vehicle, technician, and discount details.
- id: Booking ID string. Parameter: const std::string& id - booking ID
- status: Current status of the booking (e.g., PENDING, COMPLETED). util::ServiceJobStatus status - current booking status
- services: Map of services included in the booking. const util::Map<std::string, Service*>& services - map of services
- customerId: ID of the customer. const std::string& customerId - ID of the customer
- customer: Pointer to the User object representing the customer. User* customer - pointer to the customer object
- vehicleNumber: Vehicle registration number. const std::string& vehicleNumber - vehicle registration number
- vehicleBrand: Brand of the vehicle. const std::string& vehicleBrand - brand of the vehicle
- vehicleModel: Model of the vehicle. const std::string& vehicleModel - model of the vehicle
- assignedTechnicianId: ID of the assigned technician. double discountPercentage - discount applied to the booking
- assignedTechnician: Name of the assigned technician. Return type: Constructor
- discountPercentage: Discount applied to the booking.
Returns:
- A new ServiceBooking object.
*/ */
ServiceBooking::ServiceBooking( ServiceBooking::ServiceBooking(
util::ServiceJobStatus status, util::ServiceJobStatus status,
@@ -78,24 +77,6 @@ ServiceBooking::ServiceBooking(
} }
} }
/*
Function: ServiceBooking (parameterized constructor with ID)
Description: Initializes a service booking with an existing ID, status, service IDs,
customer details, vehicle details, technician ID, and discount percentage.
Updates UID tracking based on ID.
Parameters:
- id: const std::string&, unique booking ID
- status: util::ServiceJobStatus, job status of the booking
- serviceIDs: const util::Vector<std::string>&, IDs of booked services
- customerId: const std::string&, ID of the customer
- vehicleNumber: const std::string&, vehicle number
- vehicleBrand: const std::string&, vehicle brand
- vehicleModel: const std::string&, vehicle model
- assignedTechnicianId: const std::string&, ID of the assigned technician
- discountPercentage: double, discount applied
Returns:
- A new ServiceBooking object
*/
ServiceBooking::ServiceBooking( ServiceBooking::ServiceBooking(
const std::string& id, const std::string& id,
util::ServiceJobStatus status, util::ServiceJobStatus status,
@@ -126,12 +107,6 @@ ServiceBooking::ServiceBooking(
} }
} }
/*
Function: getId
Description: Retrieves the unique identifier of the service booking.
Parameter: None
Return type: const std::string&
*/
const std::string& ServiceBooking::getId() const const std::string& ServiceBooking::getId() const
{ {
return m_id; return m_id;
@@ -140,22 +115,14 @@ const std::string& ServiceBooking::getId() const
/* /*
Function: getStatus Function: getStatus
Description: Retrieves the current status of the service booking. Description: Retrieves the current status of the service booking.
Parameter: None Returns:
Return type: util::ServiceJobStatus - util::ServiceJobStatus representing the booking status.
*/ */
util::ServiceJobStatus ServiceBooking::getStatus() const util::ServiceJobStatus ServiceBooking::getStatus() const
{ {
return m_status; return m_status;
} }
/*
Function: getServiceIDs
Description: Retrieves the IDs of services booked.
Parameters:
- None
Returns:
- const util::Vector<std::string>&: Service IDs
*/
const util::Vector<std::string>& ServiceBooking::getServiceIDs() const const util::Vector<std::string>& ServiceBooking::getServiceIDs() const
{ {
return m_serviceIDs; return m_serviceIDs;
@@ -163,9 +130,9 @@ const util::Vector<std::string>& ServiceBooking::getServiceIDs() const
/* /*
Function: getServices Function: getServices
Description: Retrieves the services associated with the booking. Description: Retrieves the map of services included in the booking.
Parameter: None Returns:
Return type: const util::Map<std::string, Service*>& - const util::Map<std::string, Service*>& representing the services.
*/ */
const util::Map<std::string, Service*>& ServiceBooking::getServices() const const util::Map<std::string, Service*>& ServiceBooking::getServices() const
{ {
@@ -175,8 +142,8 @@ const util::Map<std::string, Service*>& ServiceBooking::getServices() const
/* /*
Function: getCustomerId Function: getCustomerId
Description: Retrieves the customer ID associated with the booking. Description: Retrieves the customer ID associated with the booking.
Parameter: None Returns:
Return type: const std::string& - const std::string& representing the customer ID.
*/ */
const std::string& ServiceBooking::getCustomerId() const const std::string& ServiceBooking::getCustomerId() const
{ {
@@ -185,9 +152,9 @@ const std::string& ServiceBooking::getCustomerId() const
/* /*
Function: getCustomer Function: getCustomer
Description: Retrieves the customer object associated with the booking. Description: Retrieves the pointer to the associated customer.
Parameter: None Returns:
Return type: User* - User* representing the customer.
*/ */
User* ServiceBooking::getCustomer() const User* ServiceBooking::getCustomer() const
{ {
@@ -196,9 +163,9 @@ User* ServiceBooking::getCustomer() const
/* /*
Function: getVehicleNumber Function: getVehicleNumber
Description: Retrieves the vehicle registration number for the booking. Description: Retrieves the vehicle registration number.
Parameter: None Returns:
Return type: const std::string& - const std::string& representing the vehicle number.
*/ */
const std::string& ServiceBooking::getVehicleNumber() const const std::string& ServiceBooking::getVehicleNumber() const
{ {
@@ -207,9 +174,9 @@ const std::string& ServiceBooking::getVehicleNumber() const
/* /*
Function: getVehicleBrand Function: getVehicleBrand
Description: Retrieves the brand of the vehicle for the booking. Description: Retrieves the brand of the vehicle.
Parameter: None Returns:
Return type: const std::string& - const std::string& representing the vehicle brand.
*/ */
const std::string& ServiceBooking::getVehicleBrand() const const std::string& ServiceBooking::getVehicleBrand() const
{ {
@@ -218,9 +185,9 @@ const std::string& ServiceBooking::getVehicleBrand() const
/* /*
Function: getVehicleModel Function: getVehicleModel
Description: Retrieves the model of the vehicle for the booking. Description: Retrieves the model of the vehicle.
Parameter: None Returns:
Return type: const std::string& - const std::string& representing the vehicle model.
*/ */
const std::string& ServiceBooking::getVehicleModel() const const std::string& ServiceBooking::getVehicleModel() const
{ {
@@ -229,9 +196,9 @@ const std::string& ServiceBooking::getVehicleModel() const
/* /*
Function: getAssignedTechnicianId Function: getAssignedTechnicianId
Description: Retrieves the ID of the technician assigned to the booking. Description: Retrieves the ID of the assigned technician.
Parameter: None Returns:
Return type: const std::string& - const std::string& representing the technician ID.
*/ */
const std::string& ServiceBooking::getAssignedTechnicianId() const const std::string& ServiceBooking::getAssignedTechnicianId() const
{ {
@@ -248,11 +215,12 @@ User* ServiceBooking::getAssignedTechnician() const
{ {
return m_assignedTechnician; return m_assignedTechnician;
} }
/* /*
Function: getDiscountPercentage Function: getDiscountPercentage
Description: Retrieves the discount percentage applied to the booking. Description: Retrieves the discount percentage applied to the booking.
Parameter: None Returns:
Return type: double - double representing the discount percentage.
*/ */
double ServiceBooking::getDiscountPercentage() const double ServiceBooking::getDiscountPercentage() const
{ {
@@ -261,9 +229,11 @@ double ServiceBooking::getDiscountPercentage() const
/* /*
Function: setId Function: setId
Description: Sets the unique identifier of the service booking. Description: Sets the unique ID of the service booking.
Parameter: const std::string& id - new booking ID Parameters:
Return type: void - id: New booking ID string.
Returns:
- void
*/ */
void ServiceBooking::setId(const std::string& id) void ServiceBooking::setId(const std::string& id)
{ {
@@ -273,8 +243,10 @@ void ServiceBooking::setId(const std::string& id)
/* /*
Function: setStatus Function: setStatus
Description: Sets the current status of the service booking. Description: Sets the current status of the service booking.
Parameter: const util::ServiceJobStatus& status - new booking status Parameters:
Return type: void - status: New booking status value.
Returns:
- void
*/ */
void ServiceBooking::setStatus(const util::ServiceJobStatus& status) void ServiceBooking::setStatus(const util::ServiceJobStatus& status)
{ {
@@ -283,9 +255,11 @@ void ServiceBooking::setStatus(const util::ServiceJobStatus& status)
/* /*
Function: setServices Function: setServices
Description: Sets the services associated with the booking. Description: Sets the services included in the booking.
Parameter: const util::Map<std::string, Service*>& services - new services map Parameters:
Return type: void - services: Map of services.
Returns:
- void
*/ */
void ServiceBooking::setServices(const util::Map<std::string, Service*>& services) void ServiceBooking::setServices(const util::Map<std::string, Service*>& services)
{ {
@@ -301,9 +275,11 @@ void ServiceBooking::setServices(const util::Map<std::string, Service*>& service
/* /*
Function: setCustomerId Function: setCustomerId
Description: Sets the customer ID for the booking. Description: Sets the customer ID associated with the booking.
Parameter: const std::string& customerId - new customer ID Parameters:
Return type: void - customerId: New customer ID string.
Returns:
- void
*/ */
void ServiceBooking::setCustomerId(const std::string& customerId) void ServiceBooking::setCustomerId(const std::string& customerId)
{ {
@@ -312,9 +288,11 @@ void ServiceBooking::setCustomerId(const std::string& customerId)
/* /*
Function: setCustomer Function: setCustomer
Description: Sets the customer object for the booking. Description: Sets the pointer to the associated customer.
Parameter: User* customer - pointer to the customer object Parameters:
Return type: void - customer: Pointer to the User object.
Returns:
- void
*/ */
void ServiceBooking::setCustomer(User* customer) void ServiceBooking::setCustomer(User* customer)
{ {
@@ -323,9 +301,11 @@ void ServiceBooking::setCustomer(User* customer)
/* /*
Function: setVehicleNumber Function: setVehicleNumber
Description: Sets the vehicle registration number for the booking. Description: Sets the vehicle registration number.
Parameter: const std::string& vehicleNumber - new vehicle number Parameters:
Return type: void - vehicleNumber: New vehicle number string.
Returns:
- void
*/ */
void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber) void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber)
{ {
@@ -334,9 +314,11 @@ void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber)
/* /*
Function: setVehicleBrand Function: setVehicleBrand
Description: Sets the brand of the vehicle for the booking. Description: Sets the brand of the vehicle.
Parameter: const std::string& vehicleBrand - new vehicle brand Parameters:
Return type: void - vehicleBrand: New vehicle brand string.
Returns:
- void
*/ */
void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand) void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand)
{ {
@@ -345,9 +327,11 @@ void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand)
/* /*
Function: setVehicleModel Function: setVehicleModel
Description: Sets the model of the vehicle for the booking. Description: Sets the model of the vehicle.
Parameter: const std::string& vehicleModel - new vehicle model Parameters:
Return type: void - vehicleModel: New vehicle model string.
Returns:
- void
*/ */
void ServiceBooking::setVehicleModel(const std::string& vehicleModel) void ServiceBooking::setVehicleModel(const std::string& vehicleModel)
{ {
@@ -356,9 +340,11 @@ void ServiceBooking::setVehicleModel(const std::string& vehicleModel)
/* /*
Function: setAssignedTechnicianId Function: setAssignedTechnicianId
Description: Sets the ID of the technician assigned to the booking. Description: Sets the ID of the assigned technician.
Parameter: const std::string& assignedTechnicianId - new technician ID Parameters:
Return type: void - assignedTechnicianId: New technician ID string.
Returns:
- void
*/ */
void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId) void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId)
{ {
@@ -378,23 +364,17 @@ void ServiceBooking::setAssignedTechnician(User* assignedTechnician)
/* /*
Function: setDiscountPercentage Function: setDiscountPercentage
Description: Sets the discount percentage for the booking. Description: Sets the discount percentage applied to the booking.
Parameter: double discountPercentage - new discount percentage Parameters:
Return type: void - discountPercentage: New discount percentage value.
Returns:
- void
*/ */
void ServiceBooking::setDiscountPercentage(double discountPercentage) void ServiceBooking::setDiscountPercentage(double discountPercentage)
{ {
m_discountPercentage = discountPercentage; m_discountPercentage = discountPercentage;
} }
/*
Function: getServiceIDsAsString (static helper)
Description: Converts a vector of service IDs into a single string separated by '|'.
Parameters:
- serviceIDs: const util::Vector<std::string>&, vector of service IDs
Returns:
- std::string: Concatenated service IDs string
*/
static std::string getServiceIDsAsString(const util::Vector<std::string>& serviceIDs) static std::string getServiceIDsAsString(const util::Vector<std::string>& serviceIDs)
{ {
int numberOfServices = serviceIDs.getSize(); int numberOfServices = serviceIDs.getSize();
@@ -410,14 +390,6 @@ static std::string getServiceIDsAsString(const util::Vector<std::string>& servic
return serviceIDsString; return serviceIDsString;
} }
/*
Function: getServiceIDsAsVector (static helper)
Description: Converts a string of service IDs separated by '|' into a vector.
Parameters:
- serviceIDsString: const std::string&, concatenated service IDs string
Returns:
- util::Vector<std::string>: Vector of service IDs
*/
static util::Vector<std::string> getServiceIDsAsVector(const std::string& serviceIDsString) static util::Vector<std::string> getServiceIDsAsVector(const std::string& serviceIDsString)
{ {
util::Vector<std::string> serviceIDs; util::Vector<std::string> serviceIDs;
@@ -430,14 +402,6 @@ static util::Vector<std::string> getServiceIDsAsVector(const std::string& servic
return serviceIDs; return serviceIDs;
} }
/*
Function: serialize
Description: Serializes the service booking into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized booking record
*/
std::string ServiceBooking::serialize() const std::string ServiceBooking::serialize() const
{ {
std::ostringstream serializedBooking; std::ostringstream serializedBooking;
@@ -453,16 +417,6 @@ std::string ServiceBooking::serialize() const
return serializedBooking.str(); return serializedBooking.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a ServiceBooking object.
Parameters:
- record: const std::string&, serialized booking record
Returns:
- ServiceBooking*: Pointer to the deserialized ServiceBooking object
Throws:
- std::runtime_error if discount percentage parsing fails
*/
ServiceBooking* ServiceBooking::deserialize(const std::string& record) ServiceBooking* ServiceBooking::deserialize(const std::string& record)
{ {
std::string id, customerId, vehicleNumber, vehicleBrand, vehicleModel, assignedTechnicianId; std::string id, customerId, vehicleNumber, vehicleBrand, vehicleModel, assignedTechnicianId;
@@ -501,15 +455,7 @@ ServiceBooking* ServiceBooking::deserialize(const std::string& record)
); );
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for service booking serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage")
*/
std::string ServiceBooking::getHeaders() std::string ServiceBooking::getHeaders()
{ {
return "ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage"; return "ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage";
} }
@@ -53,22 +53,6 @@ User::User(const std::string& userName, const std::string& password, const std::
m_type(role), m_type(role),
m_status(util::State::ACTIVE) {} m_status(util::State::ACTIVE) {}
/*
Function: User (parameterized constructor with ID)
Description: Initializes a user with an existing ID, credentials, personal details,
role, and state. Updates UID tracking based on ID.
Parameters:
- userId: const std::string&, unique user ID
- userName: const std::string&, username
- password: const std::string&, password
- name: const std::string&, full name
- phone: const std::string&, phone number
- email: const std::string&, email address
- role: util::UserType, role of the user
- status: util::State, state of the user (ACTIVE/INACTIVE)
Returns:
- A new User object
*/
User::User(const std::string& userId, const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role, util::State status) User::User(const std::string& userId, const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role, util::State status)
: m_id(userId), : m_id(userId),
m_userName(userName), m_userName(userName),
@@ -322,14 +306,6 @@ void User::setState(util::State status)
m_status = status; m_status = status;
} }
/*
Function: serialize
Description: Serializes the user into a CSV-formatted string.
Parameters:
- None
Returns:
- std::string: Serialized user record
*/
std::string User::serialize() const std::string User::serialize() const
{ {
std::ostringstream serializedUser; std::ostringstream serializedUser;
@@ -344,14 +320,6 @@ std::string User::serialize() const
return serializedUser.str(); return serializedUser.str();
} }
/*
Function: deserialize
Description: Deserializes a CSV-formatted string into a User object.
Parameters:
- record: const std::string&, serialized user record
Returns:
- User*: Pointer to the deserialized User object
*/
User* User::deserialize(const std::string& record) User* User::deserialize(const std::string& record)
{ {
std::string id, name, username, phone, password, email; std::string id, name, username, phone, password, email;
@@ -377,15 +345,8 @@ User* User::deserialize(const std::string& record)
status); status);
} }
/*
Function: getHeaders
Description: Retrieves the CSV headers for user serialization.
Parameters:
- None
Returns:
- std::string: Header string ("ID,Username,Password,Name,Phone,Email,UserType,UserStatus")
*/
std::string User::getHeaders() std::string User::getHeaders()
{ {
return "ID,Username,Password,Name,Phone,Email,UserType,UserStatus"; return "ID,Username,Password,Name,Phone,Email,UserType,UserStatus";
} }
@@ -1,8 +1,8 @@
/* /*
File: AuthenticationManagementService.cpp File: AuthenticationManagementService.cpp
Description: Implementation file containing the method definitions of the Description: Implementation file containing the method definitions of the
AuthenticationManagementService class, including login, logout, AuthenticationManagementService class, including logout and
password change, and retrieval of the authenticated user. password change logic.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
@@ -12,15 +12,6 @@ Date:19-May-2026
User* AuthenticationManagementService::m_authenticatedUser = nullptr; User* AuthenticationManagementService::m_authenticatedUser = nullptr;
/*
Function: login
Description: Authenticates a user by checking the provided username and password
against the stored users in the DataStore. If successful, sets the
authenticated user.
Parameter: const std::string& username - users username
const std::string& password - users password
Return type: bool - true if login successful, false otherwise
*/
bool AuthenticationManagementService::login(const std::string& username, const std::string& password) bool AuthenticationManagementService::login(const std::string& username, const std::string& password)
{ {
util::Map<std::string, User*> users = m_dataStore.getUsers(); util::Map<std::string, User*> users = m_dataStore.getUsers();
@@ -41,12 +32,6 @@ bool AuthenticationManagementService::login(const std::string& username, const s
return false; return false;
} }
/*
Function: getAuthenticatedUser
Description: Retrieves the currently authenticated user.
Parameter: None
Return type: User* - pointer to the authenticated user
*/
User* AuthenticationManagementService::getAuthenticatedUser() User* AuthenticationManagementService::getAuthenticatedUser()
{ {
return m_authenticatedUser; return m_authenticatedUser;
@@ -1,35 +1,107 @@
/* /*
File: InventoryManagementService.cpp File: InventoryManagementService.cpp
Description: Implements the InventoryManagementService class, which manages inventory Description: Implementation file containing the method definitions of the
items and observer relationships within the system. Provides methods InventoryManagementService class, including inventory operations
for loading and saving inventory items from persistent storage, as well and notification handling.
as attaching and persisting observers for notification handling.
Author: Trenser Author: Trenser
Date: 22-May-2026 Date:19-May-2026
*/ */
#include <stdexcept>
#include "Config.h"
#include "Enums.h"
#include "Factory.h"
#include "FileManager.h"
#include "InventoryItem.h"
#include "InventoryManagementService.h" #include "InventoryManagementService.h"
#include "Timestamp.h" #include "Config.h"
#include "User.h"
#include "Utility.h"
#include "Vector.h" #include "Vector.h"
#include "Enums.h"
#include "InventoryItem.h"
#include "Config.h"
#include "User.h"
#include "Factory.h"
#include "Timestamp.h"
#include "FileManager.h"
#include "Utility.h"
util::Map<std::string, User*> InventoryManagementService::m_observers{}; util::Map<std::string, User*> InventoryManagementService::m_observers{};
/* /*
Function: attach Function: addInventoryItem
Description: Adds a user to the observer list for receiving inventory notifications. Description: Creates a new inventory item using the Factory and inserts it
Parameters: into the DataStore.
- user: User*, pointer to the user to be attached as an observer Parameter: const std::string& partName - name of the part
Returns: int quantity - initial quantity of the part
- None double price - price of the part
Return type: void
*/ */
void InventoryManagementService::addInventoryItem(const std::string& partName, int quantity, double price)
{
InventoryItem* newItem = Factory::getObject<InventoryItem>(partName, quantity, price);
m_dataStore.getInventoryItems().insert(newItem->getId(), newItem);
}
/*
Function: addInventoryItemStock
Description: Increases the stock quantity of an existing inventory item.
Parameter: const std::string& selectedItemId - ID of the inventory item
int quantity - quantity to add
Return type: void
*/
void InventoryManagementService::addInventoryItemStock(const std::string& selectedItemId, int quantity)
{
int index = m_dataStore.getInventoryItems().find(selectedItemId);
if (index != -1)
{
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
if (item != nullptr)
{
int totalQuantity = item->getQuantity() + quantity;
item->setQuantity(totalQuantity);
}
}
}
/*
Function: getInventoryItems
Description: Retrieves all inventory items stored in the DataStore.
Parameter: None
Return type: util::Map<std::string, InventoryItem*>
*/
util::Map<std::string, InventoryItem*> InventoryManagementService::getInventoryItems()
{
return m_dataStore.getInventoryItems();
}
/*
Function: removeInventoryItem
Description: Marks an inventory item as inactive instead of deleting it.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: void
*/
void InventoryManagementService::removeInventoryItem(const std::string& inventoryItemID)
{
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
if (index != -1)
{
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
if (item != nullptr)
{
item->setState(util::State::INACTIVE);
}
}
}
/*
Function: getInventoryItem
Description: Retrieves a specific inventory item by its ID from the DataStore.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: InventoryItem*
*/
InventoryItem* InventoryManagementService::getInventoryItem(const std::string& inventoryItemID)
{
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
if (index != -1)
{
return m_dataStore.getInventoryItems().getValueAt(index);
}
return nullptr;
}
void InventoryManagementService::attach(User* user) void InventoryManagementService::attach(User* user)
{ {
if (user) if (user)
@@ -42,14 +114,6 @@ void InventoryManagementService::attach(User* user)
} }
} }
/*
Function: detach
Description: Removes a user from the observer list so they no longer receive inventory notifications.
Parameters:
- user: User*, pointer to the user to be detached from the observer list
Returns:
- None
*/
void InventoryManagementService::detach(User* user) void InventoryManagementService::detach(User* user)
{ {
if (user) if (user)
@@ -62,18 +126,6 @@ void InventoryManagementService::detach(User* user)
} }
} }
/*
Function: sendNotification
Description: Sends a notification to a user if they are subscribed as an observer.
Parameters:
- user: User*, pointer to the user receiving the notification
- title: std::string, title of the notification
- message: std::string, body/content of the notification
Returns:
- None
Throws:
- std::runtime_error if notification creation fails
*/
void InventoryManagementService::sendNotification(User* user, const std::string& title, const std::string& message) void InventoryManagementService::sendNotification(User* user, const std::string& title, const std::string& message)
{ {
if (user) if (user)
@@ -100,42 +152,27 @@ void InventoryManagementService::sendNotification(User* user, const std::string&
} }
} }
/*
Function: sendLowStockAlertsToAdmins (static helper)
Description: Sends low stock alert notifications to all admin users for a given inventory item.
Parameters:
- inventoryManagementService: InventoryManagementService&, service used to send notifications
- inventoryItem: const InventoryItem*, pointer to the low-stock inventory item
- adminUsers: const util::Vector<User*>&, list of admin users to notify
Returns:
- None
*/
static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector<User*>& adminUsers) static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector<User*>& adminUsers)
{ {
int adminUsersSize = adminUsers.getSize(); int adminUsersSize = adminUsers.getSize();
for (int index = 0; index < adminUsersSize; index++) for (int index = 0; index < adminUsersSize; index++)
{ {
std::string title = "Low Stock Alert";
std::string message = "The inventory item with ID " + inventoryItem->getId() + " has very low quantity in the inventory";
inventoryManagementService.sendNotification( inventoryManagementService.sendNotification(
adminUsers[index], adminUsers[index],
title, "Low Stock Alert",
message "The inventory item with ID " + inventoryItem->getId() +
); " has very low quantity in the inventory"
);
} }
} }
/*
Function: sendLowStockAlerts
Description: Sends alerts to user for inventory items with low stock
Parameters:
- None
Returns:
- None
*/
void InventoryManagementService::sendLowStockAlerts() void InventoryManagementService::sendLowStockAlerts()
{ {
auto& inventoryItems = m_dataStore.getInventoryItems(); auto& inventoryItems = m_dataStore.getInventoryItems();
if (inventoryItems.isEmpty())
{
return;
}
int inventoryItemsSize = inventoryItems.getSize(); int inventoryItemsSize = inventoryItems.getSize();
auto& usersMap = m_dataStore.getUsers(); auto& usersMap = m_dataStore.getUsers();
int usersMapSize = usersMap.getSize(); int usersMapSize = usersMap.getSize();
@@ -163,15 +200,6 @@ void InventoryManagementService::sendLowStockAlerts()
} }
} }
/*
Function: getObserverIDs
Description: Retrieves the IDs of all observers currently attached to the
InventoryManagementService.
Parameters:
- None
Returns:
- util::Vector<std::string>: Vector of observer user IDs
*/
util::Vector<std::string> InventoryManagementService::getObserverIDs() util::Vector<std::string> InventoryManagementService::getObserverIDs()
{ {
util::Vector<std::string> observerIDs; util::Vector<std::string> observerIDs;
@@ -187,15 +215,6 @@ util::Vector<std::string> InventoryManagementService::getObserverIDs()
return observerIDs; return observerIDs;
} }
/*
Function: loadInventoryItems
Description: Loads inventory items from persistent storage into the datastore.
Uses FileManager to deserialize inventory items from the configured file.
Parameters:
- None
Returns:
- void
*/
void InventoryManagementService::loadInventoryItems() void InventoryManagementService::loadInventoryItems()
{ {
util::FileManager<InventoryItem> inventoryItemFileManager(config::file::INVENTORYITEM_FILE); util::FileManager<InventoryItem> inventoryItemFileManager(config::file::INVENTORYITEM_FILE);
@@ -208,15 +227,6 @@ void InventoryManagementService::loadInventoryItems()
} }
} }
/*
Function: saveInventoryItems
Description: Saves inventory items from the datastore to persistent storage.
Uses FileManager to serialize inventory items into the configured file.
Parameters:
- None
Returns:
- void
*/
void InventoryManagementService::saveInventoryItems() void InventoryManagementService::saveInventoryItems()
{ {
util::FileManager<InventoryItem> inventoryItemFileManager(config::file::INVENTORYITEM_FILE); util::FileManager<InventoryItem> inventoryItemFileManager(config::file::INVENTORYITEM_FILE);
@@ -224,30 +234,12 @@ void InventoryManagementService::saveInventoryItems()
inventoryItemFileManager.save(inventoryItems); inventoryItemFileManager.save(inventoryItems);
} }
/*
Function: loadObservers
Description: Loads observer IDs from persistent storage and attaches corresponding
users as observers to the InventoryManagementService.
Parameters:
- None
Returns:
- void
*/
void InventoryManagementService::loadObservers() void InventoryManagementService::loadObservers()
{ {
util::loadObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this, m_dataStore); util::loadObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this, m_dataStore);
} }
/*
Function: saveObservers
Description: Saves the current observer IDs of the InventoryManagementService
to persistent storage for future retrieval.
Parameters:
- None
Returns:
- void
*/
void InventoryManagementService::saveObservers() void InventoryManagementService::saveObservers()
{ {
util::saveObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this); util::saveObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this);
} }
@@ -1,11 +1,11 @@
/* /*
File: InventoryManagementService.h File: InventoryManagementService.h
Description: Declares the InventoryManagementService class which manages inventory operations in the Vehicle Service Management System. Description: Header file declaring the InventoryManagementService class,
Provides functionality to retrieve, add, and remove inventory items, send low stock alerts, and handle notifications using the Observer pattern. which manages inventory items, stock updates, and notifications
related to low stock alerts. Inherits from NotificationManagementService.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Map.h" #include "Map.h"
@@ -27,6 +27,7 @@ public:
InventoryItem* getInventoryItem(const std::string& inventoryItemID); InventoryItem* getInventoryItem(const std::string& inventoryItemID);
void addInventoryItem(const std::string& partName, int quantity, double price); void addInventoryItem(const std::string& partName, int quantity, double price);
void removeInventoryItem(const std::string& inventoryItemID); void removeInventoryItem(const std::string& inventoryItemID);
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
void sendLowStockAlerts(); void sendLowStockAlerts();
void sendNotification(User* user, const std::string& title, const std::string& message) override; void sendNotification(User* user, const std::string& title, const std::string& message) override;
void attach(User* user) override; void attach(User* user) override;
@@ -8,12 +8,15 @@ Date: 20-May-2026
*/ */
#include <stdexcept> #include <stdexcept>
#include "PaymentManagementService.h"
#include "Config.h" #include "Config.h"
#include "Enums.h" #include "Enums.h"
#include "Factory.h" #include "Factory.h"
#include "FileManager.h" #include "FileManager.h"
#include "InventoryItem.h"
#include "Invoice.h" #include "Invoice.h"
#include "PaymentManagementService.h" #include "JobCard.h"
#include "Service.h"
#include "ServiceBooking.h" #include "ServiceBooking.h"
#include "Timestamp.h" #include "Timestamp.h"
#include "User.h" #include "User.h"
@@ -21,6 +24,90 @@ Date: 20-May-2026
util::Map<std::string, User*> PaymentManagementService::m_observers{}; util::Map<std::string, User*> PaymentManagementService::m_observers{};
static void createInventoryItemsMap(util::Map<std::string, InventoryItem*>& completeInventoryItemMapOfBooking, const Service* currentService)
{
auto& currentRequiredInventoryItems = currentService->getRequiredInventoryItems();
for (int iterator = 0; iterator < currentRequiredInventoryItems.getSize(); iterator++)
{
auto& currentRequiredInventoryItem = currentRequiredInventoryItems.getValueAt(iterator);
completeInventoryItemMapOfBooking.insert(currentRequiredInventoryItem->getId(), currentRequiredInventoryItem);
}
}
void PaymentManagementService::generateInvoice(ServiceBooking* booking)
{
if (!booking)
{
throw std::runtime_error("Invoice generation failed: booking is null.");
}
double totalLabourCost = 0, totalPartsCost = 0, totalServiceCost = 0;
double discountPercentage = booking->getDiscountPercentage();
std::string bookingID = booking->getId();
util::Map<std::string, Service*> servicesInTheBookedService = booking->getServices();
util::Map<std::string, InventoryItem*> completeInventoryItemMapOfBooking;
util::Map<std::string, JobCard*> currentJobCards = m_dataStore.getJobCards();
for (int iterator = 0; iterator < currentJobCards.getSize(); iterator++)
{
JobCard* currentJobCard = currentJobCards.getValueAt(iterator);
if (currentJobCard->getBookingId() == bookingID && currentJobCard->getStatus() != util::ServiceJobStatus::COMPLETED)
{
throw std::runtime_error("Invoice generation failed: not all job cards are completed for booking '" + bookingID + "'.");
}
}
for (int iterator = 0; iterator < servicesInTheBookedService.getSize(); iterator++)
{
Service* currentService = servicesInTheBookedService.getValueAt(iterator);
if (currentService)
{
createInventoryItemsMap(completeInventoryItemMapOfBooking, currentService);
totalLabourCost += currentService->getLaborCost();
totalPartsCost += util::calculatePartsCost(currentService);
}
}
totalServiceCost = totalLabourCost + totalPartsCost;
totalServiceCost -= (totalServiceCost * (discountPercentage / 100));
Invoice* invoice = Factory::getObject<Invoice>(bookingID, booking, util::Timestamp(), totalLabourCost, completeInventoryItemMapOfBooking, totalPartsCost, discountPercentage, totalServiceCost, util::Timestamp(), util::PaymentMode::NOTSET, util::PaymentStatus::PENDING);
util::Map<std::string, Invoice*>& currentInvoices = m_dataStore.getInvoices();
currentInvoices.insert(invoice->getId(), invoice);
}
util::Map<std::string, Invoice*> PaymentManagementService::getInvoices(const std::string& customerID)
{
util::Map<std::string, Invoice*>& currentInvoices = m_dataStore.getInvoices();
util::Map<std::string, Invoice*> currentUserInvoices;
for (int iterator = 0; iterator < currentInvoices.getSize(); iterator++)
{
Invoice* currentInvoice = currentInvoices.getValueAt(iterator);
if (currentInvoice->getBooking()->getCustomerId() == customerID)
{
currentUserInvoices.insert(currentInvoice->getId(), currentInvoice);
}
}
return currentUserInvoices;
}
void PaymentManagementService::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
{
auto& currentInvoices = m_dataStore.getInvoices();
int invoiceIndex = currentInvoices.find(invoiceID);
if (invoiceIndex != -1)
{
Invoice* invoice = currentInvoices.getValueAt(invoiceIndex);
User* currentUser = invoice->getBooking()->getCustomer();
invoice->setPaymentMethod(paymentMode);
invoice->setPaymentDate(util::Timestamp());
invoice->setStatus(util::PaymentStatus::COMPLETED);
std::string title, message;
title = "Payment successful";
message = "Payment successful for invoice ID " + invoiceID;
sendNotification(currentUser, title, message);
}
else
{
throw std::runtime_error("Payment failed: invalid invoice ID.");
}
}
/* /*
Function: attach Function: attach
Description: Attaches a user as an observer to the PaymentManagementService for receiving notifications. Description: Attaches a user as an observer to the PaymentManagementService for receiving notifications.
@@ -127,9 +214,9 @@ void PaymentManagementService::sendPaymentReminders()
User* customer = serviceBooking->getCustomer(); User* customer = serviceBooking->getCustomer();
if (customer) if (customer)
{ {
std::string title = "Payment Reminder"; sendNotification(customer,
std::string message = "Your payment for Invoice ID " + invoice->getId() + " is still pending. Please complete the payment."; "Payment Reminder",
sendNotification(customer, title, message); "Your payment for Invoice ID " + invoice->getId() + " is still pending.Please complete the payment." + invoice->getId());
} }
} }
} }
@@ -137,15 +224,6 @@ void PaymentManagementService::sendPaymentReminders()
} }
} }
/*
Function: getObserverIDs
Description: Retrieves the IDs of all observers currently attached to the
PaymentManagementService.
Parameters:
- None
Returns:
- util::Vector<std::string>: Vector of observer user IDs
*/
util::Vector<std::string> PaymentManagementService::getObserverIDs() util::Vector<std::string> PaymentManagementService::getObserverIDs()
{ {
util::Vector<std::string> observerIDs; util::Vector<std::string> observerIDs;
@@ -161,19 +239,6 @@ util::Vector<std::string> PaymentManagementService::getObserverIDs()
return observerIDs; return observerIDs;
} }
/*
Function: loadInvoices
Description: Loads invoices from persistent storage into the datastore.
Validates associated service bookings and inventory parts before
attaching them to each invoice. Throws exceptions if invalid IDs
are encountered.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if a booking ID or part ID is invalid
*/
void PaymentManagementService::loadInvoices() void PaymentManagementService::loadInvoices()
{ {
util::FileManager<Invoice> invoiceFileManager(config::file::INVOICE_FILE); util::FileManager<Invoice> invoiceFileManager(config::file::INVOICE_FILE);
@@ -207,16 +272,6 @@ void PaymentManagementService::loadInvoices()
invoices[invoice->getId()] = invoice; invoices[invoice->getId()] = invoice;
} }
} }
/*
Function: saveInvoices
Description: Saves invoices from the datastore to persistent storage.
Uses FileManager to serialize invoices into the configured file.
Parameters:
- None
Returns:
- void
*/
void PaymentManagementService::saveInvoices() void PaymentManagementService::saveInvoices()
{ {
util::FileManager<Invoice> invoiceFileManager(config::file::INVOICE_FILE); util::FileManager<Invoice> invoiceFileManager(config::file::INVOICE_FILE);
@@ -224,32 +279,12 @@ void PaymentManagementService::saveInvoices()
invoiceFileManager.save(invoices); invoiceFileManager.save(invoices);
} }
/*
Function: loadObservers
Description: Loads observer IDs from persistent storage and attaches corresponding
users as observers to the PaymentManagementService.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if an observer ID is invalid (not found in datastore)
*/
void PaymentManagementService::loadObservers() void PaymentManagementService::loadObservers()
{ {
util::loadObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this, m_dataStore); util::loadObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this, m_dataStore);
} }
/*
Function: saveObservers
Description: Saves the current observer IDs of the PaymentManagementService
to persistent storage for future retrieval.
Parameters:
- None
Returns:
- void
*/
void PaymentManagementService::saveObservers() void PaymentManagementService::saveObservers()
{ {
util::saveObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this); util::saveObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this);
} }
@@ -1,8 +1,8 @@
/* /*
File: ServiceManagementService.cpp File: ServiceManagementService.cpp
Description: Implementation file containing the method definitions of the Description: Implementation file containing the method definitions of the
ServiceManagementService class, including service and combo package ServiceManagementService class, including service booking cancellation,
purchasing logic, booking creation, and notification handling. job card management, combo package creation, and removal logic.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
@@ -11,27 +11,237 @@ Date:19-May-2026
#include "AuthenticationManagementService.h" #include "AuthenticationManagementService.h"
#include "ComboPackage.h" #include "ComboPackage.h"
#include "Config.h" #include "Config.h"
#include "Enums.h"
#include "Factory.h" #include "Factory.h"
#include "FileManager.h" #include "FileManager.h"
#include "InventoryItem.h"
#include "Invoice.h"
#include "JobCard.h" #include "JobCard.h"
#include "NotificationManagementService.h"
#include "PaymentManagementService.h"
#include "Service.h" #include "Service.h"
#include "ServiceBooking.h" #include "ServiceBooking.h"
#include "ServiceManagementService.h" #include "ServiceManagementService.h"
#include "Timestamp.h" #include "Timestamp.h"
#include "User.h" #include "User.h"
#include "UserManagementService.h"
#include "Utility.h" #include "Utility.h"
/* util::Map<std::string, User*> ServiceManagementService::m_observers{};
Function: purchaseService
Description: Creates a new service booking for the authenticated user. Validates util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBookings()
service IDs, retrieves services from the DataStore, and generates a {
booking. Sends a notification upon successful booking. return m_dataStore.getServiceBookings();
Parameter: const util::Vector<std::string>& serviceIDs - IDs of services to purchase }
const std::string& vehicleNumber - vehicle registration number
const std::string& vehicleBrand - brand of the vehicle ServiceBooking* ServiceManagementService::getServiceBooking(const std::string& serviceID)
const std::string& vehicleModel - model of the vehicle {
Return type: void auto currentServiceBookings = getServiceBookings();
*/ for (int iterator = 0; iterator < currentServiceBookings.getSize(); iterator++)
{
if (currentServiceBookings.getValueAt(iterator)->getId() == serviceID)
{
return currentServiceBookings.getValueAt(iterator);
}
}
return nullptr;
}
void ServiceManagementService::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{
UserManagementService m_userManagementService;
ServiceBooking* currentBooking = getServiceBooking(bookingID);
auto& currentJobCards = m_dataStore.getJobCards();
if (currentBooking == nullptr)
{
throw std::runtime_error("Service Booking not available");
}
auto& currentServices = currentBooking->getServices();
if (currentServices.find(serviceID) == -1)
{
throw std::runtime_error("Invalid service Id");
}
Service* currentService = currentServices.getValueAt(currentServices.find(serviceID));
User* selectedTechnician = m_userManagementService.getUser(technicianID);
if (selectedTechnician == nullptr)
{
throw std::runtime_error("Technician not available");
}
auto& inventoryItems = currentService->getRequiredInventoryItems();
for (int iterator = 0; iterator < inventoryItems.getSize(); iterator++)
{
InventoryItem* currentInventoryItem = inventoryItems.getValueAt(iterator);
if (currentInventoryItem->getQuantity() == 0)
{
std::string errorMessage = "Failed to create job card, " + currentInventoryItem->getPartName() + " is out of stock.";
throw std::runtime_error(errorMessage);
}
else
{
int currentStockQuantity = currentInventoryItem->getQuantity();
currentInventoryItem->setQuantity(currentStockQuantity - 1);
}
}
currentBooking->setAssignedTechnician(selectedTechnician);
currentBooking->setAssignedTechnicianId(selectedTechnician->getId());
std::string title = "Job card created";
std::string message = "Job card created for the service and you are assigned for that.";
JobCard* jobCard = Factory::getObject<JobCard>(bookingID, currentBooking, currentService, serviceID, technicianID, selectedTechnician, util::Timestamp(), util::ServiceJobStatus::STARTED, util::Timestamp());
currentJobCards.insert(jobCard->getId(), jobCard);
sendNotification(selectedTechnician, title, message);
}
void ServiceManagementService::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{
util::Map<std::string, InventoryItem*> currentServiceInventoryItems;
auto inventoryItems = m_dataStore.getInventoryItems();
for (int iteratorOne = 0; iteratorOne < inventoryItemIDs.getSize(); iteratorOne++)
{
std::string currentItemID = inventoryItemIDs[iteratorOne];
bool itemFound = false;
for (int iteratorTwo = 0; iteratorTwo < inventoryItems.getSize(); iteratorTwo++)
{
InventoryItem* currentInventoryItem = inventoryItems.getValueAt(iteratorTwo);
if (currentInventoryItem && currentInventoryItem->getId() == currentItemID)
{
itemFound = true;
currentServiceInventoryItems.insert(currentInventoryItem->getId(), currentInventoryItem);
break;
}
}
if (!itemFound)
{
throw std::runtime_error("Inventory item with ID '" + currentItemID + "' not found.");
}
}
Service* newService = Factory::getObject<Service>(name, currentServiceInventoryItems, laborCost);
if (newService == nullptr)
{
throw std::runtime_error("Unable to create new service.");
}
util::Map<std::string, Service*>& currentServices = m_dataStore.getServices();
if (currentServices.find(newService->getId()) != -1)
{
throw std::runtime_error("Service with this ID Already exists.");
}
currentServices.insert(newService->getId(), newService);
}
util::Map<std::string, Service*> ServiceManagementService::getServices()
{
return m_dataStore.getServices();
}
void ServiceManagementService::removeService(const std::string& serviceID)
{
util::Map<std::string, Service*> currentServices = getServices();
if (currentServices.find(serviceID) != -1)
{
currentServices.getValueAt(currentServices.find(serviceID))->setState(util::State::INACTIVE);
}
else
{
throw std::runtime_error("Service not found.");
}
}
util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBookings(const std::string& customerID)
{
util::Map<std::string, ServiceBooking*> currentServiceBookings = getServiceBookings();
util::Map<std::string, ServiceBooking*> currentUserServiceBookings;
if (currentServiceBookings.getSize() != 0)
{
for (int iterator = 0; iterator < currentServiceBookings.getSize(); iterator++)
{
auto currentServiceBooking = currentServiceBookings.getValueAt(iterator);
if (currentServiceBooking->getCustomerId() == customerID)
{
currentUserServiceBookings.insert(currentServiceBooking->getId(), currentServiceBooking);
}
}
}
return currentUserServiceBookings;
}
util::Map<std::string, JobCard*> ServiceManagementService::getJobCards(const std::string& technicianID)
{
util::Map<std::string, JobCard*> jobCards = m_dataStore.getJobCards();
util::Map<std::string, JobCard*> technicianJobCards;
for (int iterator = 0; iterator < jobCards.getSize(); iterator++)
{
JobCard* currentJobCard = jobCards.getValueAt(iterator);
if (currentJobCard->getTechnicianId() == technicianID)
{
technicianJobCards.insert(currentJobCard->getId(), currentJobCard);
}
}
return technicianJobCards;
}
static bool hasAllJobCardsinServiceBookingCompleted(std::string bookingId, util::Map<std::string, JobCard*>& currentAssignedJobs)
{
for (int iterator = 0; iterator < currentAssignedJobs.getSize(); iterator++)
{
JobCard* currentJob = currentAssignedJobs.getValueAt(iterator);
if (currentJob->getBookingId() == bookingId)
{
if (currentJob->getStatus() == util::ServiceJobStatus::STARTED)
{
return false;
}
}
}
return true;
}
void ServiceManagementService::completeJob(const std::string& jobID)
{
AuthenticationManagementService authenticationManagementService;
PaymentManagementService paymentManagementService;
bool jobStatusUpdated = false, serviceBookingCompleted;
JobCard* currentJob;
User* currentTechnician = authenticationManagementService.getAuthenticatedUser();
if (currentTechnician == nullptr)
{
throw std::runtime_error("Unable to fetch current technician.");
}
util::Map<std::string, JobCard*> currentAssignedJobs = getJobCards(currentTechnician->getId());
if (currentAssignedJobs.getSize() == 0)
{
throw std::runtime_error("No job cards assigned to the technician.");
}
if (currentAssignedJobs.find(jobID) != -1)
{
currentJob = currentAssignedJobs.getValueAt(currentAssignedJobs.find(jobID));
if (currentJob == nullptr)
{
throw std::runtime_error("Unable to fetch current job.");
}
if (currentJob->getStatus() == util::ServiceJobStatus::STARTED)
{
currentJob->setStatus(util::ServiceJobStatus::COMPLETED);
jobStatusUpdated = true;
}
}
else
{
throw std::runtime_error("Failed to complete the job, some error occured or job already completed.");
}
if (!jobStatusUpdated)
{
throw std::runtime_error("Failed to complete the job, some error occured or job already completed.");
}
serviceBookingCompleted = hasAllJobCardsinServiceBookingCompleted(currentJob->getBookingId(), currentAssignedJobs);
if (serviceBookingCompleted)
{
currentJob->getBooking()->setStatus(util::ServiceJobStatus::COMPLETED);
paymentManagementService.generateInvoice(currentJob->getBooking());
std::string title = "Service Booking completed,Invoice Generated.\n";
std::string message = "Services completed for the booking and invoice generated.\n";
sendNotification(currentJob->getBooking()->getCustomer(), title, message);
}
}
void ServiceManagementService::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) void ServiceManagementService::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{ {
AuthenticationManagementService m_authenticationManagementService; AuthenticationManagementService m_authenticationManagementService;
@@ -60,22 +270,11 @@ void ServiceManagementService::purchaseService(const util::Vector<std::string>&
throw std::runtime_error("Failed to create service booking"); throw std::runtime_error("Failed to create service booking");
} }
serviceBookingMap[serviceBooking->getId()] = serviceBooking; serviceBookingMap[serviceBooking->getId()] = serviceBooking;
std::string title = "Service Booking succeeded"; sendNotification(authenticatedUser,
std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId(); "Service Booking succeeded",
sendNotification(authenticatedUser, title, message); "Your service booking has been successfully placed with ID " + serviceBooking->getId());
} }
/*
Function: purchaseComboPackage
Description: Creates a new service booking for a combo package. Validates the combo
package ID, retrieves services from the package, and generates a booking
with the applicable discount. Sends a notification upon successful booking.
Parameter: const std::string& comboPackageID - ID of the combo package
const std::string& vehicleNumber - vehicle registration number
const std::string& vehicleBrand - brand of the vehicle
const std::string& vehicleModel - model of the vehicle
Return type: void
*/
void ServiceManagementService::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) void ServiceManagementService::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{ {
AuthenticationManagementService m_authenticationManagementService; AuthenticationManagementService m_authenticationManagementService;
@@ -99,12 +298,225 @@ void ServiceManagementService::purchaseComboPackage(const std::string& comboPack
throw std::runtime_error("Failed to create combo package service booking"); throw std::runtime_error("Failed to create combo package service booking");
} }
serviceBookingMap[serviceBooking->getId()] = serviceBooking; serviceBookingMap[serviceBooking->getId()] = serviceBooking;
std::string title = "Combo Package Service Booking succeeded"; sendNotification(authenticatedUser,
std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId(); "Combo Package Service Booking succeeded",
sendNotification(authenticatedUser, title, message); "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId());
} }
util::Map<std::string, User*> ServiceManagementService::m_observers{}; /*
Function: cancelCustomerServiceBookings
Description: Cancels all service bookings associated with a given customer or technician.
Updates booking status, resets customer/technician assignments, sends notifications,
and restocks inventory items.
Parameter: const std::string& userID - ID of the customer or technician
Return type: void
*/
void ServiceManagementService::cancelCustomerServiceBookings(const std::string& userID)
{
const int INCREMENT_VALUE = 1;
auto& users = m_dataStore.getUsers();
int userIndex = users.find(userID);
if (userIndex == -1)
{
throw std::runtime_error("User not found: " + userID);
}
User* user = users.getValueAt(userIndex);
if (user == nullptr)
{
throw std::runtime_error("User not found: " + userID);
}
util::UserType type = user->getUserType();
auto& bookings = DataStore::getInstance().getServiceBookings();
for (int bookingIterator = 0; bookingIterator < bookings.getSize(); bookingIterator++)
{
ServiceBooking* booking = bookings.getValueAt(bookingIterator);
if (booking != nullptr &&
(booking->getCustomerId() == userID || booking->getAssignedTechnicianId() == userID))
{
if (booking->getStatus() == util::ServiceJobStatus::PENDING ||
booking->getStatus() == util::ServiceJobStatus::STARTED)
{
if (type == util::UserType::CUSTOMER)
{
booking->setStatus(util::ServiceJobStatus::CANCELLED);
booking->setCustomer(nullptr);
booking->setCustomerId("");
User* assignedTechnician = booking->getAssignedTechnician();
sendNotification(assignedTechnician, "Customer Service Cancelled", "Uh?Oh. The customer has cancelled their service booking. Your assigned job card has been cancelled and the inventory has been restocked.");
}
else if (type == util::UserType::TECHNICIAN)
{
booking->setStatus(util::ServiceJobStatus::PENDING);
sendNotification(booking->getCustomer(), "Technician Unavailable", "Your assigned technician is no longer available. Your booking has been reset to pending, and we will reassign a new technician shortly.");
}
booking->setAssignedTechnician(nullptr);
booking->setAssignedTechnicianId("");
const auto& ListOfServices = booking->getServices();
for (int serviceIterator = 0; serviceIterator < ListOfServices.getSize(); serviceIterator++)
{
Service* service = ListOfServices.getValueAt(serviceIterator);
if (service != nullptr)
{
const auto& items = service->getRequiredInventoryItems();
for (int itemIterator = 0; itemIterator < items.getSize(); itemIterator++)
{
InventoryItem* item = items.getValueAt(itemIterator);
if (item != nullptr)
{
item->setQuantity(item->getQuantity() + INCREMENT_VALUE);
}
}
}
}
}
}
}
}
/*
Function: cancelTechnicianJobs
Description: Cancels all jobs assigned to a technician. Updates job status, sends notifications,
and restocks inventory items used in the service.
Parameter: const std::string& technicianID - ID of the technician
Return type: void
*/
void ServiceManagementService::cancelTechnicianJobs(const std::string& technicianID)
{
const int INCREMENT_VALUE = 1;
auto& jobs = m_dataStore.getJobCards();
for (int jobIterator = 0; jobIterator < jobs.getSize(); jobIterator++)
{
JobCard* job = jobs.getValueAt(jobIterator);
if (job != nullptr && job->getTechnicianId() == technicianID)
{
if (job->getStatus() == util::ServiceJobStatus::PENDING || job->getStatus() == util::ServiceJobStatus::STARTED)
{
job->setStatus(util::ServiceJobStatus::CANCELLED);
sendNotification(job->getTechnician(), "Job Cancelled", "The Job has cancelled. Your job card has been cancelled and the inventory has been restocked.");
Service* service = job->getService();
if (service != nullptr)
{
const auto& items = service->getRequiredInventoryItems();
for (int itemIterator = 0; itemIterator < items.getSize(); itemIterator++)
{
InventoryItem* item = items.getValueAt(itemIterator);
if (item != nullptr)
{
item->setQuantity(item->getQuantity() + INCREMENT_VALUE);
}
}
}
}
}
}
}
/*
Function: createComboPackage
Description: Creates a new combo package with two services and a discount percentage.
Validates service IDs, ensures uniqueness, and inserts the new package into the DataStore.
Parameter: const std::string& packageName - name of the combo package
const util::Vector<std::string>& serviceIDsInNewCombo - list of service IDs
double discountPercentage - discount percentage for the package
Return type: void
*/
void ServiceManagementService::createComboPackage(const std::string& packageName, const util::Vector<std::string>& serviceIDsInNewCombo, double discountPercentage)
{
if (packageName.empty())
{
throw std::invalid_argument("The Combo Package Name cannot be empty.\n");
}
if (serviceIDsInNewCombo.getSize() < 2 || serviceIDsInNewCombo.getSize() > 2)
{
throw std::invalid_argument("Combo package must contain only two services.");
}
if (discountPercentage < 0.0 || discountPercentage > 100.0)
{
throw std::invalid_argument("Discount percentage must be between 0 and 100.");
}
auto& servicesMap = m_dataStore.getServices();
for (int index = 0; index < serviceIDsInNewCombo.getSize(); index++)
{
const std::string serviceid = serviceIDsInNewCombo[index];
if (servicesMap.find(serviceid) == -1)
{
throw std::runtime_error("Service ID not found: " + serviceid);
}
}
auto& comboPackageMap = m_dataStore.getComboPackages();
for (int iterator = 0; iterator < comboPackageMap.getSize(); iterator++)
{
ComboPackage* existingCombos = comboPackageMap.getValueAt(iterator);
const util::Map<std::string, Service*>& servicesInsideExistingCombos = existingCombos->getServices();
if (servicesInsideExistingCombos.getSize() == serviceIDsInNewCombo.getSize())
{
bool isIdentical = true;
for (int serviceIterator = 0; serviceIterator < serviceIDsInNewCombo.getSize(); serviceIterator++)
{
const std::string& id = serviceIDsInNewCombo[serviceIterator];
if (servicesInsideExistingCombos.find(id) == -1)
{
isIdentical = false;
break;
}
}
if (isIdentical)
{
throw std::runtime_error("A combo package with the same services already exists.");
}
}
}
util::Map<std::string, Service*> selectedServices;
for (int iteratorOne = 0; iteratorOne < serviceIDsInNewCombo.getSize(); iteratorOne++)
{
const std::string& serviceId = serviceIDsInNewCombo[iteratorOne];
int serviceIndex = servicesMap.find(serviceId);
if (serviceIndex == -1)
{
throw std::runtime_error("Service ID not found: " + serviceId);
}
selectedServices.insert(serviceId, servicesMap.getValueAt(serviceIndex));
}
ComboPackage* newComboPackage = Factory::getObject<ComboPackage>(packageName, discountPercentage, selectedServices);
comboPackageMap.insert(newComboPackage->getId(), newComboPackage);
}
/*
Function: getComboPackages
Description: Retrieves all combo packages stored in the DataStore.
Parameter: None
Return type: util::Map<std::string, ComboPackage*>
*/
util::Map<std::string, ComboPackage*> ServiceManagementService::getComboPackages()
{
return m_dataStore.getComboPackages();
}
/*
Function: removeComboPackage
Description: Removes a combo package by marking it inactive. Throws an exception if the package ID is not found.
Parameter: const std::string& comboPackageID - ID of the combo package
Return type: void
*/
void ServiceManagementService::removeComboPackage(const std::string& comboPackageID)
{
bool removed = false;
util::Map<std::string, ComboPackage*>& currentComboPackages = m_dataStore.getComboPackages();
for (int iterator = 0; iterator < currentComboPackages.getSize(); iterator++)
{
ComboPackage* currentComboPackage = currentComboPackages.getValueAt(iterator);
if (currentComboPackage && currentComboPackage->getId() == comboPackageID)
{
currentComboPackage->setState(util::State::INACTIVE);
removed = true;
break;
}
}
if (!removed)
{
throw std::runtime_error("Combo package with ID '" + comboPackageID + "' not found.");
}
}
/* /*
Function: attach Function: attach
@@ -184,15 +596,6 @@ void ServiceManagementService::sendNotification(User* user, const std::string& t
} }
} }
/*
Function: getObserverIDs
Description: Retrieves the IDs of all observers currently attached to the
ServiceManagementService.
Parameters:
- None
Returns:
- util::Vector<std::string>: Vector of observer user IDs
*/
util::Vector<std::string> ServiceManagementService::getObserverIDs() util::Vector<std::string> ServiceManagementService::getObserverIDs()
{ {
util::Vector<std::string> observerIDs; util::Vector<std::string> observerIDs;
@@ -208,17 +611,6 @@ util::Vector<std::string> ServiceManagementService::getObserverIDs()
return observerIDs; return observerIDs;
} }
/*
Function: loadServices
Description: Loads services from persistent storage into the datastore.
Validates required inventory items and attaches them to each service.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if an inventory item ID is invalid
*/
void ServiceManagementService::loadServices() void ServiceManagementService::loadServices()
{ {
util::FileManager<Service> serviceFileManager(config::file::SERVICE_FILE); util::FileManager<Service> serviceFileManager(config::file::SERVICE_FILE);
@@ -245,15 +637,6 @@ void ServiceManagementService::loadServices()
} }
} }
/*
Function: saveServices
Description: Saves services from the datastore to persistent storage.
Uses FileManager to serialize services into the configured file.
Parameters:
- None
Returns:
- void
*/
void ServiceManagementService::saveServices() void ServiceManagementService::saveServices()
{ {
util::FileManager<Service> serviceFileManager(config::file::SERVICE_FILE); util::FileManager<Service> serviceFileManager(config::file::SERVICE_FILE);
@@ -261,17 +644,6 @@ void ServiceManagementService::saveServices()
serviceFileManager.save(services); serviceFileManager.save(services);
} }
/*
Function: loadComboPackages
Description: Loads combo packages from persistent storage into the datastore.
Validates associated services and attaches them to each package.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if a service ID is invalid
*/
void ServiceManagementService::loadComboPackages() void ServiceManagementService::loadComboPackages()
{ {
util::FileManager<ComboPackage> comboPackageFileManager(config::file::COMBOPACKAGE_FILE); util::FileManager<ComboPackage> comboPackageFileManager(config::file::COMBOPACKAGE_FILE);
@@ -298,15 +670,6 @@ void ServiceManagementService::loadComboPackages()
} }
} }
/*
Function: saveComboPackages
Description: Saves combo packages from the datastore to persistent storage.
Uses FileManager to serialize combo packages into the configured file.
Parameters:
- None
Returns:
- void
*/
void ServiceManagementService::saveComboPackages() void ServiceManagementService::saveComboPackages()
{ {
util::FileManager<ComboPackage> comboPackageFileManager(config::file::COMBOPACKAGE_FILE); util::FileManager<ComboPackage> comboPackageFileManager(config::file::COMBOPACKAGE_FILE);
@@ -314,19 +677,6 @@ void ServiceManagementService::saveComboPackages()
comboPackageFileManager.save(comboPackages); comboPackageFileManager.save(comboPackages);
} }
/*
Function: loadServiceBookings
Description: Loads service bookings from persistent storage into the datastore.
Validates associated services, customers, and technicians before
attaching them to each booking.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if a service ID, customer ID, or technician ID is invalid
- std::runtime_error if a user is not of the expected type (customer/technician)
*/
void ServiceManagementService::loadServiceBookings() void ServiceManagementService::loadServiceBookings()
{ {
util::FileManager<ServiceBooking> bookingFileManager(config::file::SERVICEBOOKING_FILE); util::FileManager<ServiceBooking> bookingFileManager(config::file::SERVICEBOOKING_FILE);
@@ -381,15 +731,6 @@ void ServiceManagementService::loadServiceBookings()
} }
} }
/*
Function: saveServiceBookings
Description: Saves service bookings from the datastore to persistent storage.
Uses FileManager to serialize bookings into the configured file.
Parameters:
- None
Returns:
- void
*/
void ServiceManagementService::saveServiceBookings() void ServiceManagementService::saveServiceBookings()
{ {
util::FileManager<ServiceBooking> bookingFileManager(config::file::SERVICEBOOKING_FILE); util::FileManager<ServiceBooking> bookingFileManager(config::file::SERVICEBOOKING_FILE);
@@ -397,20 +738,6 @@ void ServiceManagementService::saveServiceBookings()
bookingFileManager.save(serviceBookings); bookingFileManager.save(serviceBookings);
} }
/*
Function: loadJobCards
Description: Loads job cards from persistent storage into the datastore.
Validates associated bookings, services, and technicians before
attaching them to each job card.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if a booking ID, service ID, or technician ID is invalid
- std::runtime_error if a service does not belong to the booking
- std::runtime_error if a user is not a technician
*/
void ServiceManagementService::loadJobCards() void ServiceManagementService::loadJobCards()
{ {
util::FileManager<JobCard> jobCardFileManager(config::file::JOBCARD_FILE); util::FileManager<JobCard> jobCardFileManager(config::file::JOBCARD_FILE);
@@ -454,16 +781,6 @@ void ServiceManagementService::loadJobCards()
jobCards[jobCard->getId()] = jobCard; jobCards[jobCard->getId()] = jobCard;
} }
} }
/*
Function: saveJobCards
Description: Saves job cards from the datastore to persistent storage.
Uses FileManager to serialize job cards into the configured file.
Parameters:
- None
Returns:
- void
*/
void ServiceManagementService::saveJobCards() void ServiceManagementService::saveJobCards()
{ {
util::FileManager<JobCard> jobCardFileManager(config::file::JOBCARD_FILE); util::FileManager<JobCard> jobCardFileManager(config::file::JOBCARD_FILE);
@@ -471,32 +788,12 @@ void ServiceManagementService::saveJobCards()
jobCardFileManager.save(jobCards); jobCardFileManager.save(jobCards);
} }
/*
Function: loadObservers
Description: Loads observer IDs from persistent storage and attaches corresponding
users as observers to the ServiceManagementService.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if an observer ID is invalid (not found in datastore)
*/
void ServiceManagementService::loadObservers() void ServiceManagementService::loadObservers()
{ {
util::loadObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this, m_dataStore); util::loadObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this, m_dataStore);
} }
/*
Function: saveObservers
Description: Saves the current observer IDs of the ServiceManagementService
to persistent storage for future retrieval.
Parameters:
- None
Returns:
- void
*/
void ServiceManagementService::saveObservers() void ServiceManagementService::saveObservers()
{ {
util::saveObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this); util::saveObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this);
} }
@@ -31,6 +31,7 @@ public:
void purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel); void purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel);
util::Map<std::string, ServiceBooking*> getServiceBookings(); util::Map<std::string, ServiceBooking*> getServiceBookings();
util::Map<std::string, ServiceBooking*> getServiceBookings(const std::string& customerID); util::Map<std::string, ServiceBooking*> getServiceBookings(const std::string& customerID);
ServiceBooking* getServiceBooking(const std::string& serviceID);
void createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID); void createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID);
void createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost); void createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost);
void removeService(const std::string& serviceID); void removeService(const std::string& serviceID);
@@ -38,7 +39,7 @@ public:
void completeJob(const std::string& jobID); void completeJob(const std::string& jobID);
void cancelCustomerServiceBookings(const std::string& customerID); void cancelCustomerServiceBookings(const std::string& customerID);
void cancelTechnicianJobs(const std::string& technicianID); void cancelTechnicianJobs(const std::string& technicianID);
void createComboPackage(const std::string& name, const util::Vector<std::string>& serviceIDs, double discountPercentage); void createComboPackage(const std::string& packageName, const util::Vector<std::string>& serviceIDs, double discountPercentage);
void removeComboPackage(const std::string& comboPackageID); void removeComboPackage(const std::string& comboPackageID);
void sendNotification(User* user, const std::string& title, const std::string& message) override; void sendNotification(User* user, const std::string& title, const std::string& message) override;
void attach(User* user) override; void attach(User* user) override;
@@ -1,33 +1,25 @@
/* /*
File: UserManagementService.cpp File: UserManagementService.cpp
Description: Implementation file containing the method definitions of the Description: Implementation file containing the method definitions of the
UserManagementService class, including user creation, updates, UserManagementService class, including user retrieval and removal logic.
and ensuring an admin account exists.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#include <stdexcept> #include <stdexcept>
#include "Config.h" #include "Config.h"
#include "Enums.h" #include "Enums.h"
#include "Factory.h" #include "Factory.h"
#include "FileManager.h" #include "FileManager.h"
#include "InventoryManagementService.h" #include "InventoryManagementService.h"
#include "Notification.h" #include "Invoice.h"
#include "PaymentManagementService.h" #include "PaymentManagementService.h"
#include "ServiceManagementService.h" #include "ServiceManagementService.h"
#include "User.h" #include "User.h"
#include "UserManagementService.h" #include "UserManagementService.h"
#include "Utility.h"
#include "Vector.h" #include "Vector.h"
/*
Function: ensureAdminExists
Description: Ensures that at least one admin user exists in the system.
If no admin is found, creates a default admin user using
configuration constants.
Parameter: None
Return type: void
*/
void UserManagementService::ensureAdminExists() void UserManagementService::ensureAdminExists()
{ {
auto& usersMap = m_dataStore.getUsers(); auto& usersMap = m_dataStore.getUsers();
@@ -54,19 +46,6 @@ void UserManagementService::ensureAdminExists()
} }
} }
/*
Function: createUser
Description: Creates a new user with the provided details. Validates that
the username is unique, then attaches the user to relevant
management services (payment, service, inventory).
Parameter: const std::string& username - users username
const std::string& name - users name
const std::string& password - users password
const std::string& email - users email address
const std::string& phone - users phone number
util::UserType type - type of user (ADMIN, CUSTOMER, TECHNICIAN)
Return type: void
*/
void UserManagementService::createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type) void UserManagementService::createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type)
{ {
InventoryManagementService inventoryManagementService; InventoryManagementService inventoryManagementService;
@@ -93,15 +72,6 @@ void UserManagementService::createUser(const std::string& username, const std::s
} }
} }
/*
Function: updateUserDetails
Description: Updates the email and phone details of an existing user.
Throws an exception if the user does not exist.
Parameter: const std::string& userID - ID of the user to update
const std::string& email - new email address
const std::string& phone - new phone number
Return type: void
*/
void UserManagementService::updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone) void UserManagementService::updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone)
{ {
auto& usersMap = m_dataStore.getUsers(); auto& usersMap = m_dataStore.getUsers();
@@ -115,6 +85,67 @@ void UserManagementService::updateUserDetails(const std::string& userID, const s
user->setPhone(phone); user->setPhone(phone);
} }
/*
Function: getUsers
Description: Retrieves all users stored in the DataStore.
Parameter: None
Return type: util::Map<std::string, User*>
*/
util::Map<std::string, User*> UserManagementService::getUsers()
{
return m_dataStore.getUsers();
}
util::Map<std::string, User*> UserManagementService::getUsers(util::UserType type)
{
util::Map<std::string, User*>& currentUsers = m_dataStore.getUsers();
util::Map<std::string, User*> filteredUsersMap;
for (int iterator = 0; iterator < currentUsers.getSize(); iterator++)
{
User* currentUser = currentUsers.getValueAt(iterator);
if (currentUser->getUserType() == type)
{
filteredUsersMap.insert(currentUser->getId(), currentUser);
}
}
return filteredUsersMap;
}
/*
Function: getUser
Description: Retrieves a specific user by ID from the DataStore.
Parameter: const std::string& userID - ID of the user
Return type: User*
*/
User* UserManagementService::getUser(const std::string& userID)
{
int index = m_dataStore.getUsers().find(userID);
if (index != -1)
{
return m_dataStore.getUsers().getValueAt(index);
}
return nullptr;
}
/*
Function: removeUser
Description: Marks a user as inactive in the DataStore instead of deleting them.
Parameter: const std::string& userID - ID of the user to remove
Return type: void
*/
void UserManagementService::removeUser(const std::string& userID)
{
int index = m_dataStore.getUsers().find(userID);
if (index != -1)
{
User* user = m_dataStore.getUsers().getValueAt(index);
if (user != nullptr)
{
user->setState(util::State::INACTIVE);
}
}
}
/* /*
Function: getUserNotifications Function: getUserNotifications
Description: Retrieves all notifications associated with a given user ID. Description: Retrieves all notifications associated with a given user ID.
@@ -140,7 +171,7 @@ util::Vector<Notification*> UserManagementService::getUserNotifications(const st
util::Vector<Notification*> notificationsVector; util::Vector<Notification*> notificationsVector;
for (int index = 0; index < numberOfNotifications; index++) for (int index = 0; index < numberOfNotifications; index++)
{ {
notificationsVector.push_back(notifications.getValueAt(index)); notificationsVector.push_back(notifications.getValueAt(index));
} }
return notificationsVector; return notificationsVector;
} }
@@ -177,18 +208,6 @@ void UserManagementService::deleteNotification(const std::string& notificationID
notifications.remove(notificationID); notifications.remove(notificationID);
} }
/*
Function: loadUsers
Description: Loads users and notifications from persistent storage into the datastore.
Validates that each notifications recipient exists and attaches the
notification to the corresponding user.
Parameters:
- None
Returns:
- void
Throws:
- std::runtime_error if a notification recipient user ID is invalid
*/
void UserManagementService::loadUsers() void UserManagementService::loadUsers()
{ {
util::FileManager<User> userFileManager(config::file::USER_FILE); util::FileManager<User> userFileManager(config::file::USER_FILE);
@@ -216,15 +235,6 @@ void UserManagementService::loadUsers()
} }
} }
/*
Function: saveUsers
Description: Saves users and their notifications from the datastore to persistent storage.
Collects notifications from all users into a single map before saving.
Parameters:
- None
Returns:
- void
*/
void UserManagementService::saveUsers() void UserManagementService::saveUsers()
{ {
util::FileManager<User> userFileManager(config::file::USER_FILE); util::FileManager<User> userFileManager(config::file::USER_FILE);
@@ -243,4 +253,4 @@ void UserManagementService::saveUsers()
} }
userFileManager.save(users); userFileManager.save(users);
notificationFileManager.save(notifications); notificationFileManager.save(notifications);
} }
@@ -1,8 +1,7 @@
/* /*
File: UserManagementService.h File: UserManagementService.h
Description: Header file declaring the UserManagementService class, which manages Description: Header file declaring the UserManagementService class, which manages
user creation, updates, retrieval, removal, notifications, and ensures user creation, updates, retrieval, removal, and notification handling.
the existence of an admin account.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
@@ -1,8 +1,7 @@
/* /*
File: Config.h File: Config.h
Description: Header file declaring configuration constants for the Vehicle Service System. Description: Defines configuration constants for system thresholds in the Vehicle Service Management System.
Includes default admin account details such as username, name, password, Includes limits for inventory stock alerts and payment reminder intervals.
email, and phone number.
Author: Trenser Author: Trenser
Date: 21-May-2026 Date: 21-May-2026
*/ */
@@ -15,7 +14,7 @@ namespace config
{ {
constexpr const char* DEFAULT_ADMIN_USERNAME = "admin"; constexpr const char* DEFAULT_ADMIN_USERNAME = "admin";
constexpr const char* DEFAULT_ADMIN_NAME = "admin"; constexpr const char* DEFAULT_ADMIN_NAME = "admin";
constexpr const char* DEFAULT_ADMIN_PASSWORD = ""; constexpr const char* DEFAULT_ADMIN_PASSWORD = "admin";
constexpr const char* DEFAULT_ADMIN_EMAIL = "admin@vss"; constexpr const char* DEFAULT_ADMIN_EMAIL = "admin@vss";
constexpr const char* DEFAULT_ADMIN_PHONE = "0000000000"; constexpr const char* DEFAULT_ADMIN_PHONE = "0000000000";
} }
@@ -22,7 +22,8 @@ namespace util
enum class PaymentMode enum class PaymentMode
{ {
ONLINE, ONLINE,
OFFLINE OFFLINE,
NOTSET
}; };
enum class PaymentStatus enum class PaymentStatus
@@ -33,8 +34,10 @@ namespace util
enum class ServiceJobStatus enum class ServiceJobStatus
{ {
PENDING,
STARTED, STARTED,
COMPLETED COMPLETED,
CANCELLED
}; };
enum class State enum class State
@@ -108,6 +111,8 @@ namespace util
return "ONLINE"; return "ONLINE";
case PaymentMode::OFFLINE: case PaymentMode::OFFLINE:
return "OFFLINE"; return "OFFLINE";
case PaymentMode::NOTSET:
return "NOTSET";
} }
throw std::invalid_argument("Invalid PaymentMode"); throw std::invalid_argument("Invalid PaymentMode");
} }
@@ -192,10 +197,14 @@ namespace util
{ {
switch (status) switch (status)
{ {
case ServiceJobStatus::PENDING:
return "PENDING";
case ServiceJobStatus::STARTED: case ServiceJobStatus::STARTED:
return "STARTED"; return "STARTED";
case ServiceJobStatus::COMPLETED: case ServiceJobStatus::COMPLETED:
return "COMPLETED"; return "COMPLETED";
case ServiceJobStatus::CANCELLED:
return "CANCELLED";
} }
throw std::invalid_argument("Invalid ServiceJobStatus"); throw std::invalid_argument("Invalid ServiceJobStatus");
} }
@@ -220,6 +229,14 @@ namespace util
{ {
return ServiceJobStatus::COMPLETED; return ServiceJobStatus::COMPLETED;
} }
if (value == "PENDING")
{
return ServiceJobStatus::PENDING;
}
if (value == "CANCELLED")
{
return ServiceJobStatus::CANCELLED;
}
throw std::invalid_argument("Invalid ServiceJobStatus string"); throw std::invalid_argument("Invalid ServiceJobStatus string");
} }
@@ -1,12 +1,3 @@
/*
File: FileHelper.h
Description: Provides utility functions for loading and saving records
from and to CSV-like text files. Ensures files are created
if missing and supports simple record persistence.
Author: Trenser
Date: 22-May-2026
*/
#pragma once #pragma once
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -15,17 +6,6 @@ Date: 22-May-2026
namespace util namespace util
{ {
/*
Function: loadRecords
Description: Loads records from a given file path into a vector of strings.
Skips the header line if present. Creates the file if it does not exist.
Parameters:
- filePath: const std::string&, path to the file
Returns:
- util::Vector<std::string>: Vector containing all records (excluding header)
Throws:
- None (creates file if missing)
*/
inline util::Vector<std::string> loadRecords(const std::string& filePath) inline util::Vector<std::string> loadRecords(const std::string& filePath)
{ {
util::Vector<std::string> records; util::Vector<std::string> records;
@@ -50,18 +30,6 @@ namespace util
return records; return records;
} }
/*
Function: saveRecords
Description: Saves records to a given file path. Overwrites existing content
and writes a header line followed by all records.
Parameters:
- filePath: const std::string&, path to the file
- records: const util::Vector<std::string>&, vector of records to save
Returns:
- void
Throws:
- std::runtime_error if the file cannot be opened for writing
*/
inline void saveRecords(const std::string& filePath, const util::Vector<std::string>& records) inline void saveRecords(const std::string& filePath, const util::Vector<std::string>& records)
{ {
std::ofstream file(filePath, std::ios::trunc); std::ofstream file(filePath, std::ios::trunc);
@@ -1,17 +1,6 @@
/*
File: FileManager.h
Description: Declares and implements a generic FileManager template class for
loading and saving objects to and from files. Uses serialization
and deserialization methods defined in the object type T.
Provides persistence support for system entities such as Users,
Services, InventoryItems, etc.
Author: Trenser
Date: 22-May-2026
*/
#pragma once #pragma once
#include <stdexcept>
#include <string> #include <string>
#include <stdexcept>
#include <fstream> #include <fstream>
#include "Vector.h" #include "Vector.h"
#include "Map.h" #include "Map.h"
@@ -32,18 +21,6 @@ namespace util
void save(const objects<T>&); void save(const objects<T>&);
}; };
/*
Function: load
Description: Loads records from the file into a map of objects.
Skips the header line, deserializes each record into an object of type T,
and stores them in a map keyed by object ID.
Parameters:
- None
Returns:
- util::Map<std::string, T*> containing deserialized objects
Throws:
- std::runtime_error if deserialization fails for any record
*/
template <typename T> template <typename T>
objects<T> FileManager<T>::load() objects<T> FileManager<T>::load()
{ {
@@ -81,17 +58,6 @@ namespace util
return records; return records;
} }
/*
Function: save
Description: Saves records to the file. Serializes each object of type T into a string,
writes a header line, and then writes all serialized records to the file.
Parameters:
- records: const util::Map<std::string, T*>&, map of objects to save
Returns:
- void
Throws:
- std::runtime_error if the file cannot be opened for writing
*/
template <typename T> template <typename T>
void FileManager<T>::save(const objects<T>& records) void FileManager<T>::save(const objects<T>& records)
{ {
@@ -1,26 +1,8 @@
/*
File: StringHelper.h
Description: Provides utility functions for extracting numeric values from strings.
Useful for parsing IDs, codes, or mixed alphanumeric inputs where
digits need to be isolated and converted into integers.
Author: Trenser
Date: 22-May-2026
*/
#include <cctype> #include <cctype>
#include <string> #include <string>
namespace util namespace util
{ {
/*
Function: extractNumber
Description: Extracts all digits from the given string and converts them into an integer.
Ignores non-digit characters. For example, "abc123xyz" returns 123.
Parameters:
- input: const std::string&, the input string containing digits and/or other characters
Returns:
- int: The integer value formed by concatenating all digits in the string
*/
inline int extractNumber(const std::string& input) inline int extractNumber(const std::string& input)
{ {
int result = 0; int result = 0;
@@ -1,18 +1,17 @@
/* /*
File: Utility.h File: Utility.h
Description: Header file declaring utility functions used across the system, Description: Header file declaring utility functions used across the system,
including cost calculation for services and combo packages. including cost calculation for services based on required inventory items.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include "DataStore.h"
#include "FileHelper.h"
#include "InventoryItem.h"
#include "NotificationManagementService.h"
#include "Service.h" #include "Service.h"
#include "ComboPackage.h" #include "ComboPackage.h"
#include "InventoryItem.h"
#include "NotificationManagementService.h"
#include "FileHelper.h"
#include "DataStore.h"
namespace util namespace util
{ {
@@ -38,9 +37,11 @@ namespace util
/* /*
Function: calculateComboServiceEstimatedCost Function: calculateComboServiceEstimatedCost
Description: Calculates the estimated total cost of a combo package by summing Description: Calculates the estimated total cost of a combo package by summing
the labor and parts costs of all services included in the package. the labor cost and parts cost of all services included in the package.
Parameter: const ComboPackage* comboPackage - pointer to the combo package object Parameters:
Return type: double - estimated total cost of the combo package - comboPackage: const ComboPackage*, pointer to the combo package whose cost is to be estimated
Returns:
- double: The estimated total cost of the combo package
*/ */
inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage) inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage)
{ {
@@ -55,20 +56,6 @@ namespace util
return cost; return cost;
} }
/*
Function: loadObservers
Description: Loads observer IDs from a file and attaches the corresponding users
to the notification management service. Validates that each observer ID
exists in the datastore before attaching.
Parameters:
- filePath: const std::string&, path to the file containing observer IDs
- service: NotificationManagementService*, pointer to the notification service
- dataStore: DataStore&, reference to the datastore containing users
Returns:
- void
Throws:
- std::runtime_error if an observer ID is invalid (not found in datastore)
*/
inline void loadObservers(const std::string& filePath, NotificationManagementService* service, DataStore& dataStore) inline void loadObservers(const std::string& filePath, NotificationManagementService* service, DataStore& dataStore)
{ {
auto observerIDs = util::loadRecords(filePath); auto observerIDs = util::loadRecords(filePath);
@@ -85,16 +72,6 @@ namespace util
} }
} }
/*
Function: saveObservers
Description: Saves the current observer IDs from the notification management service
to a file for persistence.
Parameters:
- filePath: const std::string&, path to the file where observer IDs will be saved
- service: NotificationManagementService*, pointer to the notification service
Returns:
- void
*/
inline void saveObservers(const std::string& filePath, NotificationManagementService* service) inline void saveObservers(const std::string& filePath, NotificationManagementService* service)
{ {
auto observerIDs = service->getObserverIDs(); auto observerIDs = service->getObserverIDs();
File diff suppressed because it is too large Load Diff
@@ -1,12 +1,11 @@
/* /*
File: AdminMenu.h File: AdminMenu.h
Description: Declares the AdminMenu class which provides the administrative console menu in the Vehicle Service Management System. Description: Header file declaring the AdminMenu class, which provides
Supports operations such as inventory management, job assignment, service creation/removal, technician management, administrative operations such as inventory management,
combo package handling, notification viewing, and account management functions like logout and password change. user management, service configuration, and notifications.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include "Controller.h" #include "Controller.h"
@@ -1,30 +1,41 @@
/* /*
File: CustomerMenu.cpp File: CustomerMenu.cpp
Description: Implementation file containing the method definitions of the Description: Implements the CustomerMenu class which provides the customers console interface
CustomerMenu class, including menu handling, service selection, in the Vehicle Service Management System. Handles menu display, user input, and
combo package booking, profile updates, and password management. customer-specific operations such as booking services, viewing history, managing payments,
invoices, and notifications.
Author: Trenser Author: Trenser
Date:19-May-2026 Date: 19-May-2026
*/ */
#include <iomanip> #include <iomanip>
#include <iostream>
#include "ComboPackage.h" #include "ComboPackage.h"
#include "CustomerMenu.h" #include "CustomerMenu.h"
#include "Enums.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "InventoryItem.h" #include "InventoryItem.h"
#include "Invoice.h"
#include "Map.h" #include "Map.h"
#include "MenuHelper.h" #include "MenuHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "Service.h" #include "Service.h"
#include "ServiceBooking.h"
#include "Timestamp.h"
#include "User.h"
#include "Utility.h"
#include "Validator.h" #include "Validator.h"
#include "Vector.h" #include "Vector.h"
/* /*
Function: showMenu Function: showMenu
Description: Displays the customer menu and handles user input until logout is selected. Description: Displays the customer menu in a loop until the user chooses to logout.
Parameter: None Handles exceptions and ensures smooth user interaction.
Return type: void Parameters:
- None
Returns:
- void
*/ */
void CustomerMenu::showMenu() void CustomerMenu::showMenu()
{ {
while (true) while (true)
@@ -59,12 +70,6 @@ void CustomerMenu::showMenu()
} }
} }
/*
Function: handleOperation
Description: Executes the corresponding customer operation based on the selected menu choice.
Parameter: int choice - selected menu option
Return type: bool - true if menu continues, false if logout
*/
bool CustomerMenu::handleOperation(int choice) bool CustomerMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -106,34 +111,28 @@ bool CustomerMenu::handleOperation(int choice)
return true; return true;
} }
/*
Function: logout
Description: Logs out the currently authenticated customer user.
Parameter: None
Return type: void
*/
void CustomerMenu::logout() void CustomerMenu::logout()
{ {
m_controller.logout(); m_controller.logout();
} }
/*
Function: changePassword
Description: Allows the customer to change their password after validation.
Parameter: None
Return type: void
*/
void CustomerMenu::changePassword() void CustomerMenu::changePassword()
{ {
changePasswordHelper(m_controller); std::string newPassword;
util::clear();
std::cout << "Enter new password: ";
util::read(newPassword);
m_controller.changePassword(newPassword);
if (!util::isPasswordValid(newPassword))
{
std::cout << "Error: Password is not strong enough!";
util::pressEnter();
return;
}
std::cout << "Password changed successfully";
util::pressEnter();
} }
/*
Function: updateDetails
Description: Allows the customer to update their email and phone number after validation.
Parameter: None
Return type: void
*/
void CustomerMenu::updateDetails() void CustomerMenu::updateDetails()
{ {
std::string email, phone; std::string email, phone;
@@ -159,13 +158,49 @@ void CustomerMenu::updateDetails()
util::pressEnter(); util::pressEnter();
} }
/* static const Service* selectServiceFromServices(const util::Map<std::string, const Service*>& services)
Function: selectService {
Description: Allows the customer to select a service, provide vehicle details, util::Map<int, const Service*> activeServicesMap;
and book the service through the controller. int currentIndex = 1;
Parameter: None int userInputIndex;
Return type: void std::cout << std::left
*/ << std::setw(10) << "Index"
<< std::setw(15) << "Service ID"
<< std::setw(25) << "Service Name"
<< std::setw(15) << "Estimated Cost"
<< std::endl;
for (int index = 0; index < services.getSize(); index++)
{
const Service* currentService = services.getValueAt(index);
if (currentService->getState() != util::State::ACTIVE)
{
continue;
}
activeServicesMap.insert(currentIndex, currentService);
double partsCost = util::calculatePartsCost(currentService);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentService->getId()
<< std::setw(25) << currentService->getName()
<< std::setw(15) << (currentService->getLaborCost() + partsCost)
<< std::endl;
currentIndex++;
}
if (activeServicesMap.getSize() == 0)
{
std::cout << "No active services available." << std::endl;
return nullptr;
}
std::cout << "Enter service index: ";
util::read(userInputIndex);
if (activeServicesMap.find(userInputIndex) == -1)
{
std::cout << "Invalid service index." << std::endl;
return nullptr;
}
return activeServicesMap[userInputIndex];
}
void CustomerMenu::selectService() void CustomerMenu::selectService()
{ {
std::string vehicleNumber, vehicleBrand, vehicleModel; std::string vehicleNumber, vehicleBrand, vehicleModel;
@@ -192,13 +227,48 @@ void CustomerMenu::selectService()
util::pressEnter(); util::pressEnter();
} }
/* static const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
Function: selectComboPackage {
Description: Allows the customer to select a combo package, provide vehicle details, util::Map<int, const ComboPackage*> activeComboPackages;
and book the package through the controller. int currentIndex = 1;
Parameter: None int userInputIndex;
Return type: void std::cout << std::left
*/ << std::setw(10) << "Index"
<< std::setw(15) << "Combo Package ID"
<< std::setw(15) << "Combo Package Name"
<< std::setw(15) << "Estimate Cost"
<< std::endl;
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(25) << currentComboPackage->getPackageName()
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
if (activeComboPackages.getSize() == 0)
{
std::cout << "No active combo packages available." << std::endl;
return nullptr;
}
std::cout << "Enter combo package index: ";
util::read(userInputIndex);
if (activeComboPackages.find(userInputIndex) == -1)
{
std::cout << "Invalid combo package index." << std::endl;
return nullptr;
}
return activeComboPackages[userInputIndex];
}
void CustomerMenu::selectComboPackage() void CustomerMenu::selectComboPackage()
{ {
std::string vehicleNumber, vehicleBrand, vehicleModel; std::string vehicleNumber, vehicleBrand, vehicleModel;
@@ -225,14 +295,193 @@ void CustomerMenu::selectComboPackage()
void CustomerMenu::viewServiceHistory() void CustomerMenu::viewServiceHistory()
{ {
util::clear();
bool hasServiceHistory = false;
const User* currentUser = m_controller.getAuthenticatedUser();
std::string currentUserID = currentUser->getId();
util::Map<std::string, const ServiceBooking*> serviceBookingsByCurrentUser = m_controller.getServiceBookingsByUser(currentUserID);
if (serviceBookingsByCurrentUser.getSize() != 0)
{
std::cout << std::left
<< std::setw(12) << "Booking ID"
<< std::setw(20) << "Technician"
<< std::setw(15) << "Vehicle Brand"
<< std::setw(15) << "Vehicle Number"
<< std::setw(15) << "Vehicle Model"
<< std::setw(10) << "Discount %"
<< std::setw(12) << "Status"
<< std::endl;
for (int iterator = 0; iterator < serviceBookingsByCurrentUser.getSize(); iterator++)
{
const ServiceBooking* currentBooking = serviceBookingsByCurrentUser.getValueAt(iterator);
std::string technicianName = currentBooking->getAssignedTechnician() == nullptr
? "Not Assigned"
: currentBooking->getAssignedTechnician()->getName();
std::cout << std::left
<< std::setw(12) << currentBooking->getId()
<< std::setw(20) << technicianName
<< std::setw(15) << currentBooking->getVehicleBrand()
<< std::setw(15) << currentBooking->getVehicleNumber()
<< std::setw(15) << currentBooking->getVehicleModel()
<< std::setw(10) << currentBooking->getDiscountPercentage()
<< std::setw(12) << util::getServiceJobStatusString(currentBooking->getStatus())
<< std::endl;
hasServiceHistory = true;
}
}
if (!hasServiceHistory)
{
std::cout << "No history available." << std::endl;
}
}
static std::string selectInvoiceFromUserForPayment(const util::Map<std::string, const Invoice*>& currentInvoices)
{
int currentIndex = 1, choice;
util::Map<int, const Invoice*> pendingInvoicesForPayment;
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(12) << "BookingID"
<< std::setw(15) << "VehicleBrand"
<< std::setw(15) << "VehicleNumber"
<< std::setw(12) << "TechID"
<< std::setw(20) << "TechnicianName"
<< std::setw(10) << "Discount(%)"
<< std::setw(12) << "TotalAmount"
<< std::setw(20) << "InvoiceDate"
<< std::endl;
for (int iterator = 0; iterator < currentInvoices.getSize(); iterator++)
{
const Invoice* currentInvoice = currentInvoices.getValueAt(iterator);
if (currentInvoice && currentInvoice->getStatus() == util::PaymentStatus::PENDING)
{
std::cout << std::left
<< std::setw(6) << currentIndex
<< std::setw(12) << currentInvoice->getBookingId()
<< std::setw(15) << currentInvoice->getBooking()->getVehicleBrand()
<< std::setw(15) << currentInvoice->getBooking()->getVehicleNumber()
<< std::setw(12) << currentInvoice->getBooking()->getAssignedTechnician()->getId()
<< std::setw(20) << currentInvoice->getBooking()->getAssignedTechnician()->getName()
<< std::setw(10) << currentInvoice->getDiscountPercentage()
<< std::setw(12) << currentInvoice->getTotalAmount()
<< std::setw(20) << currentInvoice->getInvoiceDate().toString()
<< std::endl;
pendingInvoicesForPayment.insert(currentIndex++, currentInvoice);
}
}
if (pendingInvoicesForPayment.getSize() == 0)
{
std::cout << "No pending invoices available for payment.\n";
return "";
}
std::cout << "Select the Invoice to pay (Index): ";
util::read(choice);
int selectedIndex = pendingInvoicesForPayment.find(choice);
if (selectedIndex != -1)
{
const Invoice* selectedInvoice = pendingInvoicesForPayment.getValueAt(selectedIndex);
return selectedInvoice->getId();
}
else
{
std::cout << "Invalid choice.\n";
return "";
}
}
static util::PaymentMode selectPaymentMode()
{
int choice;
std::cout << "Enter the payment Mode\n1.OFFLINE\n2.ONLINE\nChoice: ";
util::read(choice);
if (choice == 1)
{
std::cout << "Offline mode selected.\n";
return util::PaymentMode::OFFLINE;
}
else if (choice == 2)
{
std::cout << "Online mode selected.\n";
return util::PaymentMode::ONLINE;
}
else
{
std::cout << "Invalid choice, Offline mode selected.\n";
return util::PaymentMode::OFFLINE;
}
} }
void CustomerMenu::completePayments() void CustomerMenu::completePayments()
{ {
util::clear();
util::Map<std::string, const Invoice*> currentInvoices = m_controller.getInvoicesByUser();
std::string selectedID = selectInvoiceFromUserForPayment(currentInvoices);
if (selectedID == "")
{
std::cout << "Payment failed.\n";
return;
}
util::PaymentMode paymentMode = selectPaymentMode();
m_controller.completePayment(selectedID, paymentMode);
std::cout << "Payment completed successfully.\n";
}
static void displayInvoices(util::Map<std::string, const Invoice*> currentUserInvoices)
{
if (currentUserInvoices.getSize() == 0)
{
std::cout << "No invoices found for this account." << std::endl;
util::pressEnter();
return;
}
else
{
for (int index = 0; index < currentUserInvoices.getSize(); index++)
{
const Invoice* currentInvoice = currentUserInvoices.getValueAt(index);
if (currentInvoice)
{
std::cout << "\nInvoice Details\n";
std::cout << "Booking ID: " << currentInvoice->getBookingId() << std::endl;
std::cout << "Vehicle Brand: " << currentInvoice->getBooking()->getVehicleBrand() << std::endl;
std::cout << "Vehicle Number: " << currentInvoice->getBooking()->getVehicleNumber() << std::endl;
std::cout << "Technician ID: " << currentInvoice->getBooking()->getAssignedTechnician()->getId() << std::endl;
std::cout << "Technician Name: " << currentInvoice->getBooking()->getAssignedTechnician()->getName() << std::endl;
std::cout << "Discount(%): " << currentInvoice->getDiscountPercentage() << std::endl;
std::cout << "Total Amount: " << currentInvoice->getTotalAmount() << std::endl;
std::cout << "Invoice Date: " << currentInvoice->getInvoiceDate().toString() << std::endl;
std::cout << "Payment Status: " << util::getPaymentStatusString(currentInvoice->getStatus()) << std::endl;
auto inventoryItemsInInvoice = currentInvoice->getParts();
std::cout << "\nItems Used:\n";
std::cout << std::left
<< std::setw(20) << "ItemName"
<< std::setw(10) << "Quantity"
<< std::setw(10) << "Price"
<< std::endl;
std::cout << std::string(40, '-') << std::endl;
for (int iterator = 0; iterator < inventoryItemsInInvoice.getSize(); iterator++)
{
InventoryItem* currentItem = inventoryItemsInInvoice.getValueAt(iterator);
std::cout << std::left
<< std::setw(20) << currentItem->getPartName()
<< std::setw(10) << currentItem->getQuantity()
<< std::setw(10) << currentItem->getPrice()
<< std::endl;
}
}
else
{
throw std::runtime_error("Null invoice encountered while displaying invoices.");
}
}
}
} }
void CustomerMenu::viewInvoices() void CustomerMenu::viewInvoices()
{ {
util::clear();
util::Map<std::string, const Invoice*> currentUserInvoices = m_controller.getInvoicesByUser();
displayInvoices(currentUserInvoices);
} }
/* /*
@@ -248,6 +497,38 @@ void CustomerMenu::viewNotifications()
viewAndDeleteNotification(m_controller); viewAndDeleteNotification(m_controller);
} }
/*
Function: getNotificationPreference (static helper)
Description: Helper function to configure notification preferences for a specific service.
Parameters:
- serviceName: Name of the service for which notifications are being configured.
Returns:
- bool: True if notifications are enabled, False if disabled.
*/
static bool getNotificationPreference(const std::string& serviceName)
{
int choice;
while (true)
{
util::clear();
std::cout << " Configure Notification Preferences\n";
std::cout << "\n" << serviceName << " Notifications\n";
std::cout << "1. Enable Notifications\n";
std::cout << "2. Disable Notifications\n";
std::cout << "Enter your choice: ";
util::read(choice);
if (choice == 1)
{
return true;
}
if (choice == 2)
{
return false;
}
std::cout << "\nInvalid choice. Please enter 1 or 2.\n";
util::pressEnter();
}
}
/* /*
Function: configureNotifications Function: configureNotifications
@@ -1,11 +1,10 @@
/* /*
File: CustomerMenu.h File: CustomerMenu.h
Description: Header file declaring the CustomerMenu class, which provides Description: Declares the CustomerMenu class which provides the customer-facing console menu in the Vehicle Service Management System.
customer operations such as selecting services, booking combo Supports operations such as account management, service selection, combo package booking, viewing service history,
packages, updating profile details, managing payments, viewing handling payments and invoices, and managing notifications.
invoices, and configuring notifications.
Author: Trenser Author: Trenser
Date:19-May-2026 Date: 19-May-2026
*/ */
#pragma once #pragma once
@@ -1,33 +1,31 @@
/* /*
File: MenuHelper.h File: MenuHelper.h
Description: Header file declaring the MenuHelper class, which provides Description: Provides inline utility functions to support menu operations in the Vehicle Service Management System.
utility functions for menu-driven operations such as Includes helper functions for selecting, displaying, and managing notifications, as well as
notification selection and display. integrating with the controller for user interactions.
Author: Trenser Author: Trenser
Date: 21-May-2026 Date: 21-May-2026
*/ */
#pragma once #pragma once
#include <iomanip>
#include <string> #include <string>
#include "Controller.h" #include <iomanip>
#include "InputHelper.h"
#include "Map.h"
#include "Notification.h"
#include "OutputHelper.h"
#include "Vector.h" #include "Vector.h"
#include "Validator.h" #include "Controller.h"
#include "Service.h" #include "Notification.h"
#include "ComboPackage.h" #include "Map.h"
#include "Utility.h" #include "InputHelper.h"
#include "OutputHelper.h"
/* /*
Function: selectNotification Function: selectNotification
Description: Displays a list of notifications with index, ID, title, and timestamp. Description: Displays a list of notifications with index, ID, title, and timestamp,
Allows the user to select a notification by index. Returns the selected then allows the user to select one by index.
notification or nullptr if the selection is invalid. Parameters:
Parameter: const util::Vector<const Notification*>& notifications - list of notifications - notifications: Vector of Notification pointers to be displayed.
Return type: const Notification* - pointer to the selected notification Returns:
- const Notification* representing the selected notification.
- nullptr if no notifications are available or if the selection is invalid.
*/ */
inline const Notification* selectNotification(const util::Vector<const Notification*>& notifications) inline const Notification* selectNotification(const util::Vector<const Notification*>& notifications)
{ {
@@ -116,172 +114,3 @@ inline void viewAndDeleteNotification(Controller& controller)
controller.deleteNotification(selectedNotification->getId()); controller.deleteNotification(selectedNotification->getId());
util::pressEnter(); util::pressEnter();
} }
/*
Function: changePassword
Description: Helper function to change password
Parameter: controller: Reference to the Controller object used to manage notifications.
Return type: void
*/
inline void changePasswordHelper(Controller& controller)
{
std::string newPassword;
while (true)
{
util::clear();
std::cout << "Enter new password: ";
util::read(newPassword);
if (!util::isPasswordValid(newPassword))
{
std::cout << "Error: Password is not strong enough!\n";
util::pressEnter();
continue;
}
controller.changePassword(newPassword);
std::cout << "Password changed successfully\n";
util::pressEnter();
break;
}
}
/*
Function: selectServiceFromServices
Description: Displays active services and allows the customer to select one by index.
Parameter: const util::Map<std::string, const Service*>& services - list of services
Return type: const Service* - selected service
*/
inline const Service* selectServiceFromServices(const util::Map<std::string, const Service*>& services)
{
util::Map<int, const Service*> activeServicesMap;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Service ID"
<< std::setw(25) << "Service Name"
<< std::setw(15) << "Estimated Cost"
<< std::endl;
for (int index = 0; index < services.getSize(); index++)
{
const Service* currentService = services.getValueAt(index);
if (currentService->getState() != util::State::ACTIVE)
{
continue;
}
activeServicesMap.insert(currentIndex, currentService);
double partsCost = util::calculatePartsCost(currentService);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentService->getId()
<< std::setw(25) << currentService->getName()
<< std::setw(15) << (currentService->getLaborCost() + partsCost)
<< std::endl;
currentIndex++;
}
if (activeServicesMap.getSize() == 0)
{
std::cout << "No active services available." << std::endl;
return nullptr;
}
std::cout << "Enter service index: ";
util::read(userInputIndex);
if (activeServicesMap.find(userInputIndex) == -1)
{
std::cout << "Invalid service index." << std::endl;
return nullptr;
}
return activeServicesMap[userInputIndex];
}
/*
Function: selectComboPackageFromPackages
Description: Displays active combo packages and allows the customer to select one by index.
Parameter: const util::Map<std::string, const ComboPackage*>& comboPackages - list of combo packages
Return type: const ComboPackage* - selected combo package
*/
inline const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
{
util::Map<int, const ComboPackage*> activeComboPackages;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Combo Package ID"
<< std::setw(15) << "Combo Package Name"
<< std::setw(15) << "Estimate Cost"
<< std::endl;
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(25) << currentComboPackage->getPackageName()
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
if (activeComboPackages.getSize() == 0)
{
std::cout << "No active combo packages available." << std::endl;
return nullptr;
}
std::cout << "Enter combo package index: ";
util::read(userInputIndex);
if (activeComboPackages.find(userInputIndex) == -1)
{
std::cout << "Invalid combo package index." << std::endl;
return nullptr;
}
return activeComboPackages[userInputIndex];
}
/*
Function: sendLowStockAlertsToAdmins (static helper)
Description: Sends low stock alert notifications to all admin users for a given inventory item.
Parameters:
- inventoryManagementService: InventoryManagementService&, service used to send notifications
- inventoryItem: const InventoryItem*, pointer to the low-stock inventory item
- adminUsers: const util::Vector<User*>&, list of admin users to notify
Returns:
- None
*/
/*
Function: getNotificationPreference (static helper)
Description: Helper function to configure notification preferences for a specific service.
Parameters:
- serviceName: Name of the service for which notifications are being configured.
Returns:
- bool: True if notifications are enabled, False if disabled.
*/
inline bool getNotificationPreference(const std::string& serviceName)
{
int choice;
while (true)
{
util::clear();
std::cout << " Configure Notification Preferences\n";
std::cout << "\n" << serviceName << " Notifications\n";
std::cout << "1. Enable Notifications\n";
std::cout << "2. Disable Notifications\n";
std::cout << "Enter your choice: ";
util::read(choice);
if (choice == 1)
{
return true;
}
if (choice == 2)
{
return false;
}
std::cout << "\nInvalid choice. Please enter 1 or 2.\n";
util::pressEnter();
}
}
@@ -1,16 +1,21 @@
/* /*
File: TechnicianMenu.cpp File: TechnicianMenu.cpp
Description: Implements the TechnicianMenu class which provides the technicians console interface Description: Implementation file containing the method definitions of the
in the Vehicle Service Management System. Handles menu display, user input, and TechnicianMenu class, including menu handling, job completion,
technician-specific operations such as completing jobs and viewing notifications. notification viewing, password management, and logout logic.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#include "TechnicianMenu.h" #include <iomanip>
#include "Enums.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "JobCard.h"
#include "MenuHelper.h" #include "MenuHelper.h"
#include "OutputHelper.h"
#include "Service.h"
#include "TechnicianMenu.h"
#include "Validator.h"
/* /*
Function: showMenu Function: showMenu
@@ -23,35 +28,124 @@ Returns:
*/ */
void TechnicianMenu::showMenu() void TechnicianMenu::showMenu()
{ {
bool isMenuActive = true; while (true)
while (isMenuActive) {
{ try
try {
{ int choice;
int choice; util::clear();
util::clear(); std::cout << "Technician Menu"
std::cout << "" << std::endl; << "\n1. Mark Job as Completed"
util::read(choice); << "\n2. View Notifications"
if (!handleOperation(choice)) << "\n3. Change Password"
{ << "\n4. Logout"
isMenuActive = false; << "\nEnter a choice: ";
} util::read(choice);
} if (!handleOperation(choice))
catch (const std::exception& e) {
{ break;
std::cout << "Exception: " << e.what() << std::endl; }
util::pressEnter(); }
} catch (const std::exception& e)
} {
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
} }
/*
Function: handleOperation
Description: Executes the corresponding technician operation based on the selected menu choice.
Parameter: int choice - selected menu option
Return type: bool - true if menu continues, false if logout
*/
bool TechnicianMenu::handleOperation(int choice) bool TechnicianMenu::handleOperation(int choice)
{ {
return false; switch (choice)
{
case 1:
completeJob();
break;
case 2:
viewNotifications();
break;
case 3:
changePassword();
break;
case 4:
logout();
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
util::pressEnter();
}
return true;
} }
static std::string selectJobCardToComplete(util::Map<std::string, const JobCard*>& assignedJobCards, util::Map<int, const JobCard*>& incompleteJobCards)
{
int currentIndex = 1;
int choice;
bool hasIncompleteJobCard = false;
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(12) << "BookingID"
<< std::setw(12) << "JobID"
<< std::setw(20) << "ServiceName"
<< std::setw(12) << "ServiceID"
<< std::endl;
for (int iterator = 0; iterator < assignedJobCards.getSize(); iterator++)
{
const JobCard* currentJobCard = assignedJobCards.getValueAt(iterator);
if (currentJobCard && (currentJobCard->getStatus() == util::ServiceJobStatus::STARTED))
{
std::cout << std::left << std::setw(6) << currentIndex
<< std::setw(12) << currentJobCard->getBookingId()
<< std::setw(12) << currentJobCard->getId()
<< std::setw(20) << currentJobCard->getService()->getName()
<< std::setw(12) << currentJobCard->getServiceId()
<< std::endl;
hasIncompleteJobCard = true;
incompleteJobCards.insert(currentIndex++, currentJobCard);
}
}
if (!hasIncompleteJobCard)
{
std::cout << "No pending jobs are present.\n";
return "";
}
std::cout << "Select the Job Card to complete (Index): ";
util::read(choice);
int selectedJobCardIndex = incompleteJobCards.find(choice);
if (selectedJobCardIndex != -1)
{
const JobCard* selectedJobCard = incompleteJobCards.getValueAt(selectedJobCardIndex);
return selectedJobCard->getId();
}
else
{
std::cout << "Invalid choice.\n";
return "";
}
}
void TechnicianMenu::completeJob() void TechnicianMenu::completeJob()
{ {
util::Map<std::string, const JobCard*> assignedJobCards = m_controller.getJobCardsByUser();
util::Map<int, const JobCard*> incompleteJobCards;
std::cout << "Jobs to be completed.\n";
std::string selectedJobID = selectJobCardToComplete(assignedJobCards, incompleteJobCards);
if (selectedJobID == "")
{
std::cout << "Failed to complete the job.\n";
}
else
{
m_controller.completeJob(selectedJobID);
std::cout << "Job marked as completed.\n";
}
} }
/* /*
@@ -66,3 +160,41 @@ void TechnicianMenu::viewNotifications()
{ {
viewAndDeleteNotification(m_controller); viewAndDeleteNotification(m_controller);
} }
/*
Function: logout
Description: Logs out the currently authenticated technician user.
Parameter: None
Return type: void
*/
void TechnicianMenu::logout()
{
m_controller.logout();
}
/*
Function: changePassword
Description: Allows the technician to change their password after validation.
Parameter: None
Return type: void
*/
void TechnicianMenu::changePassword()
{
std::string newPassword;
while (true)
{
util::clear();
std::cout << "Enter new password: ";
util::read(newPassword);
if (!util::isPasswordValid(newPassword))
{
std::cout << "Error: Password is not strong enough!\n";
util::pressEnter();
continue;
}
m_controller.changePassword(newPassword);
std::cout << "Password changed successfully\n";
util::pressEnter();
break;
}
}
@@ -1,11 +1,11 @@
/* /*
File: TechnicianMenu.h File: TechnicianMenu.h
Description: Declares the TechnicianMenu class which provides the technician-facing console menu in the Vehicle Service Management System. Description: Header file declaring the TechnicianMenu class, which provides
Supports operations such as viewing assigned jobs, completing jobs, and managing notifications. technician operations such as job completion, notification viewing,
password management, and logout functionality.
Author: Trenser Author: Trenser
Date: 19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include "Controller.h" #include "Controller.h"
@@ -18,4 +18,6 @@ public:
void showMenu(); void showMenu();
void completeJob(); void completeJob();
void viewNotifications(); void viewNotifications();
void logout();
void changePassword();
}; };
@@ -5,12 +5,11 @@ Description: Implementation file containing the method definitions of the
and customer registration logic. and customer registration logic.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#include "UserInterface.h" #include "UserInterface.h"
#include "Enums.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "Enums.h"
#include "User.h" #include "User.h"
#include "Validator.h" #include "Validator.h"
@@ -119,11 +118,11 @@ void UserInterface::login()
/* /*
Function: registerCustomer Function: registerCustomer
Description: Registers a new customer by collecting and validating details such as Description: Handles the registration process for new customers.
username, name, email, password, and phone number. Delegates creation Parameters:
to the controller. - None
Parameter: None Returns:
Return type: void - void
*/ */
void UserInterface::registerCustomer() void UserInterface::registerCustomer()
{ {