From 5c5a44876b311a704fc5bf7a21e4b773ec28c4ab Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 14:37:46 +0530 Subject: [PATCH 01/20] Implement Logout functionality CUS002: Logout 1. Connected Controller::logout() with AuthenticationManagementService logout logic. 2. Added logout implementation in AuthenticationManagementService to clear the authenticated user session. 3. Added logout handling in CustomerMenu to invoke controller logout when the user selects the logout option. 4. Added authentication service dependency in Controller for logout support. Logout functionality validation Precondition: 1. System is running. 2. A registered user exists in the data store. 3. User is logged in and customer menu is active. Steps: 1. Launch the application and log in with valid credentials. - Verify that access is granted and customer menu is displayed. 2. Select the Logout option from the customer menu. - Verify that the logout operation is triggered immediately. 3. Complete the logout operation. - Verify that the authenticated user session is cleared. 4. After logout completes. - Verify that the user is redirected to the login menu. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem/controllers/Controller.cpp | 1 + .../Trenser.VehicleServiceSystem/controllers/Controller.h | 3 +++ .../services/AuthenticationManagementService.cpp | 5 +++++ .../Trenser.VehicleServiceSystem/views/CustomerMenu.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..06fe460 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -7,6 +7,7 @@ bool Controller::login(const std::string& username, const std::string& password) void Controller::logout() { + m_authenticationManagementService.logout(); } void Controller::changePassword(const std::string& newPassword) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..0333e80 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index ca07fee..c128d26 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,3 +1,8 @@ #include "AuthenticationManagementService.h" User* AuthenticationManagementService::m_authenticatedUser = nullptr; + +void AuthenticationManagementService::logout() +{ + m_authenticatedUser = nullptr; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..2e5fc75 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -33,6 +33,7 @@ bool CustomerMenu::handleOperation(int choice) void CustomerMenu::logout() { + m_controller.logout(); } void CustomerMenu::changePassword() From cc887b9bc0a3ae8145d3a2f32481bf9e176586fa Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 17:44:38 +0530 Subject: [PATCH 02/20] Implement Change Password CUS003: Implement change password functionality 1. Connected Controller::changePassword() with AuthenticationManagementService password update logic. 2. Added password validation before updating the user password. 3. Added logged-in user check before allowing password changes. 4. Implemented password update logic in AuthenticationManagementService. 5. Added change password flow in CustomerMenu to collect new password input and trigger password update. 6. Added success message display after password is changed successfully. Change password functionality validation Precondition: 1. System is running. 2. A registered user exists in the data store. 3. User is logged in and customer menu is active. Steps: 1. Launch the application and log in with valid credentials. 2. Select the Change Password option from the customer menu. 3. Enter a new password. - Verify that the entered password is validated. 4. If the password is valid, complete the password change. - Verify that the new password is saved successfully. - Verify that the message "Password changed successfully" is displayed. Sreeja Reghukumar, please review --- .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 +++ .../services/AuthenticationManagementService.cpp | 11 +++++++++++ .../views/CustomerMenu.cpp | 14 ++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..931def8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -11,6 +11,7 @@ void Controller::logout() void Controller::changePassword(const std::string& newPassword) { + m_authenticationManagementService.changePassword(newPassword); } void Controller::createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..0333e80 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index ca07fee..4251c95 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,3 +1,14 @@ +#include #include "AuthenticationManagementService.h" +#include "User.h" User* AuthenticationManagementService::m_authenticatedUser = nullptr; + +void AuthenticationManagementService::changePassword(const std::string& newPassword) +{ + if (m_authenticatedUser == nullptr) + { + throw std::runtime_error("There is no user currently logged in!"); + } + m_authenticatedUser->setPassword(newPassword); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..b4cbd8b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,6 +1,7 @@ #include "CustomerMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Validator.h" void CustomerMenu::showMenu() { @@ -37,6 +38,19 @@ void CustomerMenu::logout() void CustomerMenu::changePassword() { + 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(); } void CustomerMenu::updateDetails() From 9c2663db74277a2c47d1b48dbca9222fed459981 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 20:51:34 +0530 Subject: [PATCH 03/20] Implement Update Customer Profile Details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CUS005: Update Customer Profile Details 1. Added update profile flow in CustomerMenu to collect new email and phone number inputs. 2. Added validation for updated email and phone number before saving changes. 3. Updated Controller::updateUserDetails() to fetch the authenticated user and delegate profile update to UserManagementService. 4. Added user existence validation in UserManagementService before updating profile details. 5. Added logic in UserManagementService to update stored email and phone details for the selected user. 6. Added profile update confirmation message after successful save. Update Customer Profile Details Precondition: 1. Application is running and a customer is logged into the system. 2. Customer record exists in DataStore. 3. Customer has existing profile details stored in the system. Steps: 1. Select the Update Profile Details option. 2. Verify that the current profile details are displayed. - Verify that the system shows the customer’s existing details. 3. Enter a new valid email address and phone number. 4. Save the updated details. - Verify that the system accepts the changes and displays a success message. 5. Create or view a future booking using the same customer account. - Verify that the updated profile details are reflected in future bookings. Sreeja Reghukumar, please review --- .../controllers/Controller.cpp | 8 +++++++ .../controllers/Controller.h | 5 +++++ .../services/UserManagementService.cpp | 15 +++++++++++++ .../views/CustomerMenu.cpp | 22 +++++++++++++++++++ 4 files changed, 50 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..0f0bc65 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,4 +1,6 @@ +#include #include "Controller.h" +#include "User.h" bool Controller::login(const std::string& username, const std::string& password) { @@ -28,6 +30,12 @@ void Controller::createTechnician(const std::string& username, const std::string void Controller::updateUserDetails(const std::string& email, const std::string& phone) { + User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (authenticatedUser == nullptr) + { + throw std::runtime_error("No user currently logged in!"); + } + m_userManagementService.updateUserDetails(authenticatedUser->getId(), email, phone); } util::Map Controller::getServices() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..e1ecc49 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,8 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" +#include "UserManagementService.h" class Service; class ComboPackage; @@ -14,6 +16,9 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; + UserManagementService m_userManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 2a5bd9e..4b2cd42 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1 +1,16 @@ +#include #include "UserManagementService.h" +#include "User.h" + +void UserManagementService::updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone) +{ + auto& usersMap = m_dataStore.getUsers(); + int index = usersMap.find(userID); + if (index == -1) + { + throw std::runtime_error("User does not exist!"); + } + User* user = usersMap.getValueAt(index); + user->setEmail(email); + user->setPhone(phone); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..7233f23 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,6 +1,7 @@ #include "CustomerMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Validator.h" void CustomerMenu::showMenu() { @@ -41,6 +42,27 @@ void CustomerMenu::changePassword() void CustomerMenu::updateDetails() { + std::string email, phone; + util::clear(); + std::cout << "Enter new email: "; + util::read(email); + if (!util::isEmailValid(email)) + { + std::cout << "Error: Email is invalid!"; + util::pressEnter(); + return; + } + std::cout << "Enter new phone: "; + util::read(phone); + if (!util::isPhoneNumberValid(phone)) + { + std::cout << "Error: Phone number is invalid!"; + util::pressEnter(); + return; + } + m_controller.updateUserDetails(email, phone); + std::cout << "Profile details updated successfully"; + util::pressEnter(); } void CustomerMenu::selectService() From 76f13b526e3b07048cf585b7a8610a268df8b40c Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 22:39:32 +0530 Subject: [PATCH 04/20] Implement Purchase Individual Service functionality CUS006 Purchase Individual Service 1. Added service selection flow in CustomerMenu to display active services, allow customer to choose a service, and collect vehicle details for booking. 2. Implemented Controller::purchaseService to delegate service booking requests to ServiceManagementService. 3. Added ServiceManagementService::purchaseService logic to validate authenticated user, fetch selected services, create a ServiceBooking, and persist it in DataStore. 4. Updated ServiceBooking constructor and assigned technician handling to use User* references instead of technician name strings. 5. Integrated ServiceManagementService dependency into Controller Validate customer service booking flow and service status tracking Precondition: 1. Customer account exists and is logged into the system. 2. Active services are available in the system. 3. Service bookings can be created and stored in DataStore. 4. Technician account exists to update service status. Steps: 1. Navigate to Customer Menu and select the individual service booking option. 2. View the list of active services and select a service. 3. Enter vehicle number, vehicle brand, and vehicle model, then confirm booking. - Verify that the service booking is created successfully with an initial status. 4. Technician updates the service booking status. - Verify that the latest status is reflected in the system. 5. Customer refreshes or views service booking history. - Verify that the updated status is shown correctly in booking history. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 + .../models/ServiceBooking.cpp | 12 ++-- .../models/ServiceBooking.h | 9 +-- .../services/ServiceManagementService.cpp | 38 ++++++++++ .../utilities/Utility.h | 15 ++++ .../views/CustomerMenu.cpp | 71 +++++++++++++++++++ .../views/MenuHelper.h | 46 ++++++++++++ 9 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..819264c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -176,6 +176,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..de2d1cd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -42,6 +42,7 @@ util::Map Controller::getComboPackages() void Controller::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { + m_serviceManagementService.purchaseService(serviceIDs, vehicleNumber, vehicleBrand, vehicleModel); } void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..8512598 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "ServiceManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + ServiceManagementService m_serviceManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 1fdfaf0..51fc6ff 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -5,10 +5,10 @@ int ServiceBooking::m_uid = 0; ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), + m_assignedTechnician(nullptr), m_discountPercentage(0.0) {} ServiceBooking::ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -17,8 +17,6 @@ ServiceBooking::ServiceBooking( const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel, - const std::string& assignedTechnicianId, - const std::string& assignedTechnician, double discountPercentage ) : m_id("SRV" + std::to_string(++m_uid)), @@ -29,8 +27,8 @@ ServiceBooking::ServiceBooking( m_vehicleNumber(vehicleNumber), m_vehicleBrand(vehicleBrand), m_vehicleModel(vehicleModel), - m_assignedTechnicianId(assignedTechnicianId), - m_assignedTechnician(assignedTechnician), + m_assignedTechnicianId(""), + m_assignedTechnician(nullptr), m_discountPercentage(discountPercentage) { } @@ -80,7 +78,7 @@ const std::string& ServiceBooking::getAssignedTechnicianId() const return m_assignedTechnicianId; } -const std::string& ServiceBooking::getAssignedTechnician() const +User* ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } @@ -135,7 +133,7 @@ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnici m_assignedTechnicianId = assignedTechnicianId; } -void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician) +void ServiceBooking::setAssignedTechnician(User* assignedTechnician) { m_assignedTechnician = assignedTechnician; } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 5ecc1b0..84a8aac 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -19,12 +19,11 @@ private: std::string m_vehicleBrand; std::string m_vehicleModel; std::string m_assignedTechnicianId; - std::string m_assignedTechnician; + User* m_assignedTechnician; double m_discountPercentage; public: ServiceBooking(); ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -33,8 +32,6 @@ public: const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel, - const std::string& assignedTechnicianId, - const std::string& assignedTechnician, double discountPercentage ); const std::string& getId() const; @@ -46,7 +43,7 @@ public: const std::string& getVehicleBrand() const; const std::string& getVehicleModel() const; const std::string& getAssignedTechnicianId() const; - const std::string& getAssignedTechnician() const; + User* getAssignedTechnician() const; double getDiscountPercentage() const; void setId(const std::string& id); void setStatus(const util::ServiceJobStatus& status); @@ -57,6 +54,6 @@ public: void setVehicleBrand(const std::string& vehicleBrand); void setVehicleModel(const std::string& vehicleModel); void setAssignedTechnicianId(const std::string& assignedTechnicianId); - void setAssignedTechnician(const std::string& assignedTechnician); + void setAssignedTechnician(User* assignedTechnician); void setDiscountPercentage(double discountPercentage); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 156c12b..511d81f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1 +1,39 @@ +#include #include "ServiceManagementService.h" +#include "AuthenticationManagementService.h" +#include "Service.h" +#include "ServiceBooking.h" +#include "Factory.h" + +void ServiceManagementService::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) +{ + AuthenticationManagementService m_authenticationManagementService; + auto authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (authenticatedUser == nullptr) + { + throw std::runtime_error("No user is currently logged in!"); + } + auto& servicesMap = m_dataStore.getServices(); + auto& serviceBookingMap = m_dataStore.getServiceBookings(); + util::Map selectedServices; + int selectedServicesCount = serviceIDs.getSize(); + for (int index = 0; index < selectedServicesCount; index++) + { + int serviceIndex = servicesMap.find(serviceIDs[index]); + if (serviceIndex == -1) + { + throw std::runtime_error("Service not found!"); + } + Service* service = servicesMap.getValueAt(serviceIndex); + selectedServices[service->getId()] = service; + } + ServiceBooking* serviceBooking = Factory::getObject(util::ServiceJobStatus::STARTED, selectedServices, authenticatedUser->getId(), authenticatedUser, vehicleNumber, vehicleBrand, vehicleModel, 0); + if (serviceBooking == nullptr) + { + throw std::runtime_error("Failed to create service booking"); + } + serviceBookingMap[serviceBooking->getId()] = serviceBooking; + sendNotification(authenticatedUser, + "Service Booking succeeded", + "Your service booking has been successfully placed with ID " + serviceBooking->getId()); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h new file mode 100644 index 0000000..0450c75 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -0,0 +1,15 @@ +#pragma once +#include "Service.h" +#include "InventoryItem.h" + +inline double calculatePartsCost(const Service* service) +{ + double cost = 0; + auto& requiredInventoryItems = service->getRequiredInventoryItems(); + int requiredInventoryItemsSize = requiredInventoryItems.getSize(); + for (int index = 0; index < requiredInventoryItemsSize; index++) + { + cost += requiredInventoryItems.getValueAt(index)->getPrice(); + } + return cost; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..610347a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,6 +1,12 @@ +#include #include "CustomerMenu.h" +#include "Service.h" +#include "InventoryItem.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Vector.h" +#include "Utility.h" +#include "Map.h" void CustomerMenu::showMenu() { @@ -43,8 +49,73 @@ void CustomerMenu::updateDetails() { } +static const Service* selectServiceFromServices(const util::Map& services) +{ + util::Map 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 = 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() { + std::string vehicleNumber, vehicleBrand, vehicleModel; + auto services = m_controller.getServices(); + util::Vector selectedServices; + util::clear(); + const Service* selectedService = selectServiceFromServices(services); + if (selectedService == nullptr) + { + std::cout << "Failed to book service!"; + util::pressEnter(); + return; + } + selectedServices.push_back(selectedService->getId()); + util::clear(); + std::cout << "Enter vehicle number: "; + util::read(vehicleNumber); + std::cout << "Enter vehicle brand: "; + util::read(vehicleBrand); + std::cout << "Enter vehicle model: "; + util::read(vehicleModel); + m_controller.purchaseService(selectedServices, vehicleNumber, vehicleBrand, vehicleModel); + std::cout << "Service has been booked successfully"; + util::pressEnter(); } void CustomerMenu::selectComboPackage() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h new file mode 100644 index 0000000..3ff1134 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -0,0 +1,46 @@ +#pragma once +#include +#include +#include "Notification.h" +#include "Map.h" +#include "InputHelper.h" +#include "OutputHelper.h" + +inline const Notification* selectNotification(const util::Vector& notifications) +{ + if (notifications.getSize() == 0) + { + std::cout << "No notifications available." << std::endl; + return nullptr; + } + std::cout << std::left + << std::setw(6) << "Index" + << std::setw(15) << "ID" + << std::setw(30) << "Title" + << std::setw(25) << "Timestamp" + << std::endl; + int currentIndex = 1; + for (int iterator = 0; iterator < notifications.getSize(); iterator++) + { + const Notification* currentNotification = notifications[iterator]; + if (currentNotification) + { + std::cout << std::left + << std::setw(6) << currentIndex + << std::setw(15) << currentNotification->getId() + << std::setw(30) << currentNotification->getTitle() + << std::setw(25) << currentNotification->getCreatedAt().toString() + << std::endl; + currentIndex++; + } + } + int selectedIndex; + std::cout << "Select notification: "; + util::read(selectedIndex); + if (selectedIndex < 1 || selectedIndex > notifications.getSize()) + { + std::cout << "Invalid selection." << std::endl; + return nullptr; + } + return notifications[selectedIndex - 1]; +} From 183a06cd2f6bec4cc60d340ffe13448b9a31c2c4 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 23:51:19 +0530 Subject: [PATCH 05/20] Implement Purchase Combo functionality CUS007: Purchase Combo Package 1. Added combo package selection flow in CustomerMenu to list all active combo packages with estimated cost and allow customer selection. 2. Implemented Controller::purchaseComboPackage to delegate combo package booking requests to ServiceManagementService. 3. Added ServiceManagementService::purchaseComboPackage logic to validate authenticated user, fetch selected combo package, create a ServiceBooking, persist it in DataStore, and send booking confirmation notification. 4. Added helper functions in CustomerMenu to calculate combo package estimated cost based on included services and required inventory items. 5. Updated ServiceBooking model to use User* reference for assigned technician and simplified constructor to align booking model with object references. Precondition: 1. Customer account exists and is logged into the system. 2. Active combo packages are available in the system. 3. Combo package contains one or more active services. 4. Service bookings and notifications can be created successfully. Steps: 1. Navigate to Customer Menu and select the combo package booking option. 2. View the list of available combo packages. - Verify that all active combo packages are displayed with their details. 3. Select one combo package and enter vehicle number, vehicle brand, and vehicle model. - Verify that a booking request is generated successfully. 4. Complete the booking flow. - Verify that a confirmation message is displayed to the customer. 5. Check customer notifications. - Verify that a booking confirmation notification is received. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 + .../models/ServiceBooking.cpp | 15 ++--- .../models/ServiceBooking.h | 9 +-- .../services/ServiceManagementService.cpp | 33 +++++++++ .../utilities/Utility.h | 28 ++++++++ .../views/CustomerMenu.cpp | 67 +++++++++++++++++++ 8 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..819264c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -176,6 +176,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..aed3518 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -46,6 +46,7 @@ void Controller::purchaseService(const util::Vector& serviceIDs, co 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); } util::Map Controller::getInventoryItems() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..8512598 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "ServiceManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + ServiceManagementService m_serviceManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 1fdfaf0..1ae6631 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -5,10 +5,11 @@ int ServiceBooking::m_uid = 0; ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), - m_discountPercentage(0.0) {} + m_assignedTechnician(nullptr), + m_discountPercentage(0.0) { +} ServiceBooking::ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -17,8 +18,6 @@ ServiceBooking::ServiceBooking( const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel, - const std::string& assignedTechnicianId, - const std::string& assignedTechnician, double discountPercentage ) : m_id("SRV" + std::to_string(++m_uid)), @@ -29,8 +28,8 @@ ServiceBooking::ServiceBooking( m_vehicleNumber(vehicleNumber), m_vehicleBrand(vehicleBrand), m_vehicleModel(vehicleModel), - m_assignedTechnicianId(assignedTechnicianId), - m_assignedTechnician(assignedTechnician), + m_assignedTechnicianId(""), + m_assignedTechnician(nullptr), m_discountPercentage(discountPercentage) { } @@ -80,7 +79,7 @@ const std::string& ServiceBooking::getAssignedTechnicianId() const return m_assignedTechnicianId; } -const std::string& ServiceBooking::getAssignedTechnician() const +User* ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } @@ -135,7 +134,7 @@ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnici m_assignedTechnicianId = assignedTechnicianId; } -void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician) +void ServiceBooking::setAssignedTechnician(User* assignedTechnician) { m_assignedTechnician = assignedTechnician; } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 5ecc1b0..84a8aac 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -19,12 +19,11 @@ private: std::string m_vehicleBrand; std::string m_vehicleModel; std::string m_assignedTechnicianId; - std::string m_assignedTechnician; + User* m_assignedTechnician; double m_discountPercentage; public: ServiceBooking(); ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -33,8 +32,6 @@ public: const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel, - const std::string& assignedTechnicianId, - const std::string& assignedTechnician, double discountPercentage ); const std::string& getId() const; @@ -46,7 +43,7 @@ public: const std::string& getVehicleBrand() const; const std::string& getVehicleModel() const; const std::string& getAssignedTechnicianId() const; - const std::string& getAssignedTechnician() const; + User* getAssignedTechnician() const; double getDiscountPercentage() const; void setId(const std::string& id); void setStatus(const util::ServiceJobStatus& status); @@ -57,6 +54,6 @@ public: void setVehicleBrand(const std::string& vehicleBrand); void setVehicleModel(const std::string& vehicleModel); void setAssignedTechnicianId(const std::string& assignedTechnicianId); - void setAssignedTechnician(const std::string& assignedTechnician); + void setAssignedTechnician(User* assignedTechnician); void setDiscountPercentage(double discountPercentage); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 156c12b..5e4391e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1 +1,34 @@ #include "ServiceManagementService.h" +#include "AuthenticationManagementService.h" +#include "ComboPackage.h" +#include "ServiceBooking.h" +#include "Factory.h" + +void ServiceManagementService::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) +{ + AuthenticationManagementService m_authenticationManagementService; + auto authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (authenticatedUser == nullptr) + { + throw std::runtime_error("No user is currently logged in!"); + } + auto& comboPackagesMap = m_dataStore.getComboPackages(); + auto& serviceBookingMap = m_dataStore.getServiceBookings(); + int comboPackageIndex = comboPackagesMap.find(comboPackageID); + if (comboPackageIndex == -1) + { + throw std::runtime_error("Combo Package not found!"); + } + const ComboPackage* comboPackage = comboPackagesMap[comboPackageID]; + util::Map selectedServices = comboPackage->getServices(); + ServiceBooking* serviceBooking = Factory::getObject(util::ServiceJobStatus::STARTED, selectedServices, authenticatedUser->getId(), authenticatedUser, vehicleNumber, vehicleBrand, vehicleModel, comboPackage->getDiscountPercentage()); + if (serviceBooking == nullptr) + { + throw std::runtime_error("Failed to create combo package service booking"); + } + serviceBookingMap[serviceBooking->getId()] = serviceBooking; + sendNotification(authenticatedUser, + "Combo Package Service Booking succeeded", + "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId()); +} + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h new file mode 100644 index 0000000..dcbe33e --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -0,0 +1,28 @@ +#pragma once +#include "Service.h" +#include "InventoryItem.h" + +inline double calculatePartsCost(const Service* service) +{ + double cost = 0; + auto& requiredInventoryItems = service->getRequiredInventoryItems(); + int requiredInventoryItemsSize = requiredInventoryItems.getSize(); + for (int index = 0; index < requiredInventoryItemsSize; index++) + { + cost += requiredInventoryItems.getValueAt(index)->getPrice(); + } + return cost; +} + +inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage) +{ + double cost = 0; + auto& services = comboPackage->getServices(); + int servicesSize = services.getSize(); + for (int index = 0; index < servicesSize; index++) + { + const Service* service = services.getValueAt(index); + cost += calculatePartsCost(service) + service->getLaborCost(); + } + return cost; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..b71d1ca 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,6 +1,11 @@ +#include #include "CustomerMenu.h" +#include "ComboPackage.h" +#include "Service.h" +#include "InventoryItem.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Utility.h" void CustomerMenu::showMenu() { @@ -47,8 +52,70 @@ void CustomerMenu::selectService() { } +static const ComboPackage* selectComboPackageFromPackages(const util::Map& comboPackages) +{ + util::Map 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) << 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() { + std::string vehicleNumber, vehicleBrand, vehicleModel; + auto comboPackages = m_controller.getComboPackages(); + util::clear(); + const ComboPackage* selectedComboPackage = selectComboPackageFromPackages(comboPackages); + if (selectedComboPackage == nullptr) + { + std::cout << "Failed to book combo package!"; + util::pressEnter(); + return; + } + util::clear(); + std::cout << "Enter vehicle number: "; + util::read(vehicleNumber); + std::cout << "Enter vehicle brand: "; + util::read(vehicleBrand); + std::cout << "Enter vehicle model: "; + util::read(vehicleModel); + m_controller.purchaseComboPackage(selectedComboPackage->getId(), vehicleNumber, vehicleBrand, vehicleModel); + std::cout << "Combo Package has been booked successfully"; + util::pressEnter(); } void CustomerMenu::viewServiceHistory() From 1732776d13c2bfdaff33eb4a70572a506cf1221f Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 16:10:04 +0530 Subject: [PATCH 06/20] Implement View Admin Notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOT002: View Admin Notifications 1. Added shared notification view handler `viewAndDeleteNotification()` in MenuHelper.h for notification viewing and deletion logic reuse. 2. Updated AdminMenu.cpp to include MenuHelper.h and connected AdminMenu::viewNotifications() to the shared notification handler. Precondition: 1. Admin user exists and is logged into the system. 2. Admin has one or more notifications available. 3. “View Notifications” option is visible in the Admin menu. Steps: 1. Navigate to Admin Menu. 2. Select “View Notifications”. 3. Verify that the system displays a list of notifications showing title, message, and timestamp. 4. Select a notification to view full details. - Verify that the selected notification is displayed and deleted after viewing. 5. Return to the notification list or reopen “View Notifications”. - Verify that the previously viewed notification is no longer present. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem/views/AdminMenu.cpp | 2 ++ .../Trenser.VehicleServiceSystem/views/MenuHelper.h | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..589df33 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,6 +1,7 @@ #include "AdminMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "MenuHelper.h" void AdminMenu::showMenu() { @@ -86,4 +87,5 @@ void AdminMenu::removeComboPackage() void AdminMenu::viewNotifications() { + viewAndDeleteNotification(m_controller); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h new file mode 100644 index 0000000..74025b7 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -0,0 +1,6 @@ +#pragma once +#include "Controller.h" + +inline void viewAndDeleteNotification(Controller& controller) +{ +} From 713c3b6cf9d056d3eef10077f56a11ad24122f0c Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 16:24:34 +0530 Subject: [PATCH 07/20] Implement View Technician Notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOT003: View Technician Notifications 1. Added MenuHelper.h to the project for shared notification viewing helper support. 2. Updated TechnicianMenu.cpp to include MenuHelper.h and route viewNotifications() through the shared notification handler. Precondition: 1. Technician user exists and is logged into the system. 2. Technician has one or more notifications available. 3. “View Notifications” option is visible in the Technician menu. Steps: 1. Navigate to Technician Menu. 2. Select “View Notifications”. 3. Verify that the system displays a list of notifications showing title, message, and timestamp. 4. Select a notification to view full details. - Verify that the selected notification is displayed and deleted after viewing. 5. Return to the notification list or reopen “View Notifications”. - Verify that the previously viewed notification is no longer present. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../Trenser.VehicleServiceSystem/views/MenuHelper.h | 6 ++++++ .../Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..aaca946 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -180,6 +180,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h new file mode 100644 index 0000000..74025b7 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -0,0 +1,6 @@ +#pragma once +#include "Controller.h" + +inline void viewAndDeleteNotification(Controller& controller) +{ +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index d6c4d57..24bf28f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -1,6 +1,7 @@ #include "TechnicianMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "MenuHelper.h" void TechnicianMenu::showMenu() { @@ -37,4 +38,5 @@ void TechnicianMenu::completeJob() void TechnicianMenu::viewNotifications() { + viewAndDeleteNotification(m_controller); } From 9533a74d87f40b56d74950afbd75f112742ce3ba Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 20:11:19 +0530 Subject: [PATCH 08/20] Implement Create Customer functionality CUS004: Register Customer Account 1. Added customer registration flow in UserInterface to collect username, name, email, password, and phone inputs. 2. Added validation for email, password, and phone number before proceeding with registration. 3. Updated Controller::createCustomer() and UserManagementService::createUser() to support customer registration with full user details including name. 4. Added duplicate username validation in UserManagementService using map predicate search. 5. Added user creation and insertion logic in UserManagementService to store newly registered customer records in DataStore. 6. Added observer attachment for newly registered users to inventory(only for admins), payment, and service notification services. 7. Added registration confirmation message display after successful customer creation. Precondition: 1. Application is running and user is on the main login/register menu. 2. DataStore is initialized and available for storing user records. 3. Existing customer records may already be present in the system. Steps: 1. Select the Register Customer option. 2. Enter valid username, name, email, password, and phone number. 3. Submit the registration request. - Verify that the system accepts valid inputs and creates the customer account. 4. Attempt registration using an already existing username. - Verify that the duplicate registration is rejected. 5. Register again with valid unique details. - Verify that the registration confirmation message is displayed. 6. Re-access application data after registration. - Verify that the customer data is stored persistently. Sreeja Reghukumar, please review --- .../controllers/Controller.cpp | 4 ++- .../controllers/Controller.h | 5 ++- .../services/UserManagementService.cpp | 33 +++++++++++++++++ .../services/UserManagementService.h | 2 +- .../views/UserInterface.cpp | 35 ++++++++++++++++++- 5 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..48e9fc7 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,4 +1,5 @@ #include "Controller.h" +#include "Enums.h" bool Controller::login(const std::string& username, const std::string& password) { @@ -13,8 +14,9 @@ void Controller::changePassword(const std::string& newPassword) { } -void Controller::createCustomer(const std::string& username, 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); } const User* Controller::getAuthenticatedUser() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..f7e2826 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "UserManagementService.h" class Service; class ComboPackage; @@ -14,11 +15,13 @@ class Notification; class Controller { +private: + UserManagementService m_userManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); void changePassword(const std::string& newPassword); - void createCustomer(const std::string& username, 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(); void createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone); void updateUserDetails(const std::string& email, const std::string& phone); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 2a5bd9e..55a068d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1 +1,34 @@ +#include #include "UserManagementService.h" +#include "ServiceManagementService.h" +#include "PaymentManagementService.h" +#include "InventoryManagementService.h" +#include "User.h" +#include "Factory.h" +#include "Enums.h" + +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; + PaymentManagementService paymentManagementService; + ServiceManagementService serviceManagementService; + auto& usersMap = m_dataStore.getUsers(); + int index = usersMap.findIf( + [&](const std::string&, User* user) + { + return user->getUserName() == username; + } + ); + if (index != -1) + { + throw std::runtime_error("Username already exists"); + } + User* newUser = Factory::getObject(username, password, name, phone, email, type); + usersMap.insert(newUser->getId(), newUser); + paymentManagementService.attach(newUser); + serviceManagementService.attach(newUser); + if (newUser->getUserType() == util::UserType::ADMIN) + { + inventoryManagementService.attach(newUser); + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index bb7a85a..cab8484 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -13,7 +13,7 @@ private: DataStore& m_dataStore; public: UserManagementService() : m_dataStore(DataStore::getInstance()) {} - void createUser(const std::string& username, const std::string& password, const std::string& email, const std::string& phone, util::UserType type); + void 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 updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone); util::Map getUsers(); util::Map getUsers(util::UserType type); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..6d71a97 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -1,6 +1,7 @@ #include "UserInterface.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Validator.h" void UserInterface::run() { @@ -53,5 +54,37 @@ void UserInterface::login() void UserInterface::registerCustomer() { - + std::string username, name, email, phone, password; + util::clear(); + std::cout << "Enter username: "; + util::read(username); + std::cout << "Enter name: "; + util::read(name); + std::cout << "Enter email: "; + util::read(email); + if (!util::isEmailValid(email)) + { + std::cout << "Error: Email is invalid!"; + util::pressEnter(); + return; + } + std::cout << "Enter password: "; + util::read(password); + if (!util::isPasswordValid(password)) + { + std::cout << "Error: Password is invalid!"; + util::pressEnter(); + return; + } + std::cout << "Enter phone: "; + util::read(phone); + if (!util::isPhoneNumberValid(phone)) + { + std::cout << "Error: Phone number is invalid!"; + util::pressEnter(); + return; + } + m_controller.createCustomer(username, name, password, email, phone); + std::cout << "Registration is successful"; + util::pressEnter(); } From c92ad773c79e2dc71c2e33a626d56a61f7fd29a2 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 19:55:54 +0530 Subject: [PATCH 09/20] Implement Configure Notifications functionality NOT006: Configure Notifications 1. Added notification subscription configuration in CustomerMenu to allow customers to enable or disable notifications for Payment Management Service and Service Management Service. 2. Updated Controller::configureNotifications() to attach or detach the authenticated user from service observers based on selected notification preferences. 3. Refactored Observer interface and User notification handling to support notification delivery through observer subscriptions. 4. Implemented observer attach, detach, and sendNotification logic in InventoryManagementService, PaymentManagementService, and ServiceManagementService to ensure notifications are sent only to subscribed users. Precondition: 1. Customer user is logged into the system. 2. Notification configuration option is available in Customer Menu. 3. Notification-triggering event exists for Payment Management Service or Service Management Service. Steps: 1. Navigate to Configure Notification Preferences in Customer Menu. 2. Enable notifications for one service and disable notifications for the other. 3. Trigger a notification event for both services. - Verify that notification is received only from the subscribed service. 4. Change preferences by disabling the subscribed service and enabling the other. 5. Trigger notification events again. - Verify that notification is received only from the newly subscribed service. Sreeja Reghukumar, please review --- .../controllers/Controller.cpp | 27 ++++++++- .../controllers/Controller.h | 9 ++- .../core/patterns/Observer.h | 2 +- .../models/User.cpp | 9 ++- .../models/User.h | 3 +- .../services/InventoryManagementService.cpp | 56 +++++++++++++++++++ .../services/NotificationManagementService.h | 1 + .../services/PaymentManagementService.cpp | 56 +++++++++++++++++++ .../services/ServiceManagementService.cpp | 56 +++++++++++++++++++ .../views/CustomerMenu.cpp | 31 ++++++++++ 10 files changed, 240 insertions(+), 10 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..f65c0c1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,3 +1,4 @@ +#include #include "Controller.h" bool Controller::login(const std::string& username, const std::string& password) @@ -137,8 +138,32 @@ void Controller::deleteNotification(const std::string& notificationID) { } -void Controller::configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications) +void Controller::configureNotifications(bool paymentNotifications, bool serviceNotifications) { + User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (authenticatedUser) + { + if (paymentNotifications) + { + m_paymentManagementService.attach(authenticatedUser); + } + else + { + m_paymentManagementService.detach(authenticatedUser); + } + if (serviceNotifications) + { + m_serviceManagementService.attach(authenticatedUser); + } + else + { + m_serviceManagementService.detach(authenticatedUser); + } + } + else + { + throw std::runtime_error("No user is currently logged in!"); + } } void Controller::runSystemChecks() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..74e8edb 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,9 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" +#include "ServiceManagementService.h" +#include "PaymentManagementService.h" class Service; class ComboPackage; @@ -14,6 +17,10 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; + ServiceManagementService m_serviceManagementService; + PaymentManagementService m_paymentManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); @@ -46,6 +53,6 @@ public: void completePayment(const std::string& invoiceID, util::PaymentMode paymentMode); util::Vector getNotifications(); void deleteNotification(const std::string& notificationID); - void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications); + void configureNotifications(bool paymentNotifications, bool serviceNotifications); void runSystemChecks(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h index 98f0efa..51fa582 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h @@ -6,5 +6,5 @@ class Observer { public: virtual ~Observer() = default; - virtual void update(Notification* notification) = 0; + virtual void addNotification(Notification* notification) = 0; }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp index 52d85a9..6e0b531 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp @@ -104,7 +104,10 @@ void User::setEmail(const std::string& email) void User::addNotification(Notification* notification) { - m_notifications.insert(notification->getId(), notification); + if (notification) + { + m_notifications.insert(notification->getId(), notification); + } } void User::setRole(util::UserType role) @@ -116,7 +119,3 @@ void User::setState(util::State status) { m_status = status; } - -void User::update(Notification* notification) -{ -} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h index bde21e1..b12ea78 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h @@ -38,8 +38,7 @@ public: void setName(const std::string& name); void setPhone(const std::string& phone); void setEmail(const std::string& email); - void addNotification(Notification* notification); + void addNotification(Notification* notification) override; void setRole(util::UserType role); void setState(util::State status); - void update(Notification* notification) override; }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 39ef719..0021c44 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,57 @@ +#include #include "InventoryManagementService.h" +#include "User.h" +#include "Factory.h" +#include "Timestamp.h" + +util::Map InventoryManagementService::m_observers{}; + +void InventoryManagementService::attach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) == -1) + { + m_observers[userID] = user; + } + } +} + +void InventoryManagementService::detach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) != -1) + { + m_observers.remove(userID); + } + } +} + +void InventoryManagementService::sendNotification(User* user, const std::string& title, const std::string& message) +{ + if (user) + { + if (m_observers.find(user->getId()) != -1) + { + Notification* notification = + Factory::getObject( + user->getId(), + user, + "InventoryManagementService: " + title, + message, + util::Timestamp() + ); + if (notification) + { + user->addNotification(notification); + } + else + { + throw std::runtime_error("Failed to create notification"); + } + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h index b193b1d..0b60c14 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h @@ -1,6 +1,7 @@ #pragma once #include #include "Subject.h" +#include "Notification.h" #include "User.h" class NotificationManagementService : public Subject diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 786ebcf..1979d00 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -1 +1,57 @@ +#include #include "PaymentManagementService.h" +#include "User.h" +#include "Factory.h" +#include "Timestamp.h" + +util::Map PaymentManagementService::m_observers{}; + +void PaymentManagementService::attach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) == -1) + { + m_observers[userID] = user; + } + } +} + +void PaymentManagementService::detach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) != -1) + { + m_observers.remove(userID); + } + } +} + +void PaymentManagementService::sendNotification(User* user, const std::string& title, const std::string& message) +{ + if (user) + { + if (m_observers.find(user->getId()) != -1) + { + Notification* notification = + Factory::getObject( + user->getId(), + user, + "PaymentManagementService: " + title, + message, + util::Timestamp() + ); + if (notification) + { + user->addNotification(notification); + } + else + { + throw std::runtime_error("Failed to create notification"); + } + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 156c12b..ac518ed 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1 +1,57 @@ +#include #include "ServiceManagementService.h" +#include "User.h" +#include "Factory.h" +#include "Timestamp.h" + +util::Map ServiceManagementService::m_observers{}; + +void ServiceManagementService::attach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) == -1) + { + m_observers[userID] = user; + } + } +} + +void ServiceManagementService::detach(User* user) +{ + if (user) + { + const std::string& userID = user->getId(); + if (m_observers.find(userID) != -1) + { + m_observers.remove(userID); + } + } +} + +void ServiceManagementService::sendNotification(User* user, const std::string& title, const std::string& message) +{ + if (user) + { + if (m_observers.find(user->getId()) != -1) + { + Notification* notification = + Factory::getObject( + user->getId(), + user, + "ServiceManagementService: " + title, + message, + util::Timestamp() + ); + if (notification) + { + user->addNotification(notification); + } + else + { + throw std::runtime_error("Failed to create notification"); + } + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..c418def 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -67,6 +67,37 @@ void CustomerMenu::viewNotifications() { } +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(); + } +} + void CustomerMenu::configureNotifications() { + bool paymentServiceNotifications = getNotificationPreference("Payment Management Service"); + bool serviceManagementNotifications = getNotificationPreference("Service Management Service"); + m_controller.configureNotifications(paymentServiceNotifications, serviceManagementNotifications); + util::clear(); + std::cout << "Notification preferences updated successfully.\n"; + util::pressEnter(); } From be306781b1e392cb43d0d7c2d9212f4a75a4afa2 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Thu, 21 May 2026 09:37:03 +0530 Subject: [PATCH 10/20] Implement Customer Menu * Added Customer Menu display with all customer options * Added menu choice handling using switch case * Connected menu options to corresponding customer functions * Added invalid choice message * Added logout option handling --- .../views/CustomerMenu.cpp | 90 ++++++++++++++----- 1 file changed, 68 insertions(+), 22 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..ee467d9 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -4,31 +4,77 @@ void CustomerMenu::showMenu() { - bool isMenuActive = true; - while (isMenuActive) - { - try - { - int choice; - util::clear(); - std::cout << "" << std::endl; - util::read(choice); - if (!handleOperation(choice)) - { - isMenuActive = false; - } - } - catch (const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - util::pressEnter(); - } - } + while (true) + { + try + { + int choice; + util::clear(); + std::cout << "Customer Menu" + << "\n1. Select a service" + << "\n2. Select a combo package" + << "\n3. Update Profile" + << "\n4. Change Password" + << "\n5. View Service History" + << "\n6. Complete Payments" + << "\n7. View Invoices" + << "\n8. View Notifications" + << "\n9. Configure Notifications" + << "\n10. Logout" + << "\nEnter a choice: "; + util::read(choice); + if (!handleOperation(choice)) + { + break; + } + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + util::pressEnter(); + } + } } bool CustomerMenu::handleOperation(int choice) { - return false; + switch (choice) + { + case 1: + selectService(); + break; + case 2: + selectComboPackage(); + break; + case 3: + updateDetails(); + break; + case 4: + changePassword(); + break; + case 5: + viewServiceHistory(); + break; + case 6: + completePayments(); + break; + case 7: + viewInvoices(); + break; + case 8: + viewNotifications(); + break; + case 9: + configureNotifications(); + break; + case 10: + logout(); + return false; + default: + std::cout << "Enter a valid choice!" << std::endl; + util::pressEnter(); + } + return true; } void CustomerMenu::logout() @@ -69,4 +115,4 @@ void CustomerMenu::viewNotifications() void CustomerMenu::configureNotifications() { -} +} \ No newline at end of file From df39c0588bf4b83ed7ef3d6f608487266fd4fcee Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 12:36:29 +0530 Subject: [PATCH 11/20] Implement Login functionality CUS001:Login 1. Added login implementation in AuthenticationManagementService to validate username and password from stored user records. 2. Connected Controller::login() with AuthenticationManagementService login logic. 3. Added getAuthenticatedUser() integration in Controller for retrieving the logged-in user. 4. Implemented login flow in UserInterface to collect credentials and validate login. 5. Added role-based menu navigation for Admin, Technician, and Customer after successful login. 6. Added error handling to display "Invalid Username or Password" for failed login attempts. 7. Added required includes and controller member dependency for authentication support. 8. Added a check to create a default admin automatically if no admin exists in the system on startup Login functionality validation Precondition: 1. System is running. 2. User records are available in the data store. 3. Valid username and password exist for a registered user. Steps: 1. Launch the application. 2. Select the login option from the main menu. 3. Enter a valid username and password. - Verify that the entered credentials are validated. - Verify that access is granted and the correct menu is shown based on user type. 4. Enter an invalid username or password. - Verify that the message "Invalid Username or Password" is displayed. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 5 +-- .../controllers/Controller.h | 5 +++ .../AuthenticationManagementService.cpp | 26 ++++++++++++++ .../services/UserManagementService.cpp | 29 +++++++++++++++ .../services/UserManagementService.h | 3 +- .../utilities/Config.h | 13 +++++++ .../views/UserInterface.cpp | 35 ++++++++++++++++++- 8 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..1b76c8a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -171,6 +171,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..e641900 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -2,7 +2,7 @@ bool Controller::login(const std::string& username, const std::string& password) { - return false; + return m_authenticationManagementService.login(username, password); } void Controller::logout() @@ -19,7 +19,7 @@ void Controller::createCustomer(const std::string& username, const std::string& const User* Controller::getAuthenticatedUser() { - return nullptr; + return m_authenticationManagementService.getAuthenticatedUser(); } void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone) @@ -143,5 +143,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { + m_userManagementService.ensureAdminExists(); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..e1ecc49 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,8 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" +#include "UserManagementService.h" class Service; class ComboPackage; @@ -14,6 +16,9 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; + UserManagementService m_userManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index ca07fee..91dd003 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,3 +1,29 @@ #include "AuthenticationManagementService.h" +#include "User.h" User* AuthenticationManagementService::m_authenticatedUser = nullptr; + +bool AuthenticationManagementService::login(const std::string& username, const std::string& password) +{ + util::Map users = m_dataStore.getUsers(); + int usersMapSize = users.getSize(); + for (int index = 0; index < usersMapSize; index++) + { + User* user = users.getValueAt(index); + if (username == user->getUserName()) + { + if (password == user->getPassword()) + { + m_authenticatedUser = user; + return true; + } + return false; + } + } + return false; +} + +User* AuthenticationManagementService::getAuthenticatedUser() +{ + return m_authenticatedUser; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 2a5bd9e..2c2e156 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1 +1,30 @@ #include "UserManagementService.h" +#include "User.h" +#include "Enums.h" +#include "Config.h" + +void UserManagementService::ensureAdminExists() +{ + auto& usersMap = m_dataStore.getUsers(); + int usersMapSize = usersMap.getSize(); + bool isAdminFound = false; + for (int index = 0; index < usersMapSize; index++) + { + User* user = usersMap.getValueAt(index); + if (user && user->getUserType() == util::UserType::ADMIN) + { + isAdminFound = true; + break; + } + } + if (!isAdminFound) + { + createUser( + config::admin::DEFAULT_ADMIN_USERNAME, + config::admin::DEFAULT_ADMIN_NAME, + config::admin::DEFAULT_ADMIN_PASSWORD, + config::admin::DEFAULT_ADMIN_EMAIL, + config::admin::DEFAULT_ADMIN_PHONE, + util::UserType::ADMIN); + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index bb7a85a..34603a4 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -13,7 +13,7 @@ private: DataStore& m_dataStore; public: UserManagementService() : m_dataStore(DataStore::getInstance()) {} - void createUser(const std::string& username, const std::string& password, const std::string& email, const std::string& phone, util::UserType type); + void 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 updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone); util::Map getUsers(); util::Map getUsers(util::UserType type); @@ -21,4 +21,5 @@ public: void removeUser(const std::string& userID); util::Vector getUserNotifications(const std::string& userID); void deleteNotification(const std::string& notificationID, const std::string& userID); + void ensureAdminExists(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h new file mode 100644 index 0000000..38c7bed --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -0,0 +1,13 @@ +#pragma once + +namespace config +{ + namespace admin + { + constexpr const char* DEFAULT_ADMIN_USERNAME = "admin"; + constexpr const char* DEFAULT_ADMIN_NAME = "admin"; + constexpr const char* DEFAULT_ADMIN_PASSWORD = ""; + constexpr const char* DEFAULT_ADMIN_EMAIL = "admin@vss"; + constexpr const char* DEFAULT_ADMIN_PHONE = "0000000000"; + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..b03defd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -1,6 +1,8 @@ #include "UserInterface.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "Enums.h" +#include "User.h" void UserInterface::run() { @@ -48,7 +50,38 @@ bool UserInterface::handleOperation(int choice) void UserInterface::login() { - + std::string username, password; + util::clear(); + std::cout << "Enter username: "; + util::read(username); + std::cout << "Enter password: "; + util::read(password); + if (m_controller.login(username, password)) + { + const User* authenticatedUser = m_controller.getAuthenticatedUser(); + if (authenticatedUser != nullptr) + { + switch (authenticatedUser->getUserType()) + { + case util::UserType::ADMIN: + m_adminMenu.showMenu(); + break; + case util::UserType::TECHNICIAN: + m_technicianMenu.showMenu(); + break; + case util::UserType::CUSTOMER: + m_customerMenu.showMenu(); + break; + default: + std::cout << "\nError: Unknown user type"; + break; + } + } + } + else + { + std::cout << "\nError: Invalid Username or Password"; + } } void UserInterface::registerCustomer() From aef0f4146e675337f018774fab29217e1f0961a1 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 17:32:13 +0530 Subject: [PATCH 12/20] Implement Low Stock Alert functionality NOT004: Low Stock Alert 1. Added low stock alert check in Controller::runSystemChecks() to trigger inventory notification processing during system startup. 2. Implemented InventoryManagementService::sendLowStockAlerts() to detect inventory items below threshold, identify admin users, and send low stock alert notifications with item details. 3. Added helper logic to notify all admins when low stock inventory is detected. Precondition: 1. System has at least one admin user. 2. Inventory item exists with quantity below the configured low stock threshold. 3. Application is started and system checks execute. Steps: 1. Start the application. 2. Allow system checks to run during startup. 3. Navigate to Inventory Menu / View Notifications. - Verify that a low stock alert notification is displayed. 4. Open the generated notification. - Verify that the notification includes the part name and remaining quantity. 5. Confirm notification content. - Verify that the alert was triggered only for inventory items with stock below the threshold. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 2 + .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 ++ .../services/InventoryManagementService.cpp | 49 +++++++++++++++++++ .../utilities/Config.h | 9 ++++ .../utilities/Utility.h | 1 + .../views/UserInterface.cpp | 1 + 7 files changed, 66 insertions(+) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..0cb9d3f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -171,11 +171,13 @@ + + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..b91450c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -143,5 +143,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { + m_inventoryManagementService.sendLowStockAlerts(); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..d1b73a8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "InventoryManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + InventoryManagementService m_inventoryManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 39ef719..aa15ae8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,50 @@ +#include #include "InventoryManagementService.h" +#include "Vector.h" +#include "Enums.h" +#include "InventoryItem.h" +#include "Config.h" + +static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector& adminUsers) +{ + int adminUsersSize = adminUsers.getSize(); + for (int index = 0; index < adminUsersSize; index++) + { + inventoryManagementService.sendNotification( + adminUsers[index], + "Low Stock Alert", + "The inventory item with ID " + inventoryItem->getId() + + " has very low quantity in the inventory" + ); + } +} + +void InventoryManagementService::sendLowStockAlerts() +{ + auto& inventoryItems = m_dataStore.getInventoryItems(); + int inventoryItemsSize = inventoryItems.getSize(); + auto& usersMap = m_dataStore.getUsers(); + int usersMapSize = usersMap.getSize(); + util::Vector adminUsers; + for (int index = 0; index < usersMapSize; index++) + { + User* user = usersMap.getValueAt(index); + if (user->getUserType() == util::UserType::ADMIN) + { + adminUsers.push_back(user); + } + } + int adminUsersSize = adminUsers.getSize(); + if (adminUsersSize < 1) + { + throw std::runtime_error("The system has no admins present!"); + } + for (int index = 0; index <= inventoryItemsSize; index++) + { + InventoryItem* inventoryItem = inventoryItems.getValueAt(index); + if (inventoryItem && inventoryItem->getQuantity() < config::threshold::INVENTORY_LOW_STOCK_THRESHOLD) + { + sendLowStockAlertsToAdmins(*this, inventoryItem, adminUsers); + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h new file mode 100644 index 0000000..7a96ed6 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -0,0 +1,9 @@ +#pragma once + +namespace config +{ + namespace threshold + { + constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5; + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -0,0 +1 @@ +#pragma once diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..cc47e47 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -4,6 +4,7 @@ void UserInterface::run() { + m_controller.runSystemChecks(); bool isMenuActive = true; while (isMenuActive) { From b9be43acca667f1f7a51aaf85c7140e7020245c0 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 18:02:13 +0530 Subject: [PATCH 13/20] Implement Payment Reminder functionality NOT005: Payment Reminder 1. Added payment reminder check in Controller::runSystemChecks() to trigger reminder processing during system startup. 2. Implemented PaymentManagementService::sendPaymentReminders() to identify unpaid invoices that exceed the pending payment threshold and send reminder notifications to customers. 3. Added reminder notification logic to include invoice details and stop reminders once invoice payment status changes from Pending to Paid. Precondition: 1. Customer has an invoice with PaymentStatus::PENDING. 2. Invoice age exceeds the configured payment reminder threshold. 3. Application is started and system checks execute. Steps: 1. Start the application. 2. Allow system checks to run during startup. 3. Navigate to View Notifications. - Verify that a payment reminder notification is displayed. 4. Open the generated notification. - Verify that the notification includes the invoice ID and due date. 5. Complete payment for the invoice and restart the application. - Verify that no further reminder notifications are generated for the paid invoice. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 ++ .../services/PaymentManagementService.cpp | 34 +++++++++++++++++++ .../utilities/Config.h | 11 ++++++ .../views/UserInterface.cpp | 1 + 6 files changed, 51 insertions(+) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..1b76c8a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -171,6 +171,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..af788dc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -143,5 +143,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { + m_paymentManagementService.sendPaymentReminders(); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..7cfc875 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "PaymentManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + PaymentManagementService m_paymentManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 786ebcf..4eaedbd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -1 +1,35 @@ #include "PaymentManagementService.h" +#include "Invoice.h" +#include "ServiceBooking.h" +#include "Enums.h" +#include "Timestamp.h" +#include "Config.h" + +void PaymentManagementService::sendPaymentReminders() +{ + auto& invoicesMap = m_dataStore.getInvoices(); + int invoicesMapSize = invoicesMap.getSize(); + for (int index = 0; index < invoicesMapSize; index++) + { + const Invoice* invoice = invoicesMap.getValueAt(index); + if (invoice && invoice->getStatus() == util::PaymentStatus::PENDING) + { + util::Timestamp invoiceCreationTimestamp = invoice->getInvoiceDate(); + util::Timestamp currentTimestamp; + if (util::Timestamp::getDurationInHours(invoiceCreationTimestamp, currentTimestamp) >= config::threshold::PAYMENT_REMINDER_THRESHOLD_HOURS) + { + const ServiceBooking* serviceBooking = invoice->getBooking(); + if (serviceBooking) + { + User* customer = serviceBooking->getCustomer(); + if (customer) + { + sendNotification(customer, + "Payment Reminder", + "Your payment for Invoice ID " + invoice->getId() + " is still pending.Please complete the payment." + invoice->getId()); + } + } + } + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h new file mode 100644 index 0000000..dc101ac --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -0,0 +1,11 @@ +#pragma once + +#pragma once + +namespace config +{ + namespace threshold + { + constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168; + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..cc47e47 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -4,6 +4,7 @@ void UserInterface::run() { + m_controller.runSystemChecks(); bool isMenuActive = true; while (isMenuActive) { From b8e87ade0f7b99eec8f2e3474510d4c9749e4ee1 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 15:11:34 +0530 Subject: [PATCH 14/20] Implement View Customer Notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOT001: View Customer Notifications 1. Added shared notification helper functions to display notifications in tabular format, support notification selection, and show full notification details. 2. Implemented notification deletion logic in Controller and UserManagementService to remove notifications for the authenticated user after viewing. 3. Updated CustomerMenu::viewNotifications() to use the shared notification viewing and deletion flow. Precondition: 1. Customer is registered in the system. 2. Customer is logged into the system. 3. Customer has one or more notifications available. Steps: 1. Navigate to “View Notifications” from the customer menu. - Verify that the system displays the list of notifications with title and timestamp. 2. Select a notification from the displayed list. - Verify that the system displays the full notification details including message. 3. View the selected notification and continue. - Verify that the viewed notification is deleted from the system. 4. Navigate to “View Notifications” again. - Verify that the previously viewed notification no longer appears in the notification list. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + ...enser.VehicleServiceSystem.vcxproj.filters | 3 + .../controllers/Controller.cpp | 22 +++++- .../controllers/Controller.h | 5 ++ .../services/UserManagementService.cpp | 44 +++++++++++ .../views/CustomerMenu.cpp | 2 + .../views/MenuHelper.h | 79 +++++++++++++++++++ 7 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..aaca946 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -180,6 +180,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters index 77d0509..c72bd44 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters @@ -233,5 +233,8 @@ Header Files\Models + + Header Files\Views + \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..298706c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,4 +1,6 @@ +#include #include "Controller.h" +#include "User.h" bool Controller::login(const std::string& username, const std::string& password) { @@ -130,11 +132,29 @@ void Controller::completePayment(const std::string& invoiceID, util::PaymentMode util::Vector Controller::getNotifications() { - return util::Vector(); + const User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (!authenticatedUser) + { + throw std::runtime_error("No user is currently logged in!"); + } + auto notifications = m_userManagementService.getUserNotifications(authenticatedUser->getId()); + int numberOfNotifications = notifications.getSize(); + util::Vector readOnlyNotifications; + for (int index = 0; index < numberOfNotifications; index++) + { + readOnlyNotifications.push_back(notifications[index]); + } + return readOnlyNotifications; } void Controller::deleteNotification(const std::string& notificationID) { + const User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); + if (!authenticatedUser) + { + throw std::runtime_error("No user is currently logged in!"); + } + m_userManagementService.deleteNotification(notificationID, authenticatedUser->getId()); } void Controller::configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..e1ecc49 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,8 @@ #include "Map.h" #include #include "Enums.h" +#include "AuthenticationManagementService.h" +#include "UserManagementService.h" class Service; class ComboPackage; @@ -14,6 +16,9 @@ class Notification; class Controller { +private: + AuthenticationManagementService m_authenticationManagementService; + UserManagementService m_userManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 2a5bd9e..bff09b1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1 +1,45 @@ +#include #include "UserManagementService.h" +#include "User.h" +#include "Vector.h" + +util::Vector UserManagementService::getUserNotifications(const std::string& userID) +{ + auto& usersMap = m_dataStore.getUsers(); + if (usersMap.find(userID) == -1) + { + throw std::runtime_error("No user found with given UserID"); + } + User* user = usersMap[userID]; + if (user) + { + auto& notifications = user->getNotifications(); + int numberOfNotifications = notifications.getSize(); + util::Vector notificationsVector; + for (int index = 0; index < numberOfNotifications; index++) + { + notificationsVector.push_back(notifications.getValueAt(index)); + } + return notificationsVector; + } + else + { + throw std::runtime_error("Invalid User object"); + } +} + +void UserManagementService::deleteNotification(const std::string& notificationID, const std::string& userID) +{ + auto& usersMap = m_dataStore.getUsers(); + if (usersMap.find(userID) == -1) + { + throw std::runtime_error("No user found with given UserID"); + } + User* user = usersMap[userID]; + auto& notifications = user->getNotifications(); + if (notifications.find(notificationID) == -1) + { + throw std::runtime_error("No notification found with given NotificationID"); + } + notifications.remove(notificationID); +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..6b3a868 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,6 +1,7 @@ #include "CustomerMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "MenuHelper.h" void CustomerMenu::showMenu() { @@ -65,6 +66,7 @@ void CustomerMenu::viewInvoices() void CustomerMenu::viewNotifications() { + viewAndDeleteNotification(m_controller); } void CustomerMenu::configureNotifications() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h new file mode 100644 index 0000000..a84ba0f --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -0,0 +1,79 @@ +#pragma once +#include +#include "Vector.h" +#include "Controller.h" +#include "Notification.h" +#include "InputHelper.h" +#include "OutputHelper.h" + +inline const Notification* selectNotification(const util::Vector& notifications) +{ + if (notifications.getSize() == 0) + { + std::cout << "No notifications available." << std::endl; + return nullptr; + } + util::Map indexedNotifications; + std::cout << std::left + << std::setw(6) << "Index" + << std::setw(15) << "ID" + << std::setw(30) << "Title" + << std::setw(25) << "Timestamp" + << std::endl; + int currentIndex = 1; + for (int index = 0; index < notifications.getSize(); index++) + { + const Notification* currentNotification = notifications[index]; + if (currentNotification) + { + std::cout << std::left + << std::setw(6) << currentIndex + << std::setw(15) << currentNotification->getId() + << std::setw(30) << currentNotification->getTitle() + << std::setw(25) << currentNotification->getCreatedAt().toString() + << std::endl; + indexedNotifications.insert(currentIndex, currentNotification); + currentIndex++; + } + } + int selectedIndex; + std::cout << "Select notification: "; + util::read(selectedIndex); + if (!indexedNotifications.containsKey(selectedIndex)) + { + std::cout << "Invalid selection." << std::endl; + return nullptr; + } + return indexedNotifications[selectedIndex]; +} + +inline void displayNotification(const Notification* notification) +{ + util::clear(); + if (!notification) + { + std::cout << "Notification not found." << std::endl; + return; + } + std::cout << "Notification Details" << std::endl; + std::cout << "ID : " << notification->getId() << std::endl; + std::cout << "Title : " << notification->getTitle() << std::endl; + std::cout << "Timestamp : " << notification->getCreatedAt().toString() << std::endl; + std::cout << "Message : " << notification->getMessage() << std::endl; +} + +inline void viewAndDeleteNotification(Controller& controller) +{ + util::clear(); + auto notifications = controller.getNotifications(); + const Notification* selectedNotification = selectNotification(notifications); + if (!selectedNotification) + { + std::cout << "Failed to display notification!"; + util::pressEnter(); + return; + } + displayNotification(selectedNotification); + controller.deleteNotification(selectedNotification->getId()); + util::pressEnter(); +} From 500eb95f121b20fae6f2e61757465c0b12238d38 Mon Sep 17 00:00:00 2001 From: Jissin Mathew Date: Fri, 22 May 2026 12:49:14 +0530 Subject: [PATCH 15/20] Add documentation headers across system modules --- .../Trenser.VehicleServiceSystem.cpp | 19 +- .../controllers/Controller.cpp | 37 ++++ .../controllers/Controller.h | 7 + .../core/patterns/Observer.h | 7 + .../core/patterns/Subject.h | 7 + .../datastores/DataStore.cpp | 82 +++++++ .../datastores/DataStore.h | 8 +- .../models/ComboPackage.cpp | 109 +++++++++ .../models/ComboPackage.h | 7 + .../models/InventoryItem.cpp | 108 +++++++++ .../models/InventoryItem.h | 9 + .../models/Invoice.cpp | 207 +++++++++++++++++- .../models/Invoice.h | 9 + .../models/JobCard.cpp | 174 +++++++++++++++ .../models/JobCard.h | 8 + .../models/Notification.cpp | 112 ++++++++++ .../models/Notification.h | 8 + .../models/Service.cpp | 98 +++++++++ .../models/Service.h | 9 + .../models/ServiceBooking.cpp | 190 ++++++++++++++++ .../models/ServiceBooking.h | 8 + .../models/User.cpp | 165 ++++++++++++++ .../models/User.h | 9 + .../AuthenticationManagementService.h | 8 + .../services/InventoryManagementService.h | 8 + .../services/NotificationManagementService.h | 8 + .../services/PaymentManagementService.cpp | 46 ++++ .../services/PaymentManagementService.h | 9 + .../services/ServiceManagementService.cpp | 37 ++++ .../services/ServiceManagementService.h | 9 + .../services/UserManagementService.cpp | 30 +++ .../services/UserManagementService.h | 10 +- .../utilities/Config.h | 8 + .../utilities/Enums.h | 99 +++++++++ .../utilities/Utility.h | 7 + .../views/AdminMenu.cpp | 27 +++ .../views/AdminMenu.h | 9 + .../views/CustomerMenu.cpp | 43 ++++ .../views/CustomerMenu.h | 9 + .../views/MenuHelper.h | 35 +++ .../views/TechnicianMenu.cpp | 26 +++ .../views/TechnicianMenu.h | 8 + .../views/UserInterface.cpp | 41 ++++ .../views/UserInterface.h | 9 + 44 files changed, 1879 insertions(+), 4 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.cpp index eff3229..3db950c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.cpp @@ -1,7 +1,24 @@ +/* +File: Trenser.VehicleServiceSystem.cpp +Description: Entry point for the Vehicle Service Management System. + Initializes the UserInterface and starts the application loop. +Author: Trenser +Date: 19-May-2026 +*/ + #include "UserInterface.h" +/* +Function: main +Description: The main entry point of the application. + Creates a UserInterface object and invokes the run method to start the system. +Parameters: + - None +Returns: + - int: Exit status code (0 for successful execution). +*/ int main() { UserInterface userInterface; userInterface.run(); -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index e5f6a21..4bcccf1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,3 +1,10 @@ +/* +File: Controller.cpp +Description: Implements the Controller class which manages authentication, user, service, inventory, payment, and notification operations in the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ + #include #include "Controller.h" #include "User.h" @@ -130,6 +137,13 @@ void Controller::completePayment(const std::string& invoiceID, util::PaymentMode { } +/* +Function: getNotifications +Description: Retrieves all notifications for the currently authenticated user. + Converts them into a read-only vector before returning. +Parameters: None +Return type: util::Vector +*/ util::Vector Controller::getNotifications() { const User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -147,6 +161,13 @@ util::Vector Controller::getNotifications() return readOnlyNotifications; } +/* +Function: deleteNotification +Description: Deletes a specific notification for the currently authenticated user. +Parameters: + - notificationID: std::string, the unique identifier of the notification +Return type: void +*/ void Controller::deleteNotification(const std::string& notificationID) { const User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -157,6 +178,15 @@ void Controller::deleteNotification(const std::string& notificationID) m_userManagementService.deleteNotification(notificationID, authenticatedUser->getId()); } +/* +Function: configureNotifications +Description: Configures notification preferences for the authenticated user. + Attaches or detaches the user from payment and service notifications. +Parameters: + - paymentNotifications: bool, enable/disable payment notifications + - serviceNotifications: bool, enable/disable service notifications +Return type: void +*/ void Controller::configureNotifications(bool paymentNotifications, bool serviceNotifications) { User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -185,6 +215,13 @@ void Controller::configureNotifications(bool paymentNotifications, bool serviceN } } +/* +Function: runSystemChecks +Description: Executes system checks including sending low stock alerts + and payment reminders. +Parameters: None +Return type: void +*/ void Controller::runSystemChecks() { m_inventoryManagementService.sendLowStockAlerts(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index eb83789..5e22a68 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -1,3 +1,10 @@ +/* +File: Controller.h +Description: File contains the Controller class which manages authentication, user, service, inventory, payment, and notification operations in the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include "Map.h" #include diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h index 51fa582..7fd7262 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Observer.h @@ -1,3 +1,10 @@ +/* +File: Observer.h +Description: Declares the Observer interface for handling notifications in the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once class Notification; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h index 309a59d..4cfe5ce 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h @@ -1,3 +1,10 @@ +/* +File: Subject.h +Description: Declares the Subject interface for managing user attachments and detachments in the Observer design pattern within the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp index dd0e016..3419f44 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp @@ -1,46 +1,128 @@ +/* +File: DataStore.cpp +Description: Implements the DataStore class which provides a centralized singleton repository + for managing system data in the Vehicle Service Management System. + Includes accessors for users, services, combo packages, service bookings, + job cards, inventory items, invoices, and payments. +Author: Trenser +Date: 19-May-2026 +*/ + #include "DataStore.h" +/* +Function: getInstance +Description: Provides a singleton instance of the DataStore class. +Parameters: + - None +Returns: + - Reference to the single DataStore instance. +*/ DataStore& DataStore::getInstance() { static DataStore dataStore; return dataStore; } +/* +Function: getUsers +Description: Retrieves the internal map of users. +Parameters: + - None +Returns: + - Reference to util::Map containing all users. +*/ util::Map& DataStore::getUsers() { return m_users; } +/* +Function: getServices +Description: Retrieves the internal map of services. +Parameters: + - None +Returns: + - Reference to util::Map containing all services. +*/ util::Map& DataStore::getServices() { return m_services; } +/* +Function: getComboPackages +Description: Retrieves the internal map of combo packages. +Parameters: + - None +Returns: + - Reference to util::Map containing all combo packages. +*/ util::Map& DataStore::getComboPackages() { return m_comboPackages; } +/* +Function: getServiceBookings +Description: Retrieves the internal map of service bookings. +Parameters: + - None +Returns: + - Reference to util::Map containing all service bookings. +*/ util::Map& DataStore::getServiceBookings() { return m_serviceBookings; } +/* +Function: getJobCards +Description: Retrieves the internal map of job cards. +Parameters: + - None +Returns: + - Reference to util::Map containing all job cards. +*/ util::Map& DataStore::getJobCards() { return m_jobCards; } +/* +Function: getInventoryItems +Description: Retrieves the internal map of inventory items. +Parameters: + - None +Returns: + - Reference to util::Map containing all inventory items. +*/ util::Map& DataStore::getInventoryItems() { return m_inventoryItems; } +/* +Function: getInvoices +Description: Retrieves the internal map of invoices. +Parameters: + - None +Returns: + - Reference to util::Map containing all invoices. +*/ util::Map& DataStore::getInvoices() { return m_invoices; } +/* +Function: getPayments +Description: Retrieves the internal map of payments. +Parameters: + - None +Returns: + - Reference to util::Map containing all payments. +*/ util::Map& DataStore::getPayments() { return m_payments; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.h index 924e8e4..cde9b4e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.h @@ -1,5 +1,11 @@ -#pragma once +/* +File: DataStore.h +Description: Declares the DataStore singleton class responsible for managing collections of users, services, combo packages, service bookings, job cards, inventory items, invoices, and payments in the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ +#pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp index 6216922..41e75d0 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp @@ -1,12 +1,41 @@ +/* +File: ComboPackage.cpp +Description: Implements the ComboPackage class which represents a bundled set of services in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for package details such as ID, name, discount percentage, state, + and associated services. +Author: Trenser +Date: 19-May-2026 +*/ + #include "ComboPackage.h" int ComboPackage::m_uid = 0; +/* +Function: ComboPackage +Description: Default constructor that initializes a new combo package with a unique ID, + active state, and zero discount percentage. +Parameters: + - None +Returns: + - A new ComboPackage object. +*/ ComboPackage::ComboPackage() : m_id("CMP" + std::to_string(++m_uid)), m_status(util::State::ACTIVE), m_discountPercentage(0.0) {} +/* +Function: ComboPackage +Description: Parameterized constructor that initializes a new combo package with a unique ID, + specified package name, discount percentage, active state, and associated services. +Parameters: + - packageName: Name of the combo package. + - discountPercentage: Discount percentage applied to the package. + - services: Map of services included in the package. +Returns: + - A new ComboPackage object. +*/ ComboPackage::ComboPackage(const std::string& packageName, double discountPercentage, const util::Map& services) : m_id("CMP" + std::to_string(++m_uid)), m_packageName(packageName), @@ -14,51 +43,131 @@ ComboPackage::ComboPackage(const std::string& packageName, double discountPercen m_status(util::State::ACTIVE), m_services(services) {} +/* +Function: getId +Description: Retrieves the unique ID of the combo package. +Parameters: + - None +Returns: + - const std::string& representing the package ID. +*/ const std::string& ComboPackage::getId() const { return m_id; } +/* +Function: getPackageName +Description: Retrieves the name of the combo package. +Parameters: + - None +Returns: + - const std::string& representing the package name. +*/ const std::string& ComboPackage::getPackageName() const { return m_packageName; } +/* +Function: getDiscountPercentage +Description: Retrieves the discount percentage applied to the combo package. +Parameters: + - None +Returns: + - double representing the discount percentage. +*/ double ComboPackage::getDiscountPercentage() const { return m_discountPercentage; } +/* +Function: getState +Description: Retrieves the current state (ACTIVE/INACTIVE) of the combo package. +Parameters: + - None +Returns: + - util::State representing the package state. +*/ util::State ComboPackage::getState() const { return m_status; } +/* +Function: getServices +Description: Retrieves the map of services included in the combo package. +Parameters: + - None +Returns: + - const util::Map& representing the services. +*/ const util::Map& ComboPackage::getServices() const { return m_services; } +/* +Function: setId +Description: Sets the unique ID of the combo package. +Parameters: + - id: New ID string. +Returns: + - void +*/ void ComboPackage::setId(const std::string& id) { m_id = id; } +/* +Function: setPackageName +Description: Sets the name of the combo package. +Parameters: + - packageName: New package name string. +Returns: + - void +*/ void ComboPackage::setPackageName(const std::string& packageName) { m_packageName = packageName; } +/* +Function: setDiscountPercentage +Description: Sets the discount percentage for the combo package. +Parameters: + - discountPercentage: New discount percentage value. +Returns: + - void +*/ void ComboPackage::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; } +/* +Function: setServices +Description: Sets the services included in the combo package. +Parameters: + - services: Map of services to be associated with the package. +Returns: + - void +*/ void ComboPackage::setServices(const util::Map& services) { m_services = services; } +/* +Function: setState +Description: Sets the state (ACTIVE/INACTIVE) of the combo package. +Parameters: + - status: New state value. +Returns: + - void +*/ void ComboPackage::setState(util::State status) { m_status = status; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h index 4b28d54..a620ee4 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h @@ -1,3 +1,10 @@ +/* +File: ComboPackage.h +Description: Declares the ComboPackage class which represents a service package with a unique ID, package name, discount percentage, associated services, and status in the Vehicle Service Management System. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp index c3dbbaa..edc8654 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp @@ -1,13 +1,41 @@ +/* +File: InventoryItem.cpp +Description: Implements the InventoryItem class which represents an inventory item in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for item details such as ID, part name, quantity, price, and state. +Author: Trenser +Date: 19-May-2026 +*/ + #include "InventoryItem.h" int InventoryItem::m_uid = 0; +/* +Function: InventoryItem +Description: Default constructor that initializes a new inventory item with a unique ID, + active state, zero quantity, and zero price. +Parameters: + - None +Returns: + - A new InventoryItem object. +*/ InventoryItem::InventoryItem() : m_id("IIM" + std::to_string(++m_uid)), m_quantity(0), m_status(util::State::ACTIVE), m_price(0.0) {} +/* +Function: InventoryItem +Description: Parameterized constructor that initializes a new inventory item with a unique ID, + specified part name, quantity, price, and active state. +Parameters: + - partName: Name of the inventory item. + - quantity: Initial quantity of the item. + - price: Price of the item. +Returns: + - A new InventoryItem object. +*/ InventoryItem::InventoryItem(const std::string& partName, int quantity, double price) : m_id("IIM" + std::to_string(++m_uid)), m_partName(partName), @@ -15,51 +43,131 @@ InventoryItem::InventoryItem(const std::string& partName, int quantity, double p m_status(util::State::ACTIVE), m_price(price) {} +/* +Function: getId +Description: Retrieves the unique ID of the inventory item. +Parameters: + - None +Returns: + - const std::string& representing the item ID. +*/ const std::string& InventoryItem::getId() const { return m_id; } +/* +Function: getPartName +Description: Retrieves the part name of the inventory item. +Parameters: + - None +Returns: + - const std::string& representing the part name. +*/ const std::string& InventoryItem::getPartName() const { return m_partName; } +/* +Function: getQuantity +Description: Retrieves the current quantity of the inventory item. +Parameters: + - None +Returns: + - int representing the quantity. +*/ int InventoryItem::getQuantity() const { return m_quantity; } +/* +Function: getPrice +Description: Retrieves the price of the inventory item. +Parameters: + - None +Returns: + - double representing the price. +*/ double InventoryItem::getPrice() const { return m_price; } +/* +Function: getState +Description: Retrieves the current state (ACTIVE/INACTIVE) of the inventory item. +Parameters: + - None +Returns: + - util::State representing the item state. +*/ util::State InventoryItem::getState() const { return m_status; } +/* +Function: setId +Description: Sets the unique ID of the inventory item. +Parameters: + - id: New ID string. +Returns: + - void +*/ void InventoryItem::setId(const std::string& id) { m_id = id; } +/* +Function: setPartName +Description: Sets the part name of the inventory item. +Parameters: + - partName: New part name string. +Returns: + - void +*/ void InventoryItem::setPartName(const std::string& partName) { m_partName = partName; } +/* +Function: setQuantity +Description: Sets the quantity of the inventory item. +Parameters: + - quantity: New quantity value. +Returns: + - void +*/ void InventoryItem::setQuantity(int quantity) { m_quantity = quantity; } +/* +Function: setPrice +Description: Sets the price of the inventory item. +Parameters: + - price: New price value. +Returns: + - void +*/ void InventoryItem::setPrice(double price) { m_price = price; } +/* +Function: setState +Description: Sets the state (ACTIVE/INACTIVE) of the inventory item. +Parameters: + - status: New state value. +Returns: + - void +*/ void InventoryItem::setState(util::State status) { m_status = status; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h index d9618bc..0cb36ac 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h @@ -1,3 +1,12 @@ +/* +File: InventoryItem.h +Description: Declares the InventoryItem class which represents parts in the Vehicle Service Management System. + Each item has a unique ID, part name, quantity, price, and status. +Author: Trenser +Date: 19-May-2026 +*/ + + #pragma once #include #include "Enums.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp index ba7bc84..7c06e5b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp @@ -1,7 +1,26 @@ +/* +File: Invoice.cpp +Description: Implements the Invoice class which represents an invoice in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for invoice details such as ID, booking, costs, + discount percentage, total amount, payment details, and status. +Author: Trenser +Date: 19-May-2026 +*/ + #include "Invoice.h" int Invoice::m_uid = 0; +/* +Function: Invoice +Description: Default constructor that initializes a new invoice with a unique ID, + null booking, zero costs, zero discount, zero total amount, + and default payment method and status. +Parameters: + - None +Returns: + - A new Invoice object. +*/ Invoice::Invoice() : m_id("INV" + std::to_string(++m_uid)), m_booking(nullptr), @@ -12,6 +31,24 @@ Invoice::Invoice() m_paymentMethod(util::PaymentMode()), m_status(util::PaymentStatus()) {} +/* +Function: Invoice +Description: Parameterized constructor that initializes a new invoice with a unique ID and specified details. +Parameters: + - bookingId: ID of the associated service booking. + - booking: Pointer to the ServiceBooking object. + - invoiceDate: Timestamp of when the invoice was created. + - laborCost: Cost of labor for the service. + - parts: Map of inventory items used in the service. + - partsCost: Total cost of parts. + - discountPercentage: Discount applied to the invoice. + - totalAmount: Final total amount after discount. + - paymentDate: Timestamp of when payment was made. + - paymentMethod: Payment mode (ONLINE/OFFLINE). + - status: Payment status (PENDING/COMPLETED). +Returns: + - A new Invoice object. +*/ Invoice::Invoice( const std::string& bookingId, ServiceBooking* booking, @@ -38,122 +75,290 @@ Invoice::Invoice( m_paymentMethod(paymentMethod), m_status(status) {} +/* +Function: getId +Description: Retrieves the unique ID of the invoice. +Returns: + - const std::string& representing the invoice ID. +*/ const std::string& Invoice::getId() const { return m_id; } +/* +Function: getBookingId +Description: Retrieves the booking ID associated with the invoice. +Returns: + - const std::string& representing the booking ID. +*/ const std::string& Invoice::getBookingId() const { return m_bookingId; } +/* +Function: getBooking +Description: Retrieves the pointer to the associated ServiceBooking. +Returns: + - ServiceBooking* representing the booking. +*/ ServiceBooking* Invoice::getBooking() const { return m_booking; } +/* +Function: getInvoiceDate +Description: Retrieves the timestamp of the invoice creation date. +Returns: + - const util::Timestamp& representing the invoice date. +*/ const util::Timestamp& Invoice::getInvoiceDate() const { return m_invoiceDate; } +/* +Function: getLaborCost +Description: Retrieves the labor cost associated with the invoice. +Returns: + - double representing the labor cost. +*/ double Invoice::getLaborCost() const { return m_laborCost; } +/* +Function: getParts +Description: Retrieves the map of inventory items used in the service. +Returns: + - const util::Map& representing the parts. +*/ const util::Map& Invoice::getParts() const { return m_parts; } +/* +Function: getPartsCost +Description: Retrieves the total cost of parts used in the service. +Returns: + - double representing the parts cost. +*/ double Invoice::getPartsCost() const { return m_partsCost; } +/* +Function: getDiscountPercentage +Description: Retrieves the discount percentage applied to the invoice. +Returns: + - double representing the discount percentage. +*/ double Invoice::getDiscountPercentage() const { return m_discountPercentage; } +/* +Function: getTotalAmount +Description: Retrieves the total amount of the invoice after discount. +Returns: + - double representing the total amount. +*/ double Invoice::getTotalAmount() const { return m_totalAmount; } +/* +Function: getPaymentDate +Description: Retrieves the timestamp of the payment date. +Returns: + - const util::Timestamp& representing the payment date. +*/ const util::Timestamp& Invoice::getPaymentDate() const { return m_paymentDate; } +/* +Function: getPaymentMethod +Description: Retrieves the payment mode used for the invoice. +Returns: + - util::PaymentMode representing the payment method. +*/ util::PaymentMode Invoice::getPaymentMethod() const { return m_paymentMethod; } +/* +Function: getStatus +Description: Retrieves the payment status of the invoice. +Returns: + - util::PaymentStatus representing the payment status. +*/ util::PaymentStatus Invoice::getStatus() const { return m_status; } +/* +Function: setId +Description: Sets the unique ID of the invoice. +Parameters: + - id: New invoice ID string. +Returns: + - void +*/ void Invoice::setId(const std::string& id) { m_id = id; } +/* +Function: setBookingId +Description: Sets the booking ID associated with the invoice. +Parameters: + - bookingId: New booking ID string. +Returns: + - void +*/ void Invoice::setBookingId(const std::string& bookingId) { m_bookingId = bookingId; } +/* +Function: setBooking +Description: Sets the associated ServiceBooking pointer. +Parameters: + - booking: Pointer to the ServiceBooking object. +Returns: + - void +*/ void Invoice::setBooking(ServiceBooking* booking) { m_booking = booking; } +/* +Function: setInvoiceDate +Description: Sets the invoice creation date. +Parameters: + - invoiceDate: New timestamp for the invoice date. +Returns: + - void +*/ void Invoice::setInvoiceDate(const util::Timestamp& invoiceDate) { m_invoiceDate = invoiceDate; } +/* +Function: setLaborCost +Description: Sets the labor cost for the invoice. +Parameters: + - laborCost: New labor cost value. +Returns: + - void +*/ void Invoice::setLaborCost(double laborCost) { m_laborCost = laborCost; } +/* +Function: setParts +Description: Sets the inventory items used in the service. +Parameters: + - parts: Map of inventory items. +Returns: + - void +*/ void Invoice::setParts(const util::Map& parts) { m_parts = parts; } +/* +Function: setPartsCost +Description: Sets the total cost of parts used in the service. +Parameters: + - partsCost: New parts cost value. +Returns: + - void +*/ void Invoice::setPartsCost(double partsCost) { m_partsCost = partsCost; } +/* +Function: setDiscountPercentage +Description: Sets the discount percentage applied to the invoice. +Parameters: + - discountPercentage: New discount percentage value. +Returns: + - void +*/ void Invoice::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; } +/* +Function: setTotalAmount +Description: Sets the total amount of the invoice. +Parameters: + - totalAmount: New total amount value. +Returns: + - void +*/ void Invoice::setTotalAmount(double totalAmount) { m_totalAmount = totalAmount; } +/* +Function: setPaymentDate +Description: Sets the payment date for the invoice. +Parameters: + - paymentDate: New timestamp for the payment date. +Returns: + - void +*/ void Invoice::setPaymentDate(const util::Timestamp& paymentDate) { m_paymentDate = paymentDate; } +/* +Function: setPaymentMethod +Description: Sets the payment mode for the invoice. +Parameters: + - paymentMethod: New payment mode value. +Returns: + - void +*/ void Invoice::setPaymentMethod(util::PaymentMode paymentMethod) { m_paymentMethod = paymentMethod; } +/* +Function: setStatus +Description: Sets the payment status of the invoice. +Parameters: + - status: New payment status value. +Returns: + - void +*/ void Invoice::setStatus(util::PaymentStatus status) { m_status = status; -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h index 212d33f..b93cd77 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h @@ -1,3 +1,12 @@ +/* +File: Invoice.h +Description: Declares the Invoice class which represents billing details for a service booking in the Vehicle Service Management System. + Each invoice includes booking information, labor cost, parts used, discount percentage, total amount, payment details, and status. +Author: Trenser +Date: 19-May-2026 +*/ + + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp index 04e9195..747da0f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp @@ -1,7 +1,25 @@ +/* +File: JobCard.cpp +Description: Implements the JobCard class which represents a technicians job assignment in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for job details such as ID, booking, service, technician, + assigned date, completion date, and job status. +Author: Trenser +Date: 19-May-2026 +*/ + #include "JobCard.h" int JobCard::m_uid = 0; +/* +Function: JobCard +Description: Default constructor that initializes a new job card with a unique ID, + null booking, null service, null technician, and default job status. +Parameters: + - None +Returns: + - A new JobCard object. +*/ JobCard::JobCard() : m_id("JC" + std::to_string(++m_uid)), m_booking(nullptr), @@ -9,6 +27,22 @@ JobCard::JobCard() m_technician(nullptr), m_status(ServiceJobStatus()) {} +/* +Function: JobCard +Description: Parameterized constructor that initializes a new job card with a unique ID and specified details. +Parameters: + - bookingId: ID of the associated service booking. + - booking: Pointer to the ServiceBooking object. + - service: Pointer to the Service object. + - serviceId: ID of the associated service. + - technicianId: ID of the assigned technician. + - technician: Pointer to the User object representing the technician. + - assignedDate: Timestamp of when the job was assigned. + - status: Current status of the job (STARTED/COMPLETED). + - completionDate: Timestamp of when the job was completed. +Returns: + - A new JobCard object. +*/ JobCard::JobCard(const std::string& bookingId, ServiceBooking* booking, Service* service, @@ -30,101 +64,241 @@ JobCard::JobCard(const std::string& bookingId, m_status(status), m_completionDate(completionDate) {} +/* +Function: getId +Description: Retrieves the unique ID of the job card. +Returns: + - const std::string& representing the job card ID. +*/ const std::string& JobCard::getId() const { return m_id; } +/* +Function: getBookingId +Description: Retrieves the booking ID associated with the job card. +Returns: + - const std::string& representing the booking ID. +*/ const std::string& JobCard::getBookingId() const { return m_bookingId; } +/* +Function: getBooking +Description: Retrieves the pointer to the associated ServiceBooking. +Returns: + - ServiceBooking* representing the booking. +*/ ServiceBooking* JobCard::getBooking() const { return m_booking; } +/* +Function: getService +Description: Retrieves the pointer to the associated Service. +Returns: + - Service* representing the service. +*/ Service* JobCard::getService() const { return m_service; } +/* +Function: getServiceId +Description: Retrieves the service ID associated with the job card. +Returns: + - const std::string& representing the service ID. +*/ const std::string& JobCard::getServiceId() const { return m_serviceId; } +/* +Function: getTechnicianId +Description: Retrieves the technician ID associated with the job card. +Returns: + - const std::string& representing the technician ID. +*/ const std::string& JobCard::getTechnicianId() const { return m_technicianId; } +/* +Function: getTechnician +Description: Retrieves the pointer to the assigned technician. +Returns: + - User* representing the technician. +*/ User* JobCard::getTechnician() const { return m_technician; } +/* +Function: getAssignedDate +Description: Retrieves the timestamp of when the job was assigned. +Returns: + - const util::Timestamp& representing the assigned date. +*/ const util::Timestamp& JobCard::getAssignedDate() const { return m_assignedDate; } +/* +Function: getStatus +Description: Retrieves the current status of the job. +Returns: + - ServiceJobStatus representing the job status. +*/ ServiceJobStatus JobCard::getStatus() const { return m_status; } +/* +Function: getCompletionDate +Description: Retrieves the timestamp of when the job was completed. +Returns: + - const util::Timestamp& representing the completion date. +*/ const util::Timestamp& JobCard::getCompletionDate() const { return m_completionDate; } +/* +Function: setId +Description: Sets the unique ID of the job card. +Parameters: + - id: New job card ID string. +Returns: + - void +*/ void JobCard::setId(const std::string& id) { m_id = id; } +/* +Function: setBookingId +Description: Sets the booking ID associated with the job card. +Parameters: + - bookingId: New booking ID string. +Returns: + - void +*/ void JobCard::setBookingId(const std::string& bookingId) { m_bookingId = bookingId; } +/* +Function: setBooking +Description: Sets the associated ServiceBooking pointer. +Parameters: + - booking: Pointer to the ServiceBooking object. +Returns: + - void +*/ void JobCard::setBooking(ServiceBooking* booking) { m_booking = booking; } +/* +Function: setService +Description: Sets the associated Service pointer. +Parameters: + - service: Pointer to the Service object. +Returns: + - void +*/ void JobCard::setService(Service* service) { m_service = service; } +/* +Function: setServiceId +Description: Sets the service ID associated with the job card. +Parameters: + - serviceId: New service ID string. +Returns: + - void +*/ void JobCard::setServiceId(const std::string& serviceId) { m_serviceId = serviceId; } +/* +Function: setTechnicianId +Description: Sets the technician ID associated with the job card. +Parameters: + - technicianId: New technician ID string. +Returns: + - void +*/ void JobCard::setTechnicianId(const std::string& technicianId) { m_technicianId = technicianId; } +/* +Function: setTechnician +Description: Sets the pointer to the assigned technician. +Parameters: + - technician: Pointer to the User object. +Returns: + - void +*/ void JobCard::setTechnician(User* technician) { m_technician = technician; } +/* +Function: setAssignedDate +Description: Sets the timestamp of when the job was assigned. +Parameters: + - assignedDate: New timestamp for the assigned date. +Returns: + - void +*/ void JobCard::setAssignedDate(const util::Timestamp& assignedDate) { m_assignedDate = assignedDate; } +/* +Function: setStatus +Description: Sets the current status of the job. +Parameters: + - status: New job status value. +Returns: + - void +*/ void JobCard::setStatus(ServiceJobStatus status) { m_status = status; } +/* +Function: setCompletionDate +Description: Sets the timestamp of when the job was completed. +Parameters: + - completionDate: New timestamp for the completion date. +Returns: + - void +*/ void JobCard::setCompletionDate(const util::Timestamp& completionDate) { m_completionDate = completionDate; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h index 15a8a5d..bdc736d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h @@ -1,3 +1,11 @@ +/* +File: JobCard.h +Description: Declares the JobCard class which represents a technicians job assignment in the Vehicle Service Management System. + Each job card includes booking details, associated service, technician information, assigned and completion dates, and job status. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Timestamp.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp index dc3ed1d..353bcb2 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp @@ -1,11 +1,39 @@ +/* +File: Notification.cpp +Description: Implements the Notification class which represents system notifications in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for notification details such as ID, recipient, title, message, and timestamp. +Author: Trenser +Date: 19-May-2026 +*/ + #include "Notification.h" int Notification::m_uid = 0; +/* +Function: Notification +Description: Default constructor that initializes a new notification with a unique ID and null recipient. +Parameters: + - None +Returns: + - A new Notification object. +*/ Notification::Notification() : m_id("NOT" + std::to_string(++m_uid)), m_recipient(nullptr) {} +/* +Function: Notification +Description: Parameterized constructor that initializes a new notification with a unique ID and specified details. +Parameters: + - recipientUserId: ID of the recipient user. + - recipient: Pointer to the User object representing the recipient. + - title: Title of the notification. + - message: Message content of the notification. + - createdAt: Timestamp of when the notification was created. +Returns: + - A new Notification object. +*/ Notification::Notification(const std::string& recipientUserId, User* recipient, const std::string& title, const std::string& message, const util::Timestamp& createdAt) : m_id("NOT" + std::to_string(++m_uid)), m_recipientUserId(recipientUserId), @@ -14,61 +42,145 @@ Notification::Notification(const std::string& recipientUserId, User* recipient, m_message(message), m_createdAt(createdAt) {} +/* +Function: getId +Description: Retrieves the unique ID of the notification. +Returns: + - const std::string& representing the notification ID. +*/ const std::string& Notification::getId() const { return m_id; } +/* +Function: getRecipientUserId +Description: Retrieves the recipient user ID associated with the notification. +Returns: + - const std::string& representing the recipient user ID. +*/ const std::string& Notification::getRecipientUserId() const { return m_recipientUserId; } +/* +Function: getRecipient +Description: Retrieves the pointer to the recipient user. +Returns: + - User* representing the recipient. +*/ User* Notification::getRecipient() const { return m_recipient; } +/* +Function: getTitle +Description: Retrieves the title of the notification. +Returns: + - const std::string& representing the notification title. +*/ const std::string& Notification::getTitle() const { return m_title; } +/* +Function: getMessage +Description: Retrieves the message content of the notification. +Returns: + - const std::string& representing the notification message. +*/ const std::string& Notification::getMessage() const { return m_message; } +/* +Function: getCreatedAt +Description: Retrieves the timestamp of when the notification was created. +Returns: + - const util::Timestamp& representing the creation timestamp. +*/ const util::Timestamp& Notification::getCreatedAt() const { return m_createdAt; } +/* +Function: setId +Description: Sets the unique ID of the notification. +Parameters: + - id: New notification ID string. +Returns: + - void +*/ void Notification::setId(const std::string& id) { m_id = id; } +/* +Function: setRecipientUserId +Description: Sets the recipient user ID for the notification. +Parameters: + - recipientUserId: New recipient user ID string. +Returns: + - void +*/ void Notification::setRecipientUserId(const std::string& recipientUserId) { m_recipientUserId = recipientUserId; } +/* +Function: setRecipient +Description: Sets the recipient user pointer for the notification. +Parameters: + - recipient: Pointer to the User object. +Returns: + - void +*/ void Notification::setRecipient(User* recipient) { m_recipient = recipient; } +/* +Function: setTitle +Description: Sets the title of the notification. +Parameters: + - title: New notification title string. +Returns: + - void +*/ void Notification::setTitle(const std::string& title) { m_title = title; } +/* +Function: setMessage +Description: Sets the message content of the notification. +Parameters: + - message: New notification message string. +Returns: + - void +*/ void Notification::setMessage(const std::string& message) { m_message = message; } +/* +Function: setCreatedAt +Description: Sets the timestamp of when the notification was created. +Parameters: + - createdAt: New timestamp value. +Returns: + - void +*/ void Notification::setCreatedAt(const util::Timestamp& createdAt) { m_createdAt = createdAt; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h index f86499e..0ba780b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h @@ -1,3 +1,11 @@ +/* +File: Notification.h +Description: Declares the Notification class which represents system messages sent to users in the Vehicle Service Management System. + Each notification includes a unique ID, recipient details, title, message content, and timestamp of creation. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Timestamp.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp index fa7f509..02fe9ea 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp @@ -1,12 +1,40 @@ +/* +File: Service.cpp +Description: Implements the Service class which represents a vehicle service in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for service details such as ID, name, required inventory items, + labor cost, and state. +Author: Trenser +Date: 19-May-2026 +*/ + #include "Service.h" int Service::m_uid = 0; +/* +Function: Service +Description: Default constructor that initializes a new service with a unique ID, + active state, and zero labor cost. +Parameters: + - None +Returns: + - A new Service object. +*/ Service::Service() : m_id("SRV" + std::to_string(++m_uid)), m_status(util::State::ACTIVE), m_laborCost(0.0) {} +/* +Function: Service +Description: Parameterized constructor that initializes a new service with a unique ID and specified details. +Parameters: + - name: Name of the service. + - requiredInventoryItems: Map of inventory items required for the service. + - laborCost: Labor cost associated with the service. +Returns: + - A new Service object. +*/ Service::Service(const std::string& name, const util::Map& requiredInventoryItems, double laborCost) : m_id("SRV" + std::to_string(++m_uid)), m_name(name), @@ -14,51 +42,121 @@ Service::Service(const std::string& name, const util::Map& representing the required inventory items. +*/ const util::Map& Service::getRequiredInventoryItems() const { return m_requiredInventoryItems; } +/* +Function: getLaborCost +Description: Retrieves the labor cost associated with the service. +Returns: + - double representing the labor cost. +*/ double Service::getLaborCost() const { return m_laborCost; } +/* +Function: getState +Description: Retrieves the current state (ACTIVE/INACTIVE) of the service. +Returns: + - util::State representing the service state. +*/ util::State Service::getState() const { return m_status; } +/* +Function: setId +Description: Sets the unique ID of the service. +Parameters: + - id: New service ID string. +Returns: + - void +*/ void Service::setId(const std::string& id) { m_id = id; } +/* +Function: setName +Description: Sets the name of the service. +Parameters: + - name: New service name string. +Returns: + - void +*/ void Service::setName(const std::string& name) { m_name = name; } +/* +Function: setRequiredInventoryItems +Description: Sets the inventory items required for the service. +Parameters: + - requiredInventoryItems: Map of inventory items. +Returns: + - void +*/ void Service::setRequiredInventoryItems(const util::Map& requiredInventoryItems) { m_requiredInventoryItems = requiredInventoryItems; } +/* +Function: setLaborCost +Description: Sets the labor cost for the service. +Parameters: + - laborCost: New labor cost value. +Returns: + - void +*/ void Service::setLaborCost(double laborCost) { m_laborCost = laborCost; } +/* +Function: setState +Description: Sets the state (ACTIVE/INACTIVE) of the service. +Parameters: + - status: New state value. +Returns: + - void +*/ void Service::setState(util::State status) { m_status = status; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h index b0d3175..7d15ebe 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h @@ -1,3 +1,12 @@ +/* +File: Service.h +Description: Declares the Service class which represents a vehicle service in the Vehicle Service Management System. + Each service includes a unique ID, name, required inventory items, labor cost, and status. +Author: Trenser +Date: 19-May-2026 +*/ + + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 1fdfaf0..90c218c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -1,12 +1,48 @@ +/* +File: ServiceBooking.cpp +Description: Implements the ServiceBooking class which represents a customers service booking in the Vehicle Service Management System. + Provides constructors, accessors, and mutators for booking details such as ID, status, services, customer, + vehicle information, assigned technician, and discount percentage. +Author: Trenser +Date: 19-May-2026 +*/ + #include "ServiceBooking.h" int ServiceBooking::m_uid = 0; +/* +Function: ServiceBooking +Description: Default constructor that initializes a new service booking with a unique ID, + null customer, and zero discount percentage. +Parameters: + - None +Returns: + - A new ServiceBooking object. +*/ ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), m_discountPercentage(0.0) {} +/* +Function: ServiceBooking +Description: Parameterized constructor that initializes a new service booking with a unique ID and specified details. +Parameters: + - id: Booking ID string. + - status: Current status of the booking (e.g., PENDING, COMPLETED). + - services: Map of services included in the booking. + - customerId: ID of the customer. + - customer: Pointer to the User object representing the customer. + - vehicleNumber: Vehicle registration number. + - vehicleBrand: Brand of the vehicle. + - vehicleModel: Model of the vehicle. + - assignedTechnicianId: ID of the assigned technician. + - assignedTechnician: Name of the assigned technician. + - discountPercentage: Discount applied to the booking. +Returns: + - A new ServiceBooking object. +*/ ServiceBooking::ServiceBooking( const std::string& id, util::ServiceJobStatus status, @@ -35,111 +71,265 @@ ServiceBooking::ServiceBooking( { } +/* +Function: getId +Description: Retrieves the unique ID of the service booking. +Returns: + - const std::string& representing the booking ID. +*/ const std::string& ServiceBooking::getId() const { return m_id; } +/* +Function: getStatus +Description: Retrieves the current status of the service booking. +Returns: + - util::ServiceJobStatus representing the booking status. +*/ util::ServiceJobStatus ServiceBooking::getStatus() const { return m_status; } +/* +Function: getServices +Description: Retrieves the map of services included in the booking. +Returns: + - const util::Map& representing the services. +*/ const util::Map& ServiceBooking::getServices() const { return m_services; } +/* +Function: getCustomerId +Description: Retrieves the customer ID associated with the booking. +Returns: + - const std::string& representing the customer ID. +*/ const std::string& ServiceBooking::getCustomerId() const { return m_customerId; } +/* +Function: getCustomer +Description: Retrieves the pointer to the associated customer. +Returns: + - User* representing the customer. +*/ User* ServiceBooking::getCustomer() const { return m_customer; } +/* +Function: getVehicleNumber +Description: Retrieves the vehicle registration number. +Returns: + - const std::string& representing the vehicle number. +*/ const std::string& ServiceBooking::getVehicleNumber() const { return m_vehicleNumber; } +/* +Function: getVehicleBrand +Description: Retrieves the brand of the vehicle. +Returns: + - const std::string& representing the vehicle brand. +*/ const std::string& ServiceBooking::getVehicleBrand() const { return m_vehicleBrand; } +/* +Function: getVehicleModel +Description: Retrieves the model of the vehicle. +Returns: + - const std::string& representing the vehicle model. +*/ const std::string& ServiceBooking::getVehicleModel() const { return m_vehicleModel; } +/* +Function: getAssignedTechnicianId +Description: Retrieves the ID of the assigned technician. +Returns: + - const std::string& representing the technician ID. +*/ const std::string& ServiceBooking::getAssignedTechnicianId() const { return m_assignedTechnicianId; } +/* +Function: getAssignedTechnician +Description: Retrieves the name of the assigned technician. +Returns: + - const std::string& representing the technician name. +*/ const std::string& ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } +/* +Function: getDiscountPercentage +Description: Retrieves the discount percentage applied to the booking. +Returns: + - double representing the discount percentage. +*/ double ServiceBooking::getDiscountPercentage() const { return m_discountPercentage; } +/* +Function: setId +Description: Sets the unique ID of the service booking. +Parameters: + - id: New booking ID string. +Returns: + - void +*/ void ServiceBooking::setId(const std::string& id) { m_id = id; } +/* +Function: setStatus +Description: Sets the current status of the service booking. +Parameters: + - status: New booking status value. +Returns: + - void +*/ void ServiceBooking::setStatus(const util::ServiceJobStatus& status) { m_status = status; } +/* +Function: setServices +Description: Sets the services included in the booking. +Parameters: + - services: Map of services. +Returns: + - void +*/ void ServiceBooking::setServices(const util::Map& services) { m_services = services; } +/* +Function: setCustomerId +Description: Sets the customer ID associated with the booking. +Parameters: + - customerId: New customer ID string. +Returns: + - void +*/ void ServiceBooking::setCustomerId(const std::string& customerId) { m_customerId = customerId; } +/* +Function: setCustomer +Description: Sets the pointer to the associated customer. +Parameters: + - customer: Pointer to the User object. +Returns: + - void +*/ void ServiceBooking::setCustomer(User* customer) { m_customer = customer; } +/* +Function: setVehicleNumber +Description: Sets the vehicle registration number. +Parameters: + - vehicleNumber: New vehicle number string. +Returns: + - void +*/ void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber) { m_vehicleNumber = vehicleNumber; } +/* +Function: setVehicleBrand +Description: Sets the brand of the vehicle. +Parameters: + - vehicleBrand: New vehicle brand string. +Returns: + - void +*/ void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand) { m_vehicleBrand = vehicleBrand; } +/* +Function: setVehicleModel +Description: Sets the model of the vehicle. +Parameters: + - vehicleModel: New vehicle model string. +Returns: + - void +*/ void ServiceBooking::setVehicleModel(const std::string& vehicleModel) { m_vehicleModel = vehicleModel; } +/* +Function: setAssignedTechnicianId +Description: Sets the ID of the assigned technician. +Parameters: + - assignedTechnicianId: New technician ID string. +Returns: + - void +*/ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId) { m_assignedTechnicianId = assignedTechnicianId; } +/* +Function: setAssignedTechnician +Description: Sets the name of the assigned technician. +Parameters: + - assignedTechnician: New technician name string. +Returns: + - void +*/ void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician) { m_assignedTechnician = assignedTechnician; } +/* +Function: setDiscountPercentage +Description: Sets the discount percentage applied to the booking. +Parameters: + - discountPercentage: New discount percentage value. +Returns: + - void +*/ void ServiceBooking::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 5ecc1b0..6c600ed 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -1,3 +1,11 @@ +/* +File: ServiceBooking.h +Description: Declares the ServiceBooking class which represents a customers service booking in the Vehicle Service Management System. + Each booking includes a unique ID, status, associated services, customer details, vehicle information, assigned technician, and discount percentage. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp index 6e0b531..0b0fa58 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp @@ -1,14 +1,45 @@ +/* +File: User.cpp +Description: Implements the User class which represents system users in the Vehicle Service Management System. + Provides constructors, destructor, accessors, and mutators for user details such as ID, username, + password, name, phone, email, role, state, and notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #include "User.h" #include "Notification.h" #include "Enums.h" int User::m_uid = 0; +/* +Function: User +Description: Default constructor that initializes a new user with a unique ID, + default role as CUSTOMER, and active state. +Parameters: + - None +Returns: + - A new User object. +*/ User::User() : m_id("USR" + std::to_string(++m_uid)), m_type(util::UserType::CUSTOMER), m_status(util::State::ACTIVE) {} +/* +Function: User +Description: Parameterized constructor that initializes a new user with a unique ID and specified details. +Parameters: + - userName: Username for login. + - password: Password for authentication. + - name: Full name of the user. + - phone: Phone number of the user. + - email: Email address of the user. + - role: Role of the user (CUSTOMER, ADMIN, TECHNICIAN, etc.). +Returns: + - A new User object. +*/ User::User(const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role) : m_id("USR" + std::to_string(++m_uid)), m_userName(userName), @@ -19,6 +50,14 @@ User::User(const std::string& userName, const std::string& password, const std:: m_type(role), m_status(util::State::ACTIVE) {} +/* +Function: ~User +Description: Destructor that cleans up dynamically allocated notifications associated with the user. +Parameters: + - None +Returns: + - void +*/ User::~User() { for (int index = 0; index < m_notifications.getSize(); index++) @@ -27,81 +66,191 @@ User::~User() } } +/* +Function: getId +Description: Retrieves the unique ID of the user. +Returns: + - const std::string& representing the user ID. +*/ const std::string& User::getId() const { return m_id; } +/* +Function: getUserName +Description: Retrieves the username of the user. +Returns: + - const std::string& representing the username. +*/ const std::string& User::getUserName() const { return m_userName; } +/* +Function: getPassword +Description: Retrieves the password of the user. +Returns: + - const std::string& representing the password. +*/ const std::string& User::getPassword() const { return m_password; } +/* +Function: getName +Description: Retrieves the full name of the user. +Returns: + - const std::string& representing the name. +*/ const std::string& User::getName() const { return m_name; } +/* +Function: getPhone +Description: Retrieves the phone number of the user. +Returns: + - const std::string& representing the phone number. +*/ const std::string& User::getPhone() const { return m_phone; } +/* +Function: getEmail +Description: Retrieves the email address of the user. +Returns: + - const std::string& representing the email. +*/ const std::string& User::getEmail() const { return m_email; } +/* +Function: getNotifications +Description: Retrieves the map of notifications associated with the user. +Returns: + - util::Map& representing the notifications. +*/ util::Map& User::getNotifications() { return m_notifications; } +/* +Function: getUserType +Description: Retrieves the role of the user. +Returns: + - util::UserType representing the user role. +*/ util::UserType User::getUserType() const { return m_type; } +/* +Function: getState +Description: Retrieves the current state (ACTIVE/INACTIVE) of the user. +Returns: + - util::State representing the user state. +*/ util::State User::getState() const { return m_status; } +/* +Function: setId +Description: Sets the unique ID of the user. +Parameters: + - id: New user ID string. +Returns: + - void +*/ void User::setId(const std::string& id) { m_id = id; } +/* +Function: setUserName +Description: Sets the username of the user. +Parameters: + - userName: New username string. +Returns: + - void +*/ void User::setUserName(const std::string& userName) { m_userName = userName; } +/* +Function: setPassword +Description: Sets the password of the user. +Parameters: + - password: New password string. +Returns: + - void +*/ void User::setPassword(const std::string& password) { m_password = password; } +/* +Function: setName +Description: Sets the full name of the user. +Parameters: + - name: New name string. +Returns: + - void +*/ void User::setName(const std::string& name) { m_name = name; } +/* +Function: setPhone +Description: Sets the phone number of the user. +Parameters: + - phone: New phone number string. +Returns: + - void +*/ void User::setPhone(const std::string& phone) { m_phone = phone; } +/* +Function: setEmail +Description: Sets the email address of the user. +Parameters: + - email: New email string. +Returns: + - void +*/ void User::setEmail(const std::string& email) { m_email = email; } +/* +Function: addNotification +Description: Adds a new notification to the users notification map. +Parameters: + - notification: Pointer to the Notification object. +Returns: + - void +*/ void User::addNotification(Notification* notification) { if (notification) @@ -110,11 +259,27 @@ void User::addNotification(Notification* notification) } } +/* +Function: setRole +Description: Sets the role of the user. +Parameters: + - role: New user role value. +Returns: + - void +*/ void User::setRole(util::UserType role) { m_type = role; } +/* +Function: setState +Description: Sets the state (ACTIVE/INACTIVE) of the user. +Parameters: + - status: New state value. +Returns: + - void +*/ void User::setState(util::State status) { m_status = status; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h index b12ea78..1c5c215 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h @@ -1,3 +1,12 @@ +/* +File: User.h +Description: Declares the User class which represents system users in the Vehicle Service Management System. + Each user has a unique ID, credentials, personal details, notifications, role type, and status. + The User class also implements the Observer interface to handle notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h index ee0ed91..dd97650 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h @@ -1,3 +1,11 @@ +/* +File: AuthenticationManagementService.h +Description: Declares the AuthenticationManagementService class which manages user authentication in the Vehicle Service Management System. + Provides functionality for login, logout, password change, and retrieving the currently authenticated user. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "DataStore.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h index 099b964..da63a84 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h @@ -1,3 +1,11 @@ +/* +File: InventoryManagementService.h +Description: Declares the InventoryManagementService class which manages inventory operations in the Vehicle Service Management System. + Provides functionality to retrieve, add, and remove inventory items, send low stock alerts, and handle notifications using the Observer pattern. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h index 0b60c14..18d0dda 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h @@ -1,3 +1,11 @@ +/* +File: NotificationManagementService.h +Description: Declares the NotificationManagementService abstract class which defines the contract for managing notifications in the Vehicle Service Management System. + Implements the Subject interface and provides pure virtual methods for sending notifications and managing user subscriptions (attach/detach). +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Subject.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 2bb6717..12082cf 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -1,3 +1,12 @@ +/* +File: PaymentManagementService.cpp +Description: Implements the PaymentManagementService class which manages payment-related operations + in the Vehicle Service Management System. Provides functionality for attaching/detaching observers, + sending notifications, and issuing payment reminders based on invoice status and thresholds. +Author: Trenser +Date: 20-May-2026 +*/ + #include #include "PaymentManagementService.h" #include "Invoice.h" @@ -10,6 +19,14 @@ util::Map PaymentManagementService::m_observers{}; +/* +Function: attach +Description: Attaches a user as an observer to the PaymentManagementService for receiving notifications. +Parameters: + - user: Pointer to the User object to be attached. +Returns: + - void +*/ void PaymentManagementService::attach(User* user) { if (user) @@ -22,6 +39,14 @@ void PaymentManagementService::attach(User* user) } } +/* +Function: detach +Description: Detaches a user from the observer list of the PaymentManagementService. +Parameters: + - user: Pointer to the User object to be detached. +Returns: + - void +*/ void PaymentManagementService::detach(User* user) { if (user) @@ -34,6 +59,18 @@ void PaymentManagementService::detach(User* user) } } +/* +Function: sendNotification +Description: Sends a notification to a user if they are registered as an observer. +Parameters: + - user: Pointer to the User object to receive the notification. + - title: Title of the notification. + - message: Message content of the notification. +Returns: + - void +Throws: + - std::runtime_error if notification creation fails. +*/ void PaymentManagementService::sendNotification(User* user, const std::string& title, const std::string& message) { if (user) @@ -60,6 +97,15 @@ void PaymentManagementService::sendNotification(User* user, const std::string& t } } +/* +Function: sendPaymentReminders +Description: Iterates through all invoices in the datastore and sends payment reminders to customers + whose invoices are pending beyond the configured threshold duration. +Parameters: + - None +Returns: + - void +*/ void PaymentManagementService::sendPaymentReminders() { auto& invoicesMap = m_dataStore.getInvoices(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h index 56a2fd2..c6e43a0 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h @@ -1,3 +1,12 @@ +/* +File: PaymentManagementService.h +Description: Declares the PaymentManagementService class which manages payment operations in the Vehicle Service Management System. + Provides functionality to generate invoices, retrieve customer invoices, complete payments, send payment reminders, + and handle notifications using the Observer pattern. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index ac518ed..5f3c740 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1,3 +1,12 @@ +/* +File: ServiceManagementService.cpp +Description: Implements the ServiceManagementService class which manages service-related operations + in the Vehicle Service Management System. Provides functionality for attaching/detaching observers + and sending notifications to users regarding service events. +Author: Trenser +Date: 20-May-2026 +*/ + #include #include "ServiceManagementService.h" #include "User.h" @@ -6,6 +15,14 @@ util::Map ServiceManagementService::m_observers{}; +/* +Function: attach +Description: Attaches a user as an observer to the ServiceManagementService for receiving notifications. +Parameters: + - user: Pointer to the User object to be attached. +Returns: + - void +*/ void ServiceManagementService::attach(User* user) { if (user) @@ -18,6 +35,14 @@ void ServiceManagementService::attach(User* user) } } +/* +Function: detach +Description: Detaches a user from the observer list of the ServiceManagementService. +Parameters: + - user: Pointer to the User object to be detached. +Returns: + - void +*/ void ServiceManagementService::detach(User* user) { if (user) @@ -30,6 +55,18 @@ void ServiceManagementService::detach(User* user) } } +/* +Function: sendNotification +Description: Sends a notification to a user if they are registered as an observer. +Parameters: + - user: Pointer to the User object to receive the notification. + - title: Title of the notification. + - message: Message content of the notification. +Returns: + - void +Throws: + - std::runtime_error if notification creation fails. +*/ void ServiceManagementService::sendNotification(User* user, const std::string& title, const std::string& message) { if (user) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h index 85e05ed..2a97218 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h @@ -1,3 +1,12 @@ +/* +File: ServiceManagementService.h +Description: Declares the ServiceManagementService class which manages services, combo packages, service bookings, and job cards + in the Vehicle Service Management System. Provides functionality to purchase services or packages, create and remove + services, assign and complete jobs, cancel bookings, and handle notifications using the Observer pattern. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index bff09b1..d989346 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1,8 +1,27 @@ +/* +File: UserManagementService.cpp +Description: Implements the UserManagementService class which manages user-related operations + in the Vehicle Service Management System. Provides functionality for retrieving user notifications + and deleting notifications by ID. +Author: Trenser +Date: 20-May-2026 +*/ + #include #include "UserManagementService.h" #include "User.h" #include "Vector.h" +/* +Function: getUserNotifications +Description: Retrieves all notifications associated with a given user ID. +Parameters: + - userID: The unique ID of the user whose notifications are to be retrieved. +Returns: + - util::Vector containing all notifications for the user. +Throws: + - std::runtime_error if no user is found with the given UserID or if the User object is invalid. +*/ util::Vector UserManagementService::getUserNotifications(const std::string& userID) { auto& usersMap = m_dataStore.getUsers(); @@ -28,6 +47,17 @@ util::Vector UserManagementService::getUserNotifications(const st } } +/* +Function: deleteNotification +Description: Deletes a specific notification associated with a given user ID. +Parameters: + - notificationID: The unique ID of the notification to be deleted. + - userID: The unique ID of the user whose notification is to be deleted. +Returns: + - void +Throws: + - std::runtime_error if no user is found with the given UserID or if no notification is found with the given NotificationID. +*/ void UserManagementService::deleteNotification(const std::string& notificationID, const std::string& userID) { auto& usersMap = m_dataStore.getUsers(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index bb7a85a..aaf315f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -1,3 +1,11 @@ +/* +File: UserManagementService.h +Description: Declares the UserManagementService class which manages user-related operations in the Vehicle Service Management System. + Provides functionality to create, update, retrieve, and remove users, as well as manage user notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include #include "Map.h" @@ -17,7 +25,7 @@ public: void updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone); util::Map getUsers(); util::Map getUsers(util::UserType type); - User* getUser(const std::string& userID); + User* getUser (const std::string& userID); void removeUser(const std::string& userID); util::Vector getUserNotifications(const std::string& userID); void deleteNotification(const std::string& notificationID, const std::string& userID); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h index 8b7b488..057a908 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -1,3 +1,11 @@ +/* +File: Config.h +Description: Defines configuration constants for system thresholds in the Vehicle Service Management System. + Includes limits for inventory stock alerts and payment reminder intervals. +Author: Trenser +Date: 21-May-2026 +*/ + #pragma once namespace config diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h index 24bbdcd..60f2d9b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h @@ -1,3 +1,12 @@ +/* +File: Enums.h +Description: Declares enumerations and utility functions for user types, payment modes, payment status, + service job status, and state management in the Vehicle Service Management System. + Provides string conversion and parsing functions for each enum type. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include @@ -34,6 +43,14 @@ namespace util INACTIVE }; + /* + Function: getUserTypeString + Description: Converts a UserType enum value to its corresponding string representation. + Parameters: + - type: UserType enum value. + Returns: + - std::string representing the UserType. + */ inline std::string getUserTypeString(UserType type) { switch (type) @@ -48,6 +65,16 @@ namespace util throw std::invalid_argument("Invalid UserType"); } + /* + Function: getUserType + Description: Converts a string value to its corresponding UserType enum. + Parameters: + - value: std::string representing the UserType. + Returns: + - UserType enum value. + Throws: + - std::invalid_argument if the string does not match a valid UserType. + */ inline UserType getUserType(const std::string& value) { if (value == "ADMIN") @@ -65,6 +92,14 @@ namespace util throw std::invalid_argument("Invalid UserType string"); } + /* + Function: getPaymentModeString + Description: Converts a PaymentMode enum value to its corresponding string representation. + Parameters: + - mode: PaymentMode enum value. + Returns: + - std::string representing the PaymentMode. + */ inline std::string getPaymentModeString(PaymentMode mode) { switch (mode) @@ -77,6 +112,16 @@ namespace util throw std::invalid_argument("Invalid PaymentMode"); } + /* + Function: getPaymentMode + Description: Converts a string value to its corresponding PaymentMode enum. + Parameters: + - value: std::string representing the PaymentMode. + Returns: + - PaymentMode enum value. + Throws: + - std::invalid_argument if the string does not match a valid PaymentMode. + */ inline PaymentMode getPaymentMode(const std::string& value) { if (value == "ONLINE") @@ -90,6 +135,14 @@ namespace util throw std::invalid_argument("Invalid PaymentMode string"); } + /* + Function: getPaymentStatusString + Description: Converts a PaymentStatus enum value to its corresponding string representation. + Parameters: + - status: PaymentStatus enum value. + Returns: + - std::string representing the PaymentStatus. + */ inline std::string getPaymentStatusString(PaymentStatus status) { switch (status) @@ -102,6 +155,16 @@ namespace util throw std::invalid_argument("Invalid PaymentStatus"); } + /* + Function: getPaymentStatus + Description: Converts a string value to its corresponding PaymentStatus enum. + Parameters: + - value: std::string representing the PaymentStatus. + Returns: + - PaymentStatus enum value. + Throws: + - std::invalid_argument if the string does not match a valid PaymentStatus. + */ inline PaymentStatus getPaymentStatus(const std::string& value) { if (value == "PENDING") @@ -117,6 +180,14 @@ namespace util throw std::invalid_argument("Invalid PaymentStatus string"); } + /* + Function: getServiceJobStatusString + Description: Converts a ServiceJobStatus enum value to its corresponding string representation. + Parameters: + - status: ServiceJobStatus enum value. + Returns: + - std::string representing the ServiceJobStatus. + */ inline std::string getServiceJobStatusString(ServiceJobStatus status) { switch (status) @@ -129,6 +200,16 @@ namespace util throw std::invalid_argument("Invalid ServiceJobStatus"); } + /* + Function: getServiceJobStatus + Description: Converts a string value to its corresponding ServiceJobStatus enum. + Parameters: + - value: std::string representing the ServiceJobStatus. + Returns: + - ServiceJobStatus enum value. + Throws: + - std::invalid_argument if the string does not match a valid ServiceJobStatus. + */ inline ServiceJobStatus getServiceJobStatus(const std::string& value) { if (value == "STARTED") @@ -142,6 +223,14 @@ namespace util throw std::invalid_argument("Invalid ServiceJobStatus string"); } + /* + Function: getStateString + Description: Converts a State enum value to its corresponding string representation. + Parameters: + - status: State enum value. + Returns: + - std::string representing the State. + */ inline std::string getStateString(State status) { switch (status) @@ -154,6 +243,16 @@ namespace util throw std::invalid_argument("Invalid State"); } + /* + Function: getState + Description: Converts a string value to its corresponding State enum. + Parameters: + - value: std::string representing the State. + Returns: + - State enum value. + Throws: + - std::invalid_argument if the string does not match a valid State. + */ inline State getState(const std::string& value) { if (value == "ACTIVE") diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h index 6f70f09..a9c1529 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -1 +1,8 @@ +/* +File: Utility.h +Description: +Author: Trenser +Date: 20-May-2026 +*/ + #pragma once diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 589df33..4e81925 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,8 +1,27 @@ +/* +File: AdminMenu.cpp +Description: Implements the AdminMenu class which provides the administrators console interface + in the Vehicle Service Management System. Handles menu display, user input, and + admin-specific operations such as inventory management, technician management, + service creation, combo package management, job assignment, and notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #include "AdminMenu.h" #include "InputHelper.h" #include "OutputHelper.h" #include "MenuHelper.h" +/* +Function: showMenu +Description: Displays the admin menu in a loop until the user chooses to logout. + Handles exceptions and ensures smooth user interaction. +Parameters: + - None +Returns: + - void +*/ void AdminMenu::showMenu() { bool isMenuActive = true; @@ -85,6 +104,14 @@ void AdminMenu::removeComboPackage() { } +/* +Function: viewNotifications +Description: Displays notifications for the admin and allows deletion of notifications. +Parameters: + - None +Returns: + - void +*/ void AdminMenu::viewNotifications() { viewAndDeleteNotification(m_controller); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h index 05fdd84..cc4ff2f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h @@ -1,3 +1,12 @@ +/* +File: AdminMenu.h +Description: Declares the AdminMenu class which provides the administrative console menu in the Vehicle Service Management System. + Supports operations such as inventory management, job assignment, service creation/removal, technician management, + combo package handling, notification viewing, and account management functions like logout and password change. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include "Controller.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index ac5fabd..37f0695 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,8 +1,27 @@ +/* +File: CustomerMenu.cpp +Description: Implements the CustomerMenu class which provides the customers console interface + in the Vehicle Service Management System. Handles menu display, user input, and + customer-specific operations such as booking services, viewing history, managing payments, + invoices, and notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #include "CustomerMenu.h" #include "InputHelper.h" #include "OutputHelper.h" #include "MenuHelper.h" +/* +Function: showMenu +Description: Displays the customer menu in a loop until the user chooses to logout. + Handles exceptions and ensures smooth user interaction. +Parameters: + - None +Returns: + - void +*/ void CustomerMenu::showMenu() { bool isMenuActive = true; @@ -64,11 +83,27 @@ void CustomerMenu::viewInvoices() { } +/* +Function: viewNotifications +Description: Displays notifications for the customer and allows deletion of notifications. +Parameters: + - None +Returns: + - void +*/ void CustomerMenu::viewNotifications() { 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; @@ -94,6 +129,14 @@ static bool getNotificationPreference(const std::string& serviceName) } } +/* +Function: configureNotifications +Description: Allows the customer to configure notification preferences for payment and service management. +Parameters: + - None +Returns: + - void +*/ void CustomerMenu::configureNotifications() { bool paymentServiceNotifications = getNotificationPreference("Payment Management Service"); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h index 886cf62..b65bb9d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h @@ -1,3 +1,12 @@ +/* +File: CustomerMenu.h +Description: Declares the CustomerMenu class which provides the customer-facing console menu in the Vehicle Service Management System. + Supports operations such as account management, service selection, combo package booking, viewing service history, + handling payments and invoices, and managing notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include "Controller.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index a84ba0f..5c40bea 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -1,3 +1,12 @@ +/* +File: MenuHelper.h +Description: Provides inline utility functions to support menu operations in the Vehicle Service Management System. + Includes helper functions for selecting, displaying, and managing notifications, as well as + integrating with the controller for user interactions. +Author: Trenser +Date: 21-May-2026 +*/ + #pragma once #include #include "Vector.h" @@ -6,6 +15,16 @@ #include "InputHelper.h" #include "OutputHelper.h" +/* +Function: selectNotification +Description: Displays a list of notifications with index, ID, title, and timestamp, + then allows the user to select one by index. +Parameters: + - notifications: Vector of Notification pointers to be displayed. +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& notifications) { if (notifications.getSize() == 0) @@ -47,6 +66,14 @@ inline const Notification* selectNotification(const util::VectorgetMessage() << std::endl; } +/* +Function: viewAndDeleteNotification +Description: Allows the user to view a notification and then delete it from the system using the controller. +Parameters: + - controller: Reference to the Controller object used to manage notifications. +Returns: + - void +*/ inline void viewAndDeleteNotification(Controller& controller) { util::clear(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index 24bf28f..ce1e5bc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -1,8 +1,26 @@ +/* +File: TechnicianMenu.cpp +Description: Implements the TechnicianMenu class which provides the technicians console interface + in the Vehicle Service Management System. Handles menu display, user input, and + technician-specific operations such as completing jobs and viewing notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #include "TechnicianMenu.h" #include "InputHelper.h" #include "OutputHelper.h" #include "MenuHelper.h" +/* +Function: showMenu +Description: Displays the technician menu in a loop until the user chooses to logout. + Handles exceptions and ensures smooth user interaction. +Parameters: + - None +Returns: + - void +*/ void TechnicianMenu::showMenu() { bool isMenuActive = true; @@ -36,6 +54,14 @@ void TechnicianMenu::completeJob() { } +/* +Function: viewNotifications +Description: Displays notifications for the technician and allows deletion of notifications. +Parameters: + - None +Returns: + - void +*/ void TechnicianMenu::viewNotifications() { viewAndDeleteNotification(m_controller); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h index c366d9b..3383362 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h @@ -1,3 +1,11 @@ +/* +File: TechnicianMenu.h +Description: Declares the TechnicianMenu class which provides the technician-facing console menu in the Vehicle Service Management System. + Supports operations such as viewing assigned jobs, completing jobs, and managing notifications. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include "Controller.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index cc47e47..c36ecc2 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -1,7 +1,24 @@ +/* +File: UserInterface.cpp +Description: Implements the UserInterface class which provides the main entry point for the Vehicle Service Management System. + Handles system checks, displays the main menu, and manages user operations such as login and customer registration. +Author: Trenser +Date: 19-May-2026 +*/ + #include "UserInterface.h" #include "InputHelper.h" #include "OutputHelper.h" +/* +Function: run +Description: Runs the Vehicle Service Management System interface. + Performs system checks, displays the main menu, and processes user input until exit. +Parameters: + - None +Returns: + - void +*/ void UserInterface::run() { m_controller.runSystemChecks(); @@ -27,6 +44,14 @@ void UserInterface::run() } } +/* +Function: handleOperation +Description: Processes the users menu choice and executes the corresponding action. +Parameters: + - choice: Integer representing the selected menu option. +Returns: + - bool: True if the menu should remain active, False if exit is selected. +*/ bool UserInterface::handleOperation(int choice) { switch (choice) @@ -47,11 +72,27 @@ bool UserInterface::handleOperation(int choice) return true; } +/* +Function: login +Description: Handles the login process for existing users. +Parameters: + - None +Returns: + - void +*/ void UserInterface::login() { } +/* +Function: registerCustomer +Description: Handles the registration process for new customers. +Parameters: + - None +Returns: + - void +*/ void UserInterface::registerCustomer() { diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h index da3862e..ee60b35 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h @@ -1,3 +1,12 @@ +/* +File: UserInterface.h +Description: Declares the UserInterface class which provides the main console interface for the Vehicle Service Management System. + Handles user interactions such as login, customer registration, and role-based menu navigation + for Admin, Technician, and Customer modules. +Author: Trenser +Date: 19-May-2026 +*/ + #pragma once #include "Controller.h" #include "AdminMenu.h" From 34cb64ab1bf0ea2d89ff4230ad3e2ab0b618973a Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Fri, 22 May 2026 13:26:02 +0530 Subject: [PATCH 16/20] Add standardized documentation headers --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 74 ++++++++ .../controllers/Controller.h | 8 + .../models/ServiceBooking.cpp | 162 +++++++++++++++++- .../models/ServiceBooking.h | 8 + .../AuthenticationManagementService.cpp | 37 ++++ .../AuthenticationManagementService.h | 8 + .../services/ServiceManagementService.cpp | 30 ++++ .../services/ServiceManagementService.h | 8 + .../services/UserManagementService.cpp | 38 ++++ .../services/UserManagementService.h | 8 + .../utilities/Config.h | 8 + .../utilities/Utility.h | 21 +++ .../views/CustomerMenu.cpp | 64 +++++++ .../views/CustomerMenu.h | 9 + .../views/MenuHelper.h | 16 ++ .../views/UserInterface.cpp | 36 ++++ .../views/UserInterface.h | 9 + 18 files changed, 544 insertions(+), 1 deletion(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index 0cb9d3f..063f776 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -182,6 +182,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index b92c3aa..893494e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,28 +1,71 @@ +/* +File: Controller.cpp +Description: Implementation file containing the method definitions of the + Controller class, including authentication, user creation, + service purchasing, and system checks. +Author: Trenser +Date:19-May-2026 +*/ #include #include "Controller.h" #include "Enums.h" #include "User.h" +/* +Function: login +Description: Authenticates a user by delegating to the authentication management service. +Parameter: const std::string& username - users username + const std::string& password - users password +Return type: bool - true if login successful, false otherwise +*/ bool Controller::login(const std::string& username, const std::string& password) { return m_authenticationManagementService.login(username, password); } +/* +Function: logout +Description: Logs out the currently authenticated user. +Parameter: None +Return type: void +*/ void Controller::logout() { m_authenticationManagementService.logout(); } +/* +Function: changePassword +Description: Changes the password of the currently authenticated user. +Parameter: const std::string& newPassword - new password to set +Return type: void +*/ void Controller::changePassword(const std::string& 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) { 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() { return m_authenticationManagementService.getAuthenticatedUser(); @@ -32,6 +75,13 @@ void Controller::createTechnician(const std::string& username, const std::string { } +/* +Function: updateUserDetails +Description: Updates the email and phone details of the currently authenticated user. +Parameter: const std::string& email - new email address + const std::string& phone - new phone number +Return type: void +*/ void Controller::updateUserDetails(const std::string& email, const std::string& phone) { User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -52,11 +102,29 @@ util::Map Controller::getComboPackages() return util::Map(); } +/* +Function: purchaseService +Description: Purchases one or more services for a vehicle by delegating to the service management service. +Parameter: const util::Vector& serviceIDs - IDs of services to purchase + 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::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& 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) { m_serviceManagementService.purchaseComboPackage(comboPackageID, vehicleNumber, vehicleBrand, vehicleModel); @@ -155,6 +223,12 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN { } +/* +Function: runSystemChecks +Description: Runs system checks to ensure critical configurations, such as verifying admin existence. +Parameter: None +Return type: void +*/ void Controller::runSystemChecks() { m_userManagementService.ensureAdminExists(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index dddbb94..027ca20 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -1,3 +1,11 @@ +/* +File: Controller.h +Description: Header file declaring the Controller class, which coordinates + authentication, user management, service management, inventory, + and notifications across the Vehicle Service System. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Map.h" #include diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 51fc6ff..c7a4d88 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -1,13 +1,42 @@ +/* +File: ServiceBooking.cpp +Description: Implementation file containing the method definitions of the + ServiceBooking class, including constructors, getters, and setters + for booking attributes. +Author: Trenser +Date:19-May-2026 +*/ #include "ServiceBooking.h" int ServiceBooking::m_uid = 0; +/* +Function: ServiceBooking +Description: Default constructor that initializes a new service booking + with a unique ID, no customer or technician, and zero discount. +Parameter: None +Return type: Constructor +*/ ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), m_assignedTechnician(nullptr), m_discountPercentage(0.0) {} +/* +Function: ServiceBooking +Description: Parameterized constructor that initializes a service booking + with customer, vehicle, services, and discount details. +Parameter: util::ServiceJobStatus status - current booking status + const util::Map& services - map of services + const std::string& customerId - ID of the customer + User* customer - pointer to the customer object + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle + double discountPercentage - discount applied to the booking +Return type: Constructor +*/ ServiceBooking::ServiceBooking( util::ServiceJobStatus status, const util::Map& +*/ const util::Map& ServiceBooking::getServices() const { return m_services; } +/* +Function: getCustomerId +Description: Retrieves the customer ID associated with the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getCustomerId() const { return m_customerId; } +/* +Function: getCustomer +Description: Retrieves the customer object associated with the booking. +Parameter: None +Return type: User* +*/ User* ServiceBooking::getCustomer() const { return m_customer; } +/* +Function: getVehicleNumber +Description: Retrieves the vehicle registration number for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleNumber() const { return m_vehicleNumber; } +/* +Function: getVehicleBrand +Description: Retrieves the brand of the vehicle for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleBrand() const { return m_vehicleBrand; } +/* +Function: getVehicleModel +Description: Retrieves the model of the vehicle for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleModel() const { return m_vehicleModel; } +/* +Function: getAssignedTechnicianId +Description: Retrieves the ID of the technician assigned to the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getAssignedTechnicianId() const { return m_assignedTechnicianId; } +/* +Function: getAssignedTechnician +Description: Retrieves the technician object assigned to the booking. +Parameter: None +Return type: User* +*/ User* ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } - +/* +Function: getDiscountPercentage +Description: Retrieves the discount percentage applied to the booking. +Parameter: None +Return type: double +*/ double ServiceBooking::getDiscountPercentage() const { return m_discountPercentage; } +/* +Function: setId +Description: Sets the unique identifier of the service booking. +Parameter: const std::string& id - new booking ID +Return type: void +*/ void ServiceBooking::setId(const std::string& id) { m_id = id; } +/* +Function: setStatus +Description: Sets the current status of the service booking. +Parameter: const util::ServiceJobStatus& status - new booking status +Return type: void +*/ void ServiceBooking::setStatus(const util::ServiceJobStatus& status) { m_status = status; } +/* +Function: setServices +Description: Sets the services associated with the booking. +Parameter: const util::Map& services - new services map +Return type: void +*/ void ServiceBooking::setServices(const util::Map& services) { m_services = services; } +/* +Function: setCustomerId +Description: Sets the customer ID for the booking. +Parameter: const std::string& customerId - new customer ID +Return type: void +*/ void ServiceBooking::setCustomerId(const std::string& customerId) { m_customerId = customerId; } +/* +Function: setCustomer +Description: Sets the customer object for the booking. +Parameter: User* customer - pointer to the customer object +Return type: void +*/ void ServiceBooking::setCustomer(User* customer) { m_customer = customer; } +/* +Function: setVehicleNumber +Description: Sets the vehicle registration number for the booking. +Parameter: const std::string& vehicleNumber - new vehicle number +Return type: void +*/ void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber) { m_vehicleNumber = vehicleNumber; } +/* +Function: setVehicleBrand +Description: Sets the brand of the vehicle for the booking. +Parameter: const std::string& vehicleBrand - new vehicle brand +Return type: void +*/ void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand) { m_vehicleBrand = vehicleBrand; } +/* +Function: setVehicleModel +Description: Sets the model of the vehicle for the booking. +Parameter: const std::string& vehicleModel - new vehicle model +Return type: void +*/ void ServiceBooking::setVehicleModel(const std::string& vehicleModel) { m_vehicleModel = vehicleModel; } +/* +Function: setAssignedTechnicianId +Description: Sets the ID of the technician assigned to the booking. +Parameter: const std::string& assignedTechnicianId - new technician ID +Return type: void +*/ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId) { m_assignedTechnicianId = assignedTechnicianId; } +/* +Function: setAssignedTechnician +Description: Sets the technician object assigned to the booking. +Parameter: User* assignedTechnician - pointer to the technician object +Return type: void +*/ void ServiceBooking::setAssignedTechnician(User* assignedTechnician) { m_assignedTechnician = assignedTechnician; } +/* +Function: setDiscountPercentage +Description: Sets the discount percentage for the booking. +Parameter: double discountPercentage - new discount percentage +Return type: void +*/ void ServiceBooking::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 84a8aac..48e3ba9 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -1,3 +1,11 @@ +/* +File: ServiceBooking.h +Description: Header file declaring the ServiceBooking class, which represents + a booking of services by a customer, including vehicle details, + assigned technician, and discount information. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index 36c2080..d6fd4b6 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,9 +1,26 @@ +/* +File: AuthenticationManagementService.cpp +Description: Implementation file containing the method definitions of the + AuthenticationManagementService class, including login, logout, + password change, and retrieval of the authenticated user. +Author: Trenser +Date:19-May-2026 +*/ #include #include "AuthenticationManagementService.h" #include "User.h" 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) { util::Map users = m_dataStore.getUsers(); @@ -24,16 +41,36 @@ bool AuthenticationManagementService::login(const std::string& username, const s return false; } +/* +Function: getAuthenticatedUser +Description: Retrieves the currently authenticated user. +Parameter: None +Return type: User* - pointer to the authenticated user +*/ User* AuthenticationManagementService::getAuthenticatedUser() { return m_authenticatedUser; } +/* +Function: logout +Description: Logs out the currently authenticated user by clearing the + static authenticated user pointer. +Parameter: None +Return type: void +*/ void AuthenticationManagementService::logout() { m_authenticatedUser = nullptr; } +/* +Function: changePassword +Description: Changes the password of the currently authenticated user. + Throws an exception if no user is logged in. +Parameter: const std::string& newPassword - new password to set +Return type: void +*/ void AuthenticationManagementService::changePassword(const std::string& newPassword) { if (m_authenticatedUser == nullptr) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h index ee0ed91..e89e0c3 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h @@ -1,3 +1,11 @@ +/* +File: AuthenticationManagementService.h +Description: Header file declaring the AuthenticationManagementService class, which manages + user authentication, login, logout, password changes, and retrieval of the + authenticated user. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "DataStore.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 3c787b3..c720c35 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1,3 +1,11 @@ +/* +File: ServiceManagementService.cpp +Description: Implementation file containing the method definitions of the + ServiceManagementService class, including service and combo package + purchasing logic, booking creation, and notification handling. +Author: Trenser +Date:19-May-2026 +*/ #include #include "ServiceManagementService.h" #include "AuthenticationManagementService.h" @@ -6,6 +14,17 @@ #include "ComboPackage.h" #include "Factory.h" +/* +Function: purchaseService +Description: Creates a new service booking for the authenticated user. Validates + service IDs, retrieves services from the DataStore, and generates a + booking. Sends a notification upon successful booking. +Parameter: const util::Vector& serviceIDs - IDs of services to purchase + 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::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { AuthenticationManagementService m_authenticationManagementService; @@ -39,6 +58,17 @@ void ServiceManagementService::purchaseService(const util::Vector& "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) { AuthenticationManagementService m_authenticationManagementService; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h index 85e05ed..e1dfb91 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h @@ -1,3 +1,11 @@ +/* +File: ServiceManagementService.h +Description: Header file declaring the ServiceManagementService class, which manages + services, combo packages, job cards, and service bookings. Inherits from + NotificationManagementService to handle notifications. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 395e12f..9036731 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1,3 +1,11 @@ +/* +File: UserManagementService.cpp +Description: Implementation file containing the method definitions of the + UserManagementService class, including user creation, updates, + and ensuring an admin account exists. +Author: Trenser +Date:19-May-2026 +*/ #include #include "User.h" #include "Enums.h" @@ -8,6 +16,14 @@ #include "InventoryManagementService.h" #include "Factory.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() { auto& usersMap = m_dataStore.getUsers(); @@ -34,6 +50,19 @@ 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) { InventoryManagementService inventoryManagementService; @@ -60,6 +89,15 @@ 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) { auto& usersMap = m_dataStore.getUsers(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index 34603a4..5b89053 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -1,3 +1,11 @@ +/* +File: UserManagementService.h +Description: Header file declaring the UserManagementService class, which manages + user creation, updates, retrieval, removal, notifications, and ensures + the existence of an admin account. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h index 38c7bed..ca5ea0e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -1,3 +1,11 @@ +/* +File: Config.h +Description: Header file declaring configuration constants for the Vehicle Service System. + Includes default admin account details such as username, name, password, + email, and phone number. +Author: Trenser +Date:19-May-2026 +*/ #pragma once namespace config diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h index dcbe33e..ca1fd37 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -1,7 +1,21 @@ +/* +File: Utility.h +Description: Header file declaring utility functions used across the system, + including cost calculation for services and combo packages. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Service.h" #include "InventoryItem.h" +/* +Function: calculatePartsCost +Description: Calculates the total cost of parts required for a given service + by summing the prices of all associated inventory items. +Parameter: const Service* service - pointer to the service object +Return type: double - total cost of required parts +*/ inline double calculatePartsCost(const Service* service) { double cost = 0; @@ -14,6 +28,13 @@ inline double calculatePartsCost(const Service* service) return cost; } +/* +Function: calculateComboServiceEstimatedCost +Description: Calculates the estimated total cost of a combo package by summing + the labor and parts costs of all services included in the package. +Parameter: const ComboPackage* comboPackage - pointer to the combo package object +Return type: double - estimated total cost of the combo package +*/ inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage) { double cost = 0; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 0a97c6a..b9a6d23 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,3 +1,11 @@ +/* +File: CustomerMenu.cpp +Description: Implementation file containing the method definitions of the + CustomerMenu class, including menu handling, service selection, + combo package booking, profile updates, and password management. +Author: Trenser +Date:19-May-2026 +*/ #include #include "CustomerMenu.h" #include "Service.h" @@ -11,6 +19,12 @@ #include "Utility.h" #include "Map.h" +/* +Function: showMenu +Description: Displays the customer menu and handles user input until logout is selected. +Parameter: None +Return type: void +*/ void CustomerMenu::showMenu() { while (true) @@ -45,6 +59,12 @@ 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) { switch (choice) @@ -86,11 +106,23 @@ bool CustomerMenu::handleOperation(int choice) return true; } +/* +Function: logout +Description: Logs out the currently authenticated customer user. +Parameter: None +Return type: void +*/ void CustomerMenu::logout() { m_controller.logout(); } +/* +Function: changePassword +Description: Allows the customer to change their password after validation. +Parameter: None +Return type: void +*/ void CustomerMenu::changePassword() { std::string newPassword; @@ -108,6 +140,12 @@ void CustomerMenu::changePassword() 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() { std::string email, phone; @@ -133,6 +171,12 @@ void CustomerMenu::updateDetails() util::pressEnter(); } +/* +Function: selectServiceFromServices +Description: Displays active services and allows the customer to select one by index. +Parameter: const util::Map& services - list of services +Return type: const Service* - selected service +*/ static const Service* selectServiceFromServices(const util::Map& services) { util::Map activeServicesMap; @@ -176,6 +220,13 @@ static const Service* selectServiceFromServices(const util::Map& comboPackages - list of combo packages +Return type: const ComboPackage* - selected combo package +*/ static const ComboPackage* selectComboPackageFromPackages(const util::Map& comboPackages) { util::Map activeComboPackages; @@ -244,6 +301,13 @@ static const ComboPackage* selectComboPackageFromPackages(const util::Map #include @@ -6,6 +14,14 @@ #include "InputHelper.h" #include "OutputHelper.h" +/* +Function: selectNotification +Description: Displays a list of notifications with index, ID, title, and timestamp. + Allows the user to select a notification by index. Returns the selected + notification or nullptr if the selection is invalid. +Parameter: const util::Vector& notifications - list of notifications +Return type: const Notification* - pointer to the selected notification +*/ inline const Notification* selectNotification(const util::Vector& notifications) { if (notifications.getSize() == 0) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 6e4e26f..e774b1d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -1,3 +1,11 @@ +/* +File: UserInterface.cpp +Description: Implementation file containing the method definitions of the + UserInterface class, including system run loop, login handling, + and customer registration logic. +Author: Trenser +Date:19-May-2026 +*/ #include "UserInterface.h" #include "InputHelper.h" #include "OutputHelper.h" @@ -5,6 +13,13 @@ #include "User.h" #include "Validator.h" +/* +Function: run +Description: Runs the main system loop, displaying the initial menu for login, + customer registration, or exit. Handles exceptions gracefully. +Parameter: None +Return type: void +*/ void UserInterface::run() { bool isMenuActive = true; @@ -29,6 +44,12 @@ void UserInterface::run() } } +/* +Function: handleOperation +Description: Executes the corresponding system operation based on the selected menu choice. +Parameter: int choice - selected menu option +Return type: bool - true if menu continues, false if exit +*/ bool UserInterface::handleOperation(int choice) { switch (choice) @@ -49,6 +70,13 @@ bool UserInterface::handleOperation(int choice) return true; } +/* +Function: login +Description: Handles user login by validating credentials. Based on the authenticated + user type, navigates to the appropriate menu (Admin, Technician, Customer). +Parameter: None +Return type: void +*/ void UserInterface::login() { std::string username, password; @@ -85,6 +113,14 @@ void UserInterface::login() } } +/* +Function: registerCustomer +Description: Registers a new customer by collecting and validating details such as + username, name, email, password, and phone number. Delegates creation + to the controller. +Parameter: None +Return type: void +*/ void UserInterface::registerCustomer() { std::string username, name, email, phone, password; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h index da3862e..52c2beb 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h @@ -1,3 +1,12 @@ +/* +File: UserInterface.h +Description: Header file declaring the UserInterface class, which provides + the main entry point for the Vehicle Service System. Handles + login, customer registration, and menu navigation for different + user roles (Admin, Technician, Customer). +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Controller.h" #include "AdminMenu.h" From 53713f444ba1b5dd240110e8950132de19abc8cf Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Fri, 22 May 2026 12:13:17 +0530 Subject: [PATCH 17/20] 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 --- .../Trenser.VehicleServiceSystem.vcxproj | 5 + ...enser.VehicleServiceSystem.vcxproj.filters | 15 ++ .../controllers/Controller.cpp | 28 +++ .../controllers/Controller.h | 11 + .../core/patterns/Subject.h | 1 + .../files/README.md | 1 + .../models/ComboPackage.cpp | 114 +++++++++- .../models/ComboPackage.h | 7 + .../models/InventoryItem.cpp | 67 +++++- .../models/InventoryItem.h | 4 + .../models/Invoice.cpp | 167 +++++++++++++- .../models/Invoice.h | 28 ++- .../models/JobCard.cpp | 92 +++++++- .../models/JobCard.h | 22 +- .../models/Notification.cpp | 61 +++++ .../models/Notification.h | 4 + .../models/Service.cpp | 113 +++++++++- .../models/Service.h | 7 + .../models/ServiceBooking.cpp | 149 ++++++++++++- .../models/ServiceBooking.h | 26 ++- .../models/User.cpp | 70 +++++- .../models/User.h | 4 + .../services/InventoryManagementService.cpp | 48 ++++ .../services/InventoryManagementService.h | 6 + .../services/NotificationManagementService.h | 1 + .../services/PaymentManagementService.cpp | 70 ++++++ .../services/PaymentManagementService.h | 5 + .../services/ServiceManagementService.cpp | 210 ++++++++++++++++++ .../services/ServiceManagementService.h | 11 + .../services/UserManagementService.cpp | 51 +++++ .../services/UserManagementService.h | 2 + .../utilities/Config.h | 19 ++ .../utilities/FileHelper.h | 47 ++++ .../utilities/FileManager.h | 82 +++++++ .../utilities/InputHelper.h | 11 +- .../utilities/StringHelper.h | 18 ++ .../utilities/Utility.h | 29 +++ .../views/UserInterface.cpp | 2 + 38 files changed, 1573 insertions(+), 35 deletions(-) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/files/README.md create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..f9b2eaf 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -171,11 +171,16 @@ + + + + + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters index 77d0509..28cbc00 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj.filters @@ -233,5 +233,20 @@ Header Files\Models + + Header Files\Utilities + + + Header Files\Utilities + + + Header Files\Utilities + + + Header Files\Utilities + + + Header Files\Utilities + \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..a6f230d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -141,6 +141,34 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN { } +void Controller::loadSystemData() +{ + m_userManagementService.loadUsers(); + m_inventoryManagementService.loadInventoryItems(); + m_serviceManagementService.loadServices(); + m_serviceManagementService.loadComboPackages(); + m_serviceManagementService.loadServiceBookings(); + m_serviceManagementService.loadJobCards(); + m_paymentManagementService.loadInvoices(); + m_serviceManagementService.loadObservers(); + m_paymentManagementService.loadObservers(); + m_inventoryManagementService.loadObservers(); +} + +void Controller::saveSystemData() +{ + m_userManagementService.saveUsers(); + m_inventoryManagementService.saveInventoryItems(); + m_serviceManagementService.saveServices(); + m_serviceManagementService.saveComboPackages(); + m_serviceManagementService.saveServiceBookings(); + m_serviceManagementService.saveJobCards(); + m_paymentManagementService.saveInvoices(); + m_serviceManagementService.saveObservers(); + m_paymentManagementService.saveObservers(); + m_inventoryManagementService.saveObservers(); +} + void Controller::runSystemChecks() { } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..863aba3 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,10 @@ #include "Map.h" #include #include "Enums.h" +#include "InventoryManagementService.h" +#include "UserManagementService.h" +#include "ServiceManagementService.h" +#include "PaymentManagementService.h" class Service; class ComboPackage; @@ -14,6 +18,11 @@ class Notification; class Controller { +private: + UserManagementService m_userManagementService; + InventoryManagementService m_inventoryManagementService; + ServiceManagementService m_serviceManagementService; + PaymentManagementService m_paymentManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); @@ -47,5 +56,7 @@ public: util::Vector getNotifications(); void deleteNotification(const std::string& notificationID); void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications); + void loadSystemData(); + void saveSystemData(); void runSystemChecks(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h index 309a59d..3981440 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/core/patterns/Subject.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" class User; class Notification; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/files/README.md b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/files/README.md new file mode 100644 index 0000000..6e6b93e --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/files/README.md @@ -0,0 +1 @@ +Place files here. \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp index 6216922..c76d727 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp @@ -1,4 +1,9 @@ +#include +#include #include "ComboPackage.h" +#include "Service.h" +#include "Factory.h" +#include "StringHelper.h" int ComboPackage::m_uid = 0; @@ -12,7 +17,29 @@ ComboPackage::ComboPackage(const std::string& packageName, double discountPercen m_packageName(packageName), m_discountPercentage(discountPercentage), m_status(util::State::ACTIVE), - m_services(services) {} + m_services(services) +{ + int numberOfServices = m_services.getSize(); + auto servicePointers = m_services.getValues(); + for (int index = 0; index < numberOfServices; index++) + { + m_serviceIDs.push_back(servicePointers[index]->getId()); + } +} + +ComboPackage::ComboPackage(const std::string& id, const std::string& packageName, double discountPercentage, const util::Vector& serviceIDs, util::State status) + : m_id(id), + m_packageName(packageName), + m_discountPercentage(discountPercentage), + m_serviceIDs(serviceIDs), + m_status(status) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} const std::string& ComboPackage::getId() const { @@ -34,6 +61,11 @@ util::State ComboPackage::getState() const return m_status; } +const util::Vector& ComboPackage::getServiceIDs() const +{ + return m_serviceIDs; +} + const util::Map& ComboPackage::getServices() const { return m_services; @@ -57,9 +89,89 @@ void ComboPackage::setDiscountPercentage(double discountPercentage) void ComboPackage::setServices(const util::Map& services) { m_services = services; + m_serviceIDs.clear(); + int numberOfServices = m_services.getSize(); + auto servicePointers = m_services.getValues(); + for (int index = 0; index < numberOfServices; index++) + { + m_serviceIDs.push_back(servicePointers[index]->getId()); + } } void ComboPackage::setState(util::State status) { m_status = status; } + +static std::string getServiceIDsAsString(const util::Vector& serviceIDs) +{ + int numberOfServices = serviceIDs.getSize(); + std::string serviceIDsString; + for (int index = 0; index < numberOfServices; index++) + { + serviceIDsString += serviceIDs[index]; + if (index < numberOfServices - 1) + { + serviceIDsString += '|'; + } + } + return serviceIDsString; +} + +static util::Vector getServiceIDsAsVector(const std::string& serviceIDsString) +{ + util::Vector serviceIDs; + std::string serviceID; + std::istringstream serializedServiceIDs(serviceIDsString); + while (getline(serializedServiceIDs, serviceID, '|')) + { + serviceIDs.push_back(serviceID); + } + return serviceIDs; +} + +std::string ComboPackage::serialize() const +{ + std::ostringstream serializedComboPackage; + serializedComboPackage << m_id << ',' + << m_packageName << ',' + << m_discountPercentage << ',' + << getServiceIDsAsString(m_serviceIDs) << ',' + << util::getStateString(m_status); + return serializedComboPackage.str(); +} + +ComboPackage* ComboPackage::deserialize(const std::string& record) +{ + std::string id, packageName; + std::string discountPercentageString, serviceIDsString, statusString; + double discountPercentage; + std::istringstream serializedComboPackage(record); + getline(serializedComboPackage, id, ','); + getline(serializedComboPackage, packageName, ','); + getline(serializedComboPackage, discountPercentageString, ','); + getline(serializedComboPackage, serviceIDsString, ','); + getline(serializedComboPackage, statusString, ','); + try + { + discountPercentage = std::stod(discountPercentageString); + } + catch (...) + { + throw std::runtime_error("Invalid combo package data"); + } + util::Vector serviceIDs = getServiceIDsAsVector(serviceIDsString); + util::State status = util::getState(statusString); + return Factory::getObject( + id, + packageName, + discountPercentage, + serviceIDs, + status + ); +} + +std::string ComboPackage::getHeaders() +{ + return "ID,PackageName,DiscountPercentage,ServiceIDs,Status"; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h index 4b28d54..36e32dd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" #include "Enums.h" class Service; @@ -12,14 +13,17 @@ private: std::string m_id; std::string m_packageName; double m_discountPercentage; + util::Vector m_serviceIDs; util::Map m_services; util::State m_status; public: ComboPackage(); ComboPackage(const std::string& packageName, double discountPercentage, const util::Map& services); + ComboPackage(const std::string& id, const std::string& packageName, double discountPercentage, const util::Vector& serviceIDs, util::State status); const std::string& getId() const; const std::string& getPackageName() const; double getDiscountPercentage() const; + const util::Vector& getServiceIDs() const; const util::Map& getServices() const; util::State getState() const; void setId(const std::string& id); @@ -27,4 +31,7 @@ public: void setDiscountPercentage(double discountPercentage); void setServices(const util::Map& services); void setState(util::State status); + std::string serialize() const; + static ComboPackage* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp index c3dbbaa..da0fd3c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp @@ -1,3 +1,7 @@ +#include +#include +#include "Factory.h" +#include "StringHelper.h" #include "InventoryItem.h" int InventoryItem::m_uid = 0; @@ -15,6 +19,20 @@ InventoryItem::InventoryItem(const std::string& partName, int quantity, double p m_status(util::State::ACTIVE), m_price(price) {} +InventoryItem::InventoryItem(const std::string& id, const std::string& partName, int quantity, double price, util::State status) + : m_id(id), + m_partName(partName), + m_quantity(quantity), + m_status(status), + m_price(price) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} + const std::string& InventoryItem::getId() const { return m_id; @@ -63,4 +81,51 @@ void InventoryItem::setPrice(double price) void InventoryItem::setState(util::State status) { m_status = status; -} \ No newline at end of file +} + +std::string InventoryItem::serialize() const +{ + std::ostringstream serializedInventoryItem; + serializedInventoryItem << m_id << ',' + << m_partName << ',' + << m_quantity << ',' + << m_price << ',' + << util::getStateString(m_status); + return serializedInventoryItem.str(); +} + +InventoryItem* InventoryItem::deserialize(const std::string& record) +{ + std::string id, partName; + std::string quantityString, priceString, statusString; + int quantity; + double price; + std::istringstream serializedInventoryItem(record); + getline(serializedInventoryItem, id, ','); + getline(serializedInventoryItem, partName, ','); + getline(serializedInventoryItem, quantityString, ','); + getline(serializedInventoryItem, priceString, ','); + getline(serializedInventoryItem, statusString, ','); + try + { + quantity = std::stoi(quantityString); + price = std::stod(priceString); + } + catch (...) + { + throw std::runtime_error("Invalid inventory item data"); + } + util::State status = util::getState(statusString); + return Factory::getObject( + id, + partName, + quantity, + price, + status + ); +} + +std::string InventoryItem::getHeaders() +{ + return "ID,PartName,Quantity,Price,Status"; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h index d9618bc..6a9b237 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.h @@ -14,6 +14,7 @@ private: public: InventoryItem(); InventoryItem(const std::string& partName, int quantity, double price); + InventoryItem(const std::string& id, const std::string& partName, int quantity, double price, util::State status); const std::string& getId() const; const std::string& getPartName() const; int getQuantity() const; @@ -24,4 +25,7 @@ public: void setQuantity(int quantity); void setPrice(double price); void setState(util::State status); + std::string serialize() const; + static InventoryItem* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp index ba7bc84..622988e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp @@ -1,4 +1,9 @@ +#include +#include #include "Invoice.h" +#include "Factory.h" +#include "InventoryItem.h" +#include "StringHelper.h" int Invoice::m_uid = 0; @@ -16,7 +21,7 @@ Invoice::Invoice( const std::string& bookingId, ServiceBooking* booking, const util::Timestamp& invoiceDate, - double laborCost, const util::Map& parts, double partsCost, double discountPercentage, @@ -36,7 +41,48 @@ Invoice::Invoice( m_totalAmount(totalAmount), m_paymentDate(paymentDate), m_paymentMethod(paymentMethod), - m_status(status) {} + m_status(status) +{ + int numberOfParts = m_parts.getSize(); + auto partPointers = m_parts.getValues(); + for (int index = 0; index < numberOfParts; index++) + { + m_partIDs.push_back(partPointers[index]->getId()); + } +} + +Invoice::Invoice( + const std::string& id, + const std::string& bookingId, + const util::Timestamp& invoiceDate, + const util::Vector& partIDs, + double laborCost, + double partsCost, + double discountPercentage, + double totalAmount, + const util::Timestamp& paymentDate, + util::PaymentMode paymentMethod, + util::PaymentStatus status +) + : m_id(id), + m_bookingId(bookingId), + m_booking(nullptr), + m_invoiceDate(invoiceDate), + m_partIDs(partIDs), + m_laborCost(laborCost), + m_partsCost(partsCost), + m_discountPercentage(discountPercentage), + m_totalAmount(totalAmount), + m_paymentDate(paymentDate), + m_paymentMethod(paymentMethod), + m_status(status) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} const std::string& Invoice::getId() const { @@ -63,7 +109,12 @@ double Invoice::getLaborCost() const return m_laborCost; } -const util::Map& Invoice::getParts() const +const util::Vector& Invoice::getPartIDs() const +{ + return m_partIDs; +} + +const util::Map& Invoice::getParts() const { return m_parts; } @@ -123,9 +174,16 @@ void Invoice::setLaborCost(double laborCost) m_laborCost = laborCost; } -void Invoice::setParts(const util::Map& parts) +void Invoice::setParts(const util::Map& parts) { m_parts = parts; + m_partIDs.clear(); + int numberOfParts = m_parts.getSize(); + auto partPointers = m_parts.getValues(); + for (int index = 0; index < numberOfParts; index++) + { + m_partIDs.push_back(partPointers[index]->getId()); + } } void Invoice::setPartsCost(double partsCost) @@ -157,3 +215,104 @@ void Invoice::setStatus(util::PaymentStatus status) { m_status = status; } + +static std::string getPartIDsAsString(const util::Vector& partIDs) +{ + int numberOfParts = partIDs.getSize(); + std::string partIDsString; + for (int index = 0; index < numberOfParts; index++) + { + partIDsString += partIDs[index]; + if (index < numberOfParts - 1) + { + partIDsString += '|'; + } + } + return partIDsString; +} + +static util::Vector getPartIDsAsVector(const std::string& partIDsString) +{ + util::Vector partIDs; + std::string partID; + std::istringstream serializedPartIDs(partIDsString); + while (getline(serializedPartIDs, partID, '|')) + { + partIDs.push_back(partID); + } + return partIDs; +} + +std::string Invoice::serialize() const +{ + std::ostringstream serializedInvoice; + serializedInvoice << m_id << ',' + << m_bookingId << ',' + << m_invoiceDate.toString() << ',' + << m_laborCost << ',' + << getPartIDsAsString(m_partIDs) << ',' + << m_partsCost << ',' + << m_discountPercentage << ',' + << m_totalAmount << ',' + << m_paymentDate.toString() << ',' + << util::getPaymentModeString(m_paymentMethod) << ',' + << util::getPaymentStatusString(m_status); + return serializedInvoice.str(); +} + +Invoice* Invoice::deserialize(const std::string& record) +{ + std::string id, bookingId; + std::string invoiceDateString, laborCostString, partIDsString; + std::string partsCostString, discountPercentageString, totalAmountString; + std::string paymentDateString, paymentMethodString, statusString; + double laborCost, partsCost, discountPercentage, totalAmount; + std::istringstream serializedInvoice(record); + getline(serializedInvoice, id, ','); + getline(serializedInvoice, bookingId, ','); + getline(serializedInvoice, invoiceDateString, ','); + getline(serializedInvoice, laborCostString, ','); + getline(serializedInvoice, partIDsString, ','); + getline(serializedInvoice, partsCostString, ','); + getline(serializedInvoice, discountPercentageString, ','); + getline(serializedInvoice, totalAmountString, ','); + getline(serializedInvoice, paymentDateString, ','); + getline(serializedInvoice, paymentMethodString, ','); + getline(serializedInvoice, statusString, ','); + util::Timestamp invoiceDate; + util::Timestamp paymentDate; + try + { + invoiceDate = util::Timestamp::fromString(invoiceDateString); + paymentDate = util::Timestamp::fromString(paymentDateString); + laborCost = std::stod(laborCostString); + partsCost = std::stod(partsCostString); + discountPercentage = std::stod(discountPercentageString); + totalAmount = std::stod(totalAmountString); + } + catch (...) + { + throw std::runtime_error("Invalid invoice data"); + } + util::Vector partIDs = getPartIDsAsVector(partIDsString); + util::PaymentMode paymentMethod = util::getPaymentMode(paymentMethodString); + util::PaymentStatus status = util::getPaymentStatus(statusString); + return Factory::getObject( + id, + bookingId, + invoiceDate, + partIDs, + laborCost, + partsCost, + discountPercentage, + totalAmount, + paymentDate, + paymentMethod, + status + ); +} + +std::string Invoice::getHeaders() +{ + return "ID,BookingID,InvoiceDate,LaborCost,PartIDs,PartsCost,DiscountPercentage,TotalAmount,PaymentDate,PaymentMethod,Status"; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h index 212d33f..bbbbb0e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" #include "Timestamp.h" #include "Enums.h" @@ -16,21 +17,21 @@ private: ServiceBooking* m_booking; util::Timestamp m_invoiceDate; double m_laborCost; - util::Map m_parts; + util::Vector m_partIDs; + util::Map m_parts; double m_partsCost; double m_discountPercentage; double m_totalAmount; util::Timestamp m_paymentDate; util::PaymentMode m_paymentMethod; util::PaymentStatus m_status; - public: Invoice(); Invoice( const std::string& bookingId, ServiceBooking* booking, const util::Timestamp& invoiceDate, - double laborCost, const util::Map& parts, double partsCost, double discountPercentage, @@ -39,12 +40,26 @@ public: util::PaymentMode paymentMethod, util::PaymentStatus status ); + Invoice( + const std::string& id, + const std::string& bookingId, + const util::Timestamp& invoiceDate, + const util::Vector& partIDs, + double laborCost, + double partsCost, + double discountPercentage, + double totalAmount, + const util::Timestamp& paymentDate, + util::PaymentMode paymentMethod, + util::PaymentStatus status + ); const std::string& getId() const; const std::string& getBookingId() const; ServiceBooking* getBooking() const; const util::Timestamp& getInvoiceDate() const; double getLaborCost() const; - const util::Map& getParts() const; + const util::Vector& getPartIDs() const; + const util::Map& getParts() const; double getPartsCost() const; double getDiscountPercentage() const; double getTotalAmount() const; @@ -56,11 +71,14 @@ public: void setBooking(ServiceBooking* booking); void setInvoiceDate(const util::Timestamp& invoiceDate); void setLaborCost(double laborCost); - void setParts(const util::Map& parts); + void setParts(const util::Map& parts); void setPartsCost(double partsCost); void setDiscountPercentage(double discountPercentage); void setTotalAmount(double totalAmount); void setPaymentDate(const util::Timestamp& paymentDate); void setPaymentMethod(util::PaymentMode paymentMethod); void setStatus(util::PaymentStatus status); + std::string serialize() const; + static Invoice* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp index 04e9195..6683dc1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp @@ -1,4 +1,9 @@ +#include +#include #include "JobCard.h" +#include "Factory.h" +#include "StringHelper.h" +#include "Enums.h" int JobCard::m_uid = 0; @@ -7,7 +12,7 @@ JobCard::JobCard() m_booking(nullptr), m_service(nullptr), m_technician(nullptr), - m_status(ServiceJobStatus()) {} + m_status(util::ServiceJobStatus()) {} JobCard::JobCard(const std::string& bookingId, ServiceBooking* booking, @@ -16,7 +21,7 @@ JobCard::JobCard(const std::string& bookingId, const std::string& technicianId, User* technician, const util::Timestamp& assignedDate, - ServiceJobStatus status, + util::ServiceJobStatus status, const util::Timestamp& completionDate ) : m_id("JC" + std::to_string(++m_uid)), @@ -30,6 +35,32 @@ JobCard::JobCard(const std::string& bookingId, m_status(status), m_completionDate(completionDate) {} +JobCard::JobCard(const std::string& id, + const std::string& bookingId, + const std::string& serviceId, + const std::string& technicianId, + const util::Timestamp& assignedDate, + util::ServiceJobStatus status, + const util::Timestamp& completionDate +) + : m_id(id), + m_bookingId(bookingId), + m_booking(nullptr), + m_service(nullptr), + m_serviceId(serviceId), + m_technicianId(technicianId), + m_technician(nullptr), + m_assignedDate(assignedDate), + m_status(status), + m_completionDate(completionDate) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} + const std::string& JobCard::getId() const { return m_id; @@ -70,7 +101,7 @@ const util::Timestamp& JobCard::getAssignedDate() const return m_assignedDate; } -ServiceJobStatus JobCard::getStatus() const +util::ServiceJobStatus JobCard::getStatus() const { return m_status; } @@ -120,7 +151,7 @@ void JobCard::setAssignedDate(const util::Timestamp& assignedDate) m_assignedDate = assignedDate; } -void JobCard::setStatus(ServiceJobStatus status) +void JobCard::setStatus(util::ServiceJobStatus status) { m_status = status; } @@ -128,4 +159,57 @@ void JobCard::setStatus(ServiceJobStatus status) void JobCard::setCompletionDate(const util::Timestamp& completionDate) { m_completionDate = completionDate; +} + +std::string JobCard::serialize() const +{ + std::ostringstream serializedJobCard; + serializedJobCard << m_id << ',' + << m_bookingId << ',' + << m_serviceId << ',' + << m_technicianId << ',' + << m_assignedDate.toString() << ',' + << util::getServiceJobStatusString(m_status) << ',' + << m_completionDate.toString(); + return serializedJobCard.str(); +} + +JobCard* JobCard::deserialize(const std::string& record) +{ + std::string id, bookingId, serviceId, technicianId; + std::string assignedDateString, statusString, completionDateString; + std::istringstream serializedJobCard(record); + getline(serializedJobCard, id, ','); + getline(serializedJobCard, bookingId, ','); + getline(serializedJobCard, serviceId, ','); + getline(serializedJobCard, technicianId, ','); + getline(serializedJobCard, assignedDateString, ','); + getline(serializedJobCard, statusString, ','); + getline(serializedJobCard, completionDateString, ','); + util::Timestamp assignedDate; + util::Timestamp completionDate; + try + { + assignedDate = util::Timestamp::fromString(assignedDateString); + completionDate = util::Timestamp::fromString(completionDateString); + } + catch (...) + { + throw std::runtime_error("Invalid timestamp"); + } + util::ServiceJobStatus status = util::getServiceJobStatus(statusString); + return Factory::getObject( + id, + bookingId, + serviceId, + technicianId, + assignedDate, + status, + completionDate + ); +} + +std::string JobCard::getHeaders() +{ + return "ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate"; } \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h index 15a8a5d..21cdf44 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.h @@ -1,13 +1,12 @@ #pragma once #include #include "Timestamp.h" +#include "Enums.h" class ServiceBooking; class Service; class User; -enum class ServiceJobStatus : int; - class JobCard { private: @@ -20,7 +19,7 @@ private: std::string m_technicianId; User* m_technician; util::Timestamp m_assignedDate; - ServiceJobStatus m_status; + util::ServiceJobStatus m_status; util::Timestamp m_completionDate; public: @@ -32,7 +31,15 @@ public: const std::string& technicianId, User* technician, const util::Timestamp& assignedDate, - ServiceJobStatus status, + util::ServiceJobStatus status, + const util::Timestamp& completionDate + ); + JobCard(const std::string& id, + const std::string& bookingId, + const std::string& serviceId, + const std::string& technicianId, + const util::Timestamp& assignedDate, + util::ServiceJobStatus status, const util::Timestamp& completionDate ); const std::string& getId() const; @@ -43,7 +50,7 @@ public: const std::string& getTechnicianId() const; User* getTechnician() const; const util::Timestamp& getAssignedDate() const; - ServiceJobStatus getStatus() const; + util::ServiceJobStatus getStatus() const; const util::Timestamp& getCompletionDate() const; void setId(const std::string& id); void setBookingId(const std::string& bookingId); @@ -53,6 +60,9 @@ public: void setTechnicianId(const std::string& technicianId); void setTechnician(User* technician); void setAssignedDate(const util::Timestamp& assignedDate); - void setStatus(ServiceJobStatus status); + void setStatus(util::ServiceJobStatus status); void setCompletionDate(const util::Timestamp& completionDate); + std::string serialize() const; + static JobCard* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp index dc3ed1d..86eaaec 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp @@ -1,4 +1,7 @@ +#include #include "Notification.h" +#include "StringHelper.h" +#include "Factory.h" int Notification::m_uid = 0; @@ -14,6 +17,21 @@ Notification::Notification(const std::string& recipientUserId, User* recipient, m_message(message), m_createdAt(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_recipientUserId(recipientUserId), + m_recipient(nullptr), + m_title(title), + m_message(message), + m_createdAt(createdAt) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} + const std::string& Notification::getId() const { return m_id; @@ -72,4 +90,47 @@ void Notification::setMessage(const std::string& message) void Notification::setCreatedAt(const util::Timestamp& createdAt) { m_createdAt = createdAt; +} + +std::string Notification::serialize() const +{ + std::ostringstream serializedNotification; + serializedNotification << m_id << ',' + << m_recipientUserId << ',' + << m_title << ',' + << m_message << ',' + << m_createdAt.toString(); + return serializedNotification.str(); +} + +Notification* Notification::deserialize(const std::string& record) +{ + std::string id, recipientUserId, title, message, createdAtTimestampString; + std::istringstream serializedNotification(record); + getline(serializedNotification, id, ','); + getline(serializedNotification, recipientUserId, ','); + getline(serializedNotification, title, ','); + getline(serializedNotification, message, ','); + getline(serializedNotification, createdAtTimestampString, ','); + util::Timestamp createdAtTimestamp; + try + { + createdAtTimestamp = util::Timestamp::fromString(createdAtTimestampString); + } + catch (...) + { + throw std::runtime_error("Invalid createdAt timestamp"); + } + return Factory::getObject( + id, + recipientUserId, + title, + message, + createdAtTimestamp + ); +} + +std::string Notification::getHeaders() +{ + return "ID,RecipientID,Title,Message,Timestamp"; } \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h index f86499e..fc03386 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.h @@ -17,6 +17,7 @@ private: public: Notification(); Notification(const std::string& recipientUserId, User* recipient, const std::string& title, const std::string& message, const util::Timestamp& createdAt); + Notification(const std::string& id, const std::string& recipientUserId, const std::string& title, const std::string& message, const util::Timestamp& createdAt); const std::string& getId() const; const std::string& getRecipientUserId() const; User* getRecipient() const; @@ -29,4 +30,7 @@ public: void setTitle(const std::string& title); void setMessage(const std::string& message); void setCreatedAt(const util::Timestamp& createdAt); + std::string serialize() const; + static Notification* deserialize(const std::string&); + static std::string getHeaders(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp index fa7f509..e83b639 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp @@ -1,4 +1,8 @@ +#include #include "Service.h" +#include "InventoryItem.h" +#include "StringHelper.h" +#include "Factory.h" int Service::m_uid = 0; @@ -12,7 +16,29 @@ Service::Service(const std::string& name, const util::MapgetId()); + } +} + +Service::Service(const std::string& id, const std::string& name, const util::Vector& requiredInventoryItemIDs, double laborCost, util::State status) + : m_id(id), + m_name(name), + m_requiredInventoryItemIDs(requiredInventoryItemIDs), + m_status(status), + m_laborCost(laborCost) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} const std::string& Service::getId() const { @@ -24,6 +50,11 @@ const std::string& Service::getName() const return m_name; } +const util::Vector& Service::getRequiredInventoryItemIDs() const +{ + return m_requiredInventoryItemIDs; +} + const util::Map& Service::getRequiredInventoryItems() const { return m_requiredInventoryItems; @@ -52,6 +83,13 @@ void Service::setName(const std::string& name) void Service::setRequiredInventoryItems(const util::Map& requiredInventoryItems) { m_requiredInventoryItems = requiredInventoryItems; + m_requiredInventoryItemIDs.clear(); + int numberOfRequiredInventoryItems = m_requiredInventoryItems.getSize(); + auto inventoryItemPointers = m_requiredInventoryItems.getValues(); + for (int index = 0; index < numberOfRequiredInventoryItems; index++) + { + m_requiredInventoryItemIDs.push_back(inventoryItemPointers[index]->getId()); + } } void Service::setLaborCost(double laborCost) @@ -62,4 +100,77 @@ void Service::setLaborCost(double laborCost) void Service::setState(util::State status) { m_status = status; +} + +static std::string getInventoryItemIDsAsString(const util::Vector& inventoryItemIds) +{ + int numberOfInventoryItems = inventoryItemIds.getSize(); + std::string inventoryItemIDs; + for (int index = 0; index < numberOfInventoryItems; index++) + { + inventoryItemIDs += inventoryItemIds[index]; + if (index < numberOfInventoryItems - 1) + { + inventoryItemIDs += '|'; + } + } + return inventoryItemIDs; +} + +static util::Vector getInventoryItemIDsAsVector(const std::string& inventoryItemIDsString) +{ + util::Vector inventoryItemIDs; + std::string inventoryItemID; + std::istringstream serializedInventoryItemIDs(inventoryItemIDsString); + while (getline(serializedInventoryItemIDs, inventoryItemID, '|')) + { + inventoryItemIDs.push_back(inventoryItemID); + } + return inventoryItemIDs; +} + +std::string Service::serialize() const +{ + std::ostringstream serializedService; + serializedService << m_id << ',' + << m_name << ',' + << getInventoryItemIDsAsString(m_requiredInventoryItemIDs) << ',' + << m_laborCost << ',' + << util::getStateString(m_status); + return serializedService.str(); +} + +Service* Service::deserialize(const std::string& record) +{ + std::string id, name; + std::string inventoryItemIDsString, laborCostString, statusString; + double laborCost; + std::istringstream serializedService(record); + getline(serializedService, id, ','); + getline(serializedService, name, ','); + getline(serializedService, inventoryItemIDsString, ','); + getline(serializedService, laborCostString, ','); + getline(serializedService, statusString, ','); + util::Vector inventoryItemIDs = getInventoryItemIDsAsVector(inventoryItemIDsString); + try + { + laborCost = std::stod(laborCostString); + } + catch (...) + { + throw std::runtime_error("Invalid labor cost"); + } + util::State status = util::getState(statusString); + return Factory::getObject( + id, + name, + inventoryItemIDs, + laborCost, + status + ); +} + +std::string Service::getHeaders() +{ + return "ID,Name,InventoryIDs,LaborCost,Status"; } \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h index b0d3175..ec00164 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" #include "Enums.h" class InventoryItem; @@ -11,14 +12,17 @@ private: static int m_uid; std::string m_id; std::string m_name; + util::Vector m_requiredInventoryItemIDs; util::Map m_requiredInventoryItems; double m_laborCost; util::State m_status; public: Service(); Service(const std::string& name, const util::Map& requiredInventoryItems, double laborCost); + Service(const std::string& id, const std::string& name, const util::Vector& requiredInventoryItemIDs, double laborCost, util::State state); const std::string& getId() const; const std::string& getName() const; + const util::Vector& getRequiredInventoryItemIDs() const; const util::Map& getRequiredInventoryItems() const; double getLaborCost() const; util::State getState() const; @@ -27,4 +31,7 @@ public: void setRequiredInventoryItems(const util::Map& requiredInventoryItems); void setLaborCost(double laborCost); void setState(util::State status); + std::string serialize() const; + static Service* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 1fdfaf0..efd6c6a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -1,14 +1,20 @@ +#include +#include #include "ServiceBooking.h" +#include "Service.h" +#include "Enums.h" +#include "Factory.h" +#include "StringHelper.h" int ServiceBooking::m_uid = 0; ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), + m_assignedTechnician(nullptr), m_discountPercentage(0.0) {} ServiceBooking::ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -18,7 +24,7 @@ ServiceBooking::ServiceBooking( const std::string& vehicleBrand, const std::string& vehicleModel, const std::string& assignedTechnicianId, - const std::string& assignedTechnician, + User* assignedTechnician, double discountPercentage ) : m_id("SRV" + std::to_string(++m_uid)), @@ -33,6 +39,42 @@ ServiceBooking::ServiceBooking( m_assignedTechnician(assignedTechnician), m_discountPercentage(discountPercentage) { + int numberOfServices = m_services.getSize(); + auto servicePointers = m_services.getValues(); + for (int index = 0; index < numberOfServices; index++) + { + m_serviceIDs.push_back(servicePointers[index]->getId()); + } +} + +ServiceBooking::ServiceBooking( + const std::string& id, + util::ServiceJobStatus status, + const util::Vector& serviceIDs, + const std::string& customerId, + const std::string& vehicleNumber, + const std::string& vehicleBrand, + const std::string& vehicleModel, + const std::string& assignedTechnicianId, + double discountPercentage +) + : m_id(id), + m_status(status), + m_serviceIDs(serviceIDs), + m_customerId(customerId), + m_customer(nullptr), + m_vehicleNumber(vehicleNumber), + m_vehicleBrand(vehicleBrand), + m_vehicleModel(vehicleModel), + m_assignedTechnicianId(assignedTechnicianId), + m_assignedTechnician(nullptr), + m_discountPercentage(discountPercentage) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } } const std::string& ServiceBooking::getId() const @@ -45,6 +87,11 @@ util::ServiceJobStatus ServiceBooking::getStatus() const return m_status; } +const util::Vector& ServiceBooking::getServiceIDs() const +{ + return m_serviceIDs; +} + const util::Map& ServiceBooking::getServices() const { return m_services; @@ -80,7 +127,7 @@ const std::string& ServiceBooking::getAssignedTechnicianId() const return m_assignedTechnicianId; } -const std::string& ServiceBooking::getAssignedTechnician() const +const User* ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } @@ -103,6 +150,13 @@ void ServiceBooking::setStatus(const util::ServiceJobStatus& status) void ServiceBooking::setServices(const util::Map& services) { m_services = services; + m_serviceIDs.clear(); + int numberOfServices = m_services.getSize(); + auto servicePointers = m_services.getValues(); + for (int index = 0; index < numberOfServices; index++) + { + m_serviceIDs.push_back(servicePointers[index]->getId()); + } } void ServiceBooking::setCustomerId(const std::string& customerId) @@ -135,7 +189,7 @@ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnici m_assignedTechnicianId = assignedTechnicianId; } -void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician) +void ServiceBooking::setAssignedTechnician(User* assignedTechnician) { m_assignedTechnician = assignedTechnician; } @@ -143,4 +197,89 @@ void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician void ServiceBooking::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; -} \ No newline at end of file +} + +static std::string getServiceIDsAsString(const util::Vector& serviceIDs) +{ + int numberOfServices = serviceIDs.getSize(); + std::string serviceIDsString; + for (int index = 0; index < numberOfServices; index++) + { + serviceIDsString += serviceIDs[index]; + if (index < numberOfServices - 1) + { + serviceIDsString += '|'; + } + } + return serviceIDsString; +} + +static util::Vector getServiceIDsAsVector(const std::string& serviceIDsString) +{ + util::Vector serviceIDs; + std::string serviceID; + std::istringstream serializedServiceIDs(serviceIDsString); + while (getline(serializedServiceIDs, serviceID, '|')) + { + serviceIDs.push_back(serviceID); + } + return serviceIDs; +} + +std::string ServiceBooking::serialize() const +{ + std::ostringstream serializedBooking; + serializedBooking << m_id << ',' + << util::getServiceJobStatusString(m_status) << ',' + << getServiceIDsAsString(m_serviceIDs) << ',' + << m_customerId << ',' + << m_vehicleNumber << ',' + << m_vehicleBrand << ',' + << m_vehicleModel << ',' + << m_assignedTechnicianId << ',' + << m_discountPercentage << ','; + return serializedBooking.str(); +} + +ServiceBooking* ServiceBooking::deserialize(const std::string& record) +{ + std::string id, customerId, vehicleNumber, vehicleBrand, vehicleModel, assignedTechnicianId; + std::string serviceJobStatusString, serviceIDsString, discountPercentageString; + double discountPercentage; + std::istringstream serializedBooking(record); + getline(serializedBooking, id, ','); + getline(serializedBooking, serviceJobStatusString, ','); + getline(serializedBooking, serviceIDsString, ','); + getline(serializedBooking, customerId, ','); + getline(serializedBooking, vehicleNumber, ','); + getline(serializedBooking, vehicleBrand, ','); + getline(serializedBooking, vehicleModel, ','); + getline(serializedBooking, assignedTechnicianId, ','); + getline(serializedBooking, discountPercentageString, ','); + util::Vector serviceIDs = getServiceIDsAsVector(serviceIDsString); + try + { + discountPercentage = std::stod(discountPercentageString); + } + catch (...) + { + throw std::runtime_error("Invalid discount percentage"); + } + util::ServiceJobStatus status = util::getServiceJobStatus(serviceJobStatusString); + return Factory::getObject( + id, + status, + serviceIDs, + customerId, + vehicleNumber, + vehicleBrand, + vehicleModel, + assignedTechnicianId, + discountPercentage + ); +} + +std::string ServiceBooking::getHeaders() +{ + return "ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage"; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 5ecc1b0..896360d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" #include "Enums.h" class Service; @@ -12,6 +13,7 @@ private: static int m_uid; std::string m_id; util::ServiceJobStatus m_status; + util::Vector m_serviceIDs; util::Map m_services; std::string m_customerId; User* m_customer; @@ -19,12 +21,11 @@ private: std::string m_vehicleBrand; std::string m_vehicleModel; std::string m_assignedTechnicianId; - std::string m_assignedTechnician; + User* m_assignedTechnician; double m_discountPercentage; public: ServiceBooking(); ServiceBooking( - const std::string& id, util::ServiceJobStatus status, const util::Map& services, @@ -34,11 +35,23 @@ public: const std::string& vehicleBrand, const std::string& vehicleModel, const std::string& assignedTechnicianId, - const std::string& assignedTechnician, + User* assignedTechnician, + double discountPercentage + ); + ServiceBooking( + const std::string& id, + util::ServiceJobStatus status, + const util::Vector& serviceIDs, + const std::string& customerId, + const std::string& vehicleNumber, + const std::string& vehicleBrand, + const std::string& vehicleModel, + const std::string& assignedTechnicianId, double discountPercentage ); const std::string& getId() const; util::ServiceJobStatus getStatus() const; + const util::Vector& getServiceIDs() const; const util::Map& getServices() const; const std::string& getCustomerId() const; User* getCustomer() const; @@ -46,7 +59,7 @@ public: const std::string& getVehicleBrand() const; const std::string& getVehicleModel() const; const std::string& getAssignedTechnicianId() const; - const std::string& getAssignedTechnician() const; + const User* getAssignedTechnician() const; double getDiscountPercentage() const; void setId(const std::string& id); void setStatus(const util::ServiceJobStatus& status); @@ -57,6 +70,9 @@ public: void setVehicleBrand(const std::string& vehicleBrand); void setVehicleModel(const std::string& vehicleModel); void setAssignedTechnicianId(const std::string& assignedTechnicianId); - void setAssignedTechnician(const std::string& assignedTechnician); + void setAssignedTechnician(User* assignedTechnician); void setDiscountPercentage(double discountPercentage); + std::string serialize() const; + static ServiceBooking* deserialize(const std::string&); + static std::string getHeaders(); }; \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp index 52d85a9..7bea5f0 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp @@ -1,6 +1,9 @@ +#include #include "User.h" #include "Notification.h" #include "Enums.h" +#include "Factory.h" +#include "StringHelper.h" int User::m_uid = 0; @@ -19,11 +22,29 @@ User::User(const std::string& userName, const std::string& password, const std:: m_type(role), m_status(util::State::ACTIVE) {} +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_userName(userName), + m_password(password), + m_name(name), + m_phone(phone), + m_email(email), + m_type(role), + m_status(status) +{ + int idNumber = util::extractNumber(m_id); + if (idNumber > m_uid) + { + m_uid = idNumber; + } +} + User::~User() { - for (int index = 0; index < m_notifications.getSize(); index++) + auto values = m_notifications.getValues(); + for (int index = 0; index < values.getSize(); index++) { - delete m_notifications.getValues()[index]; + delete values[index]; } } @@ -120,3 +141,48 @@ void User::setState(util::State status) void User::update(Notification* notification) { } + +std::string User::serialize() const +{ + std::ostringstream serializedUser; + serializedUser << m_id << ',' + << m_userName << ',' + << m_password << ',' + << m_name << ',' + << m_phone << ',' + << m_email << ',' + << util::getUserTypeString(m_type) << ',' + << util::getStateString(m_status); + return serializedUser.str(); +} + +User* User::deserialize(const std::string& record) +{ + std::string id, name, username, phone, password, email; + std::string userTypeString, stateString; + std::istringstream serializedUser(record); + getline(serializedUser, id, ','); + getline(serializedUser, username, ','); + getline(serializedUser, password, ','); + getline(serializedUser, name, ','); + getline(serializedUser, phone, ','); + getline(serializedUser, email, ','); + getline(serializedUser, userTypeString, ','); + getline(serializedUser, stateString); + util::UserType userType = util::getUserType(userTypeString); + util::State status = util::getState(stateString); + return Factory::getObject(id, + username, + password, + name, + phone, + email, + userType, + status); +} + +std::string User::getHeaders() +{ + return "ID,Username,Password,Name,Phone,Email,UserType,UserStatus"; +} + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h index bde21e1..efe4374 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.h @@ -22,6 +22,7 @@ private: public: User(); User(const std::string& userName, const std::string& password, const std::string& name, const std::string& phone, const std::string& email, util::UserType role); + 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(); const std::string& getId() const; const std::string& getUserName() const; @@ -42,4 +43,7 @@ public: void setRole(util::UserType role); void setState(util::State status); void update(Notification* notification) override; + std::string serialize() const; + static User* deserialize(const std::string&); + static std::string getHeaders(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 39ef719..9aa5166 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,49 @@ #include "InventoryManagementService.h" +#include "FileManager.h" +#include "InventoryItem.h" +#include "Utility.h" +#include "Config.h" + +util::Vector InventoryManagementService::getObserverIDs() +{ + util::Vector observerIDs; + int numberOfObservers = m_observers.getSize(); + for (int index = 0; index < numberOfObservers; index++) + { + User* observer = m_observers.getValueAt(index); + if (observer) + { + observerIDs.push_back(observer->getId()); + } + } + return observerIDs; +} + +void InventoryManagementService::loadInventoryItems() +{ + util::FileManager inventoryItemFileManager(config::file::INVENTORYITEM_FILE); + auto& inventoryItems = m_dataStore.getInventoryItems(); + auto inventoryItemsMap = inventoryItemFileManager.load(); + int numberOfInventoryItems = inventoryItemsMap.getSize(); + for (int index = 0; index < numberOfInventoryItems; index++) + { + inventoryItems[inventoryItemsMap.getKeyAt(index)] = inventoryItemsMap.getValueAt(index); + } +} + +void InventoryManagementService::saveInventoryItems() +{ + util::FileManager inventoryItemFileManager(config::file::INVENTORYITEM_FILE); + auto& inventoryItems = m_dataStore.getInventoryItems(); + inventoryItemFileManager.save(inventoryItems); +} + +void InventoryManagementService::loadObservers() +{ + util::loadObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this, m_dataStore); +} + +void InventoryManagementService::saveObservers() +{ + util::saveObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h index 099b964..4473c7d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h @@ -1,6 +1,7 @@ #pragma once #include #include "Map.h" +#include "Vector.h" #include "NotificationManagementService.h" #include "DataStore.h" @@ -11,6 +12,7 @@ class InventoryManagementService : public NotificationManagementService private: DataStore& m_dataStore; static util::Map m_observers; + util::Vector getObserverIDs() override; public: InventoryManagementService() : m_dataStore(DataStore::getInstance()) {} util::Map getInventoryItems(); @@ -21,4 +23,8 @@ public: void sendNotification(User* user, const std::string& title, const std::string& message) override; void attach(User* user) override; void detach(User* user) override; + void loadInventoryItems(); + void saveInventoryItems(); + void loadObservers(); + void saveObservers(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h index b193b1d..096782a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/NotificationManagementService.h @@ -10,4 +10,5 @@ public: virtual void sendNotification(User* recipient, const std::string& title, const std::string& message) = 0; virtual void attach(User* user) = 0; virtual void detach(User* user) = 0; + virtual util::Vector getObserverIDs() = 0; }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 786ebcf..055b57c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -1 +1,71 @@ +#include #include "PaymentManagementService.h" +#include "Invoice.h" +#include "FileManager.h" +#include "Utility.h" +#include "Config.h" + +util::Vector PaymentManagementService::getObserverIDs() +{ + util::Vector observerIDs; + int numberOfObservers = m_observers.getSize(); + for (int index = 0; index < numberOfObservers; index++) + { + User* observer = m_observers.getValueAt(index); + if (observer) + { + observerIDs.push_back(observer->getId()); + } + } + return observerIDs; +} + +void PaymentManagementService::loadInvoices() +{ + util::FileManager invoiceFileManager(config::file::INVOICE_FILE); + auto& invoices = m_dataStore.getInvoices(); + auto& serviceBookings = m_dataStore.getServiceBookings(); + auto& inventoryItems = m_dataStore.getInventoryItems(); + auto invoicesMap = invoiceFileManager.load(); + for (int invoiceIndex = 0; invoiceIndex < invoicesMap.getSize(); invoiceIndex++) + { + Invoice* invoice = invoicesMap.getValueAt(invoiceIndex); + int bookingIndex = serviceBookings.find(invoice->getBookingId()); + if (bookingIndex == -1) + { + throw std::runtime_error("Invalid Booking ID"); + } + ServiceBooking* booking = serviceBookings.getValueAt(bookingIndex); + invoice->setBooking(booking); + util::Map invoiceParts; + auto& partIDs = invoice->getPartIDs(); + for (int partIndex = 0; partIndex < partIDs.getSize(); partIndex++) + { + const std::string& partID = partIDs[partIndex]; + int inventoryIndex = inventoryItems.find(partID); + if (inventoryIndex == -1) + { + throw std::runtime_error("Invalid Part ID"); + } + invoiceParts[partID] = inventoryItems.getValueAt(inventoryIndex); + } + invoice->setParts(invoiceParts); + invoices[invoice->getId()] = invoice; + } +} +void PaymentManagementService::saveInvoices() +{ + util::FileManager invoiceFileManager(config::file::INVOICE_FILE); + auto& invoices = m_dataStore.getInvoices(); + invoiceFileManager.save(invoices); +} + +void PaymentManagementService::loadObservers() +{ + util::loadObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this, m_dataStore); +} + +void PaymentManagementService::saveObservers() +{ + util::saveObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h index 56a2fd2..6fb94fc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.h @@ -13,6 +13,7 @@ class PaymentManagementService : public NotificationManagementService private: DataStore& m_dataStore; static util::Map m_observers; + util::Vector getObserverIDs() override; public: PaymentManagementService() : m_dataStore(DataStore::getInstance()) {} void generateInvoice(ServiceBooking* booking); @@ -22,4 +23,8 @@ public: void sendNotification(User* user, const std::string& title, const std::string& message) override; void attach(User* user) override; void detach(User* user) override; + void loadInvoices(); + void saveInvoices(); + void loadObservers(); + void saveObservers(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 156c12b..eeb3e65 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1 +1,211 @@ +#include #include "ServiceManagementService.h" +#include "FileManager.h" +#include "Service.h" +#include "ComboPackage.h" +#include "ServiceBooking.h" +#include "JobCard.h" +#include "Config.h" +#include "Utility.h" + +util::Vector ServiceManagementService::getObserverIDs() +{ + util::Vector observerIDs; + int numberOfObservers = m_observers.getSize(); + for (int index = 0; index < numberOfObservers; index++) + { + User* observer = m_observers.getValueAt(index); + if (observer) + { + observerIDs.push_back(observer->getId()); + } + } + return observerIDs; +} + +void ServiceManagementService::loadServices() +{ + util::FileManager serviceFileManager(config::file::SERVICE_FILE); + auto& services = m_dataStore.getServices(); + auto& inventoryItems = m_dataStore.getInventoryItems(); + auto servicesMap = serviceFileManager.load(); + for (int serviceIndex = 0; serviceIndex < servicesMap.getSize(); serviceIndex++) + { + Service* service = servicesMap.getValueAt(serviceIndex); + services[service->getId()] = service; + util::Map inventoryItemsMap; + auto& inventoryItemIDs = service->getRequiredInventoryItemIDs(); + for (int inventoryItemIndex = 0; inventoryItemIndex < inventoryItemIDs.getSize(); inventoryItemIndex++) + { + const std::string& inventoryItemID = inventoryItemIDs[inventoryItemIndex]; + int index = inventoryItems.find(inventoryItemID); + if (index == -1) + { + throw std::runtime_error("Invalid Inventory Item ID"); + } + inventoryItemsMap[inventoryItemID] = inventoryItems.getValueAt(index); + } + service->setRequiredInventoryItems(inventoryItemsMap); + } +} + +void ServiceManagementService::saveServices() +{ + util::FileManager serviceFileManager(config::file::SERVICE_FILE); + auto& services = m_dataStore.getServices(); + serviceFileManager.save(services); +} + +void ServiceManagementService::loadComboPackages() +{ + util::FileManager comboPackageFileManager(config::file::COMBOPACKAGE_FILE); + auto& comboPackages = m_dataStore.getComboPackages(); + auto& services = m_dataStore.getServices(); + auto comboPackagesMap = comboPackageFileManager.load(); + for (int packageIndex = 0; packageIndex < comboPackagesMap.getSize(); packageIndex++) + { + ComboPackage* comboPackage = comboPackagesMap.getValueAt(packageIndex); + util::Map packageServices; + auto& serviceIDs = comboPackage->getServiceIDs(); + for (int serviceIndex = 0; serviceIndex < serviceIDs.getSize(); serviceIndex++) + { + const std::string& serviceID = serviceIDs[serviceIndex]; + int serviceMapIndex = services.find(serviceID); + if (serviceMapIndex == -1) + { + throw std::runtime_error("Invalid Service ID"); + } + packageServices[serviceID] = services.getValueAt(serviceMapIndex); + } + comboPackage->setServices(packageServices); + comboPackages[comboPackage->getId()] = comboPackage; + } +} + +void ServiceManagementService::saveComboPackages() +{ + util::FileManager comboPackageFileManager(config::file::COMBOPACKAGE_FILE); + auto& comboPackages = m_dataStore.getComboPackages(); + comboPackageFileManager.save(comboPackages); +} + +void ServiceManagementService::loadServiceBookings() +{ + util::FileManager bookingFileManager(config::file::SERVICEBOOKING_FILE); + auto& serviceBookings = m_dataStore.getServiceBookings(); + auto& services = m_dataStore.getServices(); + auto& users = m_dataStore.getUsers(); + auto bookingsMap = bookingFileManager.load(); + for (int bookingIndex = 0; bookingIndex < bookingsMap.getSize(); bookingIndex++) + { + ServiceBooking* booking = bookingsMap.getValueAt(bookingIndex); + util::Map bookingServices; + auto& serviceIDs = booking->getServiceIDs(); + for (int serviceIndex = 0; serviceIndex < serviceIDs.getSize(); serviceIndex++) + { + const std::string& serviceID = serviceIDs[serviceIndex]; + int serviceMapIndex = services.find(serviceID); + if (serviceMapIndex == -1) + { + throw std::runtime_error("Invalid Service ID"); + } + + bookingServices[serviceID] = services.getValueAt(serviceMapIndex); + } + booking->setServices(bookingServices); + int customerIndex = users.find(booking->getCustomerId()); + if (customerIndex == -1) + { + throw std::runtime_error("Invalid Customer ID"); + } + User* customer = users.getValueAt(customerIndex); + if (customer->getUserType() != util::UserType::CUSTOMER) + { + throw std::runtime_error("User is not a customer"); + } + booking->setCustomer(customer); + const std::string& technicianId = booking->getAssignedTechnicianId(); + if (!technicianId.empty()) + { + int technicianIndex = users.find(technicianId); + if (technicianIndex == -1) + { + throw std::runtime_error("Invalid Technician ID"); + } + User* technician = users.getValueAt(technicianIndex); + if (technician->getUserType() != util::UserType::TECHNICIAN) + { + throw std::runtime_error("User is not a technician"); + } + booking->setAssignedTechnician(technician); + } + serviceBookings[booking->getId()] = booking; + } +} + +void ServiceManagementService::saveServiceBookings() +{ + util::FileManager bookingFileManager(config::file::SERVICEBOOKING_FILE); + auto& serviceBookings = m_dataStore.getServiceBookings(); + bookingFileManager.save(serviceBookings); +} + +void ServiceManagementService::loadJobCards() +{ + util::FileManager jobCardFileManager(config::file::JOBCARD_FILE); + auto& jobCards = m_dataStore.getJobCards(); + auto& serviceBookings = m_dataStore.getServiceBookings(); + auto& services = m_dataStore.getServices(); + auto& users = m_dataStore.getUsers(); + auto jobCardsMap = jobCardFileManager.load(); + for (int jobCardIndex = 0; jobCardIndex < jobCardsMap.getSize(); jobCardIndex++) + { + JobCard* jobCard = jobCardsMap.getValueAt(jobCardIndex); + int bookingIndex = serviceBookings.find(jobCard->getBookingId()); + if (bookingIndex == -1) + { + throw std::runtime_error("Invalid Booking ID"); + } + ServiceBooking* booking = serviceBookings.getValueAt(bookingIndex); + jobCard->setBooking(booking); + int serviceIndex = services.find(jobCard->getServiceId()); + if (serviceIndex == -1) + { + throw std::runtime_error("Invalid Service ID"); + } + Service* service = services.getValueAt(serviceIndex); + if (booking->getServices().find(jobCard->getServiceId()) == -1) + { + throw std::runtime_error("Service does not belong to booking"); + } + jobCard->setService(service); + int technicianIndex = users.find(jobCard->getTechnicianId()); + if (technicianIndex == -1) + { + throw std::runtime_error("Invalid Technician ID"); + } + User* technician = users.getValueAt(technicianIndex); + if (technician->getUserType() != util::UserType::TECHNICIAN) + { + throw std::runtime_error("User is not a technician"); + } + jobCard->setTechnician(technician); + jobCards[jobCard->getId()] = jobCard; + } +} +void ServiceManagementService::saveJobCards() +{ + util::FileManager jobCardFileManager(config::file::JOBCARD_FILE); + auto& jobCards = m_dataStore.getJobCards(); + jobCardFileManager.save(jobCards); +} + +void ServiceManagementService::loadObservers() +{ + util::loadObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this, m_dataStore); +} + +void ServiceManagementService::saveObservers() +{ + util::saveObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h index 85e05ed..b4bc99a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h @@ -14,6 +14,7 @@ class ServiceManagementService : public NotificationManagementService private: DataStore& m_dataStore; static util::Map m_observers; + util::Vector getObserverIDs() override; public: ServiceManagementService() : m_dataStore(DataStore::getInstance()) {} util::Map getServices(); @@ -34,4 +35,14 @@ public: void sendNotification(User* user, const std::string& title, const std::string& message) override; void attach(User* user) override; void detach(User* user) override; + void loadServices(); + void saveServices(); + void loadComboPackages(); + void saveComboPackages(); + void loadServiceBookings(); + void saveServiceBookings(); + void loadJobCards(); + void saveJobCards(); + void loadObservers(); + void saveObservers(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 2a5bd9e..8731484 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1 +1,52 @@ #include "UserManagementService.h" +#include "FileManager.h" +#include "User.h" +#include "Notification.h" +#include "Config.h" + +void UserManagementService::loadUsers() +{ + util::FileManager userFileManager(config::file::USER_FILE); + util::FileManager notificationFileManager(config::file::NOTIFICATION_FILE); + auto& users = m_dataStore.getUsers(); + auto usersMap = userFileManager.load(); + auto notificationsMap = notificationFileManager.load(); + int numberOfUsers = usersMap.getSize(); + int numberOfNotifications = notificationsMap.getSize(); + for (int index = 0; index < numberOfUsers; index++) + { + users[usersMap.getKeyAt(index)] = usersMap.getValueAt(index); + } + for (int index = 0; index < numberOfNotifications; index++) + { + Notification* notification = notificationsMap.getValueAt(index); + const std::string& recipientUserId = notification->getRecipientUserId(); + int userIndex = users.find(recipientUserId); + if (userIndex == -1) + { + throw std::runtime_error("Invalid recipient user ID"); + } + User* user = users.getValueAt(userIndex); + user->addNotification(notification); + } +} + +void UserManagementService::saveUsers() +{ + util::FileManager userFileManager(config::file::USER_FILE); + util::FileManager notificationFileManager(config::file::NOTIFICATION_FILE); + auto& users = m_dataStore.getUsers(); + util::Map notifications; + for (int userIndex = 0; userIndex < users.getSize(); userIndex++) + { + User* user = users.getValueAt(userIndex); + auto& userNotifications = user->getNotifications(); + for (int notificationIndex = 0; notificationIndex < userNotifications.getSize(); notificationIndex++) + { + notifications[userNotifications.getKeyAt(notificationIndex)] = + userNotifications.getValueAt(notificationIndex); + } + } + userFileManager.save(users); + notificationFileManager.save(notifications); +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index bb7a85a..6bd6488 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -21,4 +21,6 @@ public: void removeUser(const std::string& userID); util::Vector getUserNotifications(const std::string& userID); void deleteNotification(const std::string& notificationID, const std::string& userID); + void loadUsers(); + void saveUsers(); }; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h new file mode 100644 index 0000000..751ec31 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -0,0 +1,19 @@ +#pragma once + +namespace config +{ + namespace file + { + constexpr const char* INVENTORYITEM_FILE = "files/InventoryItem.csv"; + constexpr const char* USER_FILE = "files/User.csv"; + constexpr const char* NOTIFICATION_FILE = "files/Notification.csv"; + constexpr const char* SERVICE_FILE = "files/Service.csv"; + constexpr const char* COMBOPACKAGE_FILE = "files/ComboPackage.csv"; + constexpr const char* SERVICEBOOKING_FILE = "files/ServiceBooking.csv"; + constexpr const char* JOBCARD_FILE = "files/JobCard.csv"; + constexpr const char* INVOICE_FILE = "files/Invoice.csv"; + constexpr const char* SERVICEMANAGEMENTOBSERVERS = "files/ServiceManagementObservers.csv"; + constexpr const char* PAYMENTMANAGEMENTOBSERVERS = "files/PaymentManagementObservers.csv"; + constexpr const char* INVENTORYMANAGEMENTOBSERVERS = "files/InventoryManagementObservers.csv"; + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h new file mode 100644 index 0000000..b9990b2 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h @@ -0,0 +1,47 @@ +#pragma once +#include +#include +#include +#include "Vector.h" + +namespace util +{ + inline util::Vector loadRecords(const std::string& filePath) + { + util::Vector records; + std::ifstream file(filePath); + if (!file.is_open()) + { + std::ofstream newFile(filePath); + newFile.close(); + file.open(filePath); + } + std::string line; + bool isHeader = true; + while (std::getline(file, line)) + { + if (isHeader) + { + isHeader = false; + continue; + } + records.push_back(line); + } + return records; + } + + inline void saveRecords(const std::string& filePath, const util::Vector& records) + { + std::ofstream file(filePath, std::ios::trunc); + if (!file.is_open()) + { + throw std::runtime_error("Failed to open file " + filePath); + } + file << "Values" << '\n'; + int numberOfRecords = records.getSize(); + for (int index = 0; index < numberOfRecords; index++) + { + file << records[index] << '\n'; + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h new file mode 100644 index 0000000..f3b0de5 --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h @@ -0,0 +1,82 @@ +#pragma once +#include +#include +#include "Vector.h" +#include "Map.h" + +namespace util +{ + template using objects = util::Map; + + template + class FileManager + { + private: + std::string m_filePath; + public: + FileManager() : m_filePath("") {} + FileManager(const std::string& filePath) : m_filePath(filePath) {} + objects load(); + void save(const objects&); + }; + + template + objects FileManager::load() + { + objects records; + std::ifstream file(m_filePath); + if (!file.is_open()) + { + std::ofstream newFile(m_filePath); + newFile.close(); + file.open(m_filePath); + } + util::Vector lines; + std::string line; + while (std::getline(file, line)) + { + lines.push_back(line); + } + int numberOfLines = lines.getSize(); + bool isHeader = true; + for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) + { + const auto& record = lines[lineIndex]; + if (isHeader) + { + isHeader = false; + continue; + } + auto object = T::deserialize(record); + if (!object) + { + throw std::runtime_error("Failed to deserialize record"); + } + records[object->getId()] = object; + } + return records; + } + + template + void FileManager::save(const objects& records) + { + util::Vector lines; + lines.push_back(T::getHeaders()); + int numberOfRecords = records.getSize(); + for (int recordIndex = 0; recordIndex < numberOfRecords; recordIndex++) + { + const auto& record = records.getValueAt(recordIndex); + lines.push_back(record->serialize()); + } + std::ofstream file(m_filePath, std::ios::trunc); + if (!file.is_open()) + { + throw std::runtime_error("Failed to open file " + m_filePath); + } + int numberOfLines = lines.getSize(); + for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) + { + file << lines[lineIndex] << '\n'; + } + } +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/InputHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/InputHelper.h index d8fee08..e789442 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/InputHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/InputHelper.h @@ -34,7 +34,7 @@ namespace util /* * Function: read - * Description: Reads a line of text input from console into a string. + * Description: Reads a line of text input from console into a string and cleans it up. * Parameters: * value - reference to a string where the input will be stored * Returns: @@ -43,6 +43,15 @@ namespace util inline void read(std::string& value) { std::getline(std::cin >> std::ws, value); + std::string cleanedValue; + for (int index = 0; index < value.length(); index++) + { + if (value[index] != ',') + { + cleanedValue += value[index]; + } + } + value = cleanedValue; } /* diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h new file mode 100644 index 0000000..64f657c --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h @@ -0,0 +1,18 @@ +#include +#include + +namespace util +{ + inline int extractNumber(const std::string& input) + { + int result = 0; + for (char character : input) + { + if (std::isdigit(static_cast(character))) + { + result = result * 10 + (character - '0'); + } + } + return result; + } +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h new file mode 100644 index 0000000..f3a895f --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -0,0 +1,29 @@ +#pragma once +#include "NotificationManagementService.h" +#include "FileHelper.h" +#include "DataStore.h" + +namespace util +{ + inline void loadObservers(const std::string& filePath, NotificationManagementService* service, DataStore& dataStore) + { + auto observerIDs = util::loadRecords(filePath); + auto& users = dataStore.getUsers(); + for (int index = 0; index < observerIDs.getSize(); index++) + { + const std::string& observerID = observerIDs[index]; + int userIndex = users.find(observerID); + if (userIndex == -1) + { + throw std::runtime_error("Invalid Observer ID"); + } + service->attach(users.getValueAt(userIndex)); + } + } + + inline void saveObservers(const std::string& filePath, NotificationManagementService* service) + { + auto observerIDs = service->getObserverIDs(); + util::saveRecords(filePath, observerIDs); + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..ddba515 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -4,6 +4,7 @@ void UserInterface::run() { + m_controller.loadSystemData(); bool isMenuActive = true; while (isMenuActive) { @@ -24,6 +25,7 @@ void UserInterface::run() util::pressEnter(); } } + m_controller.saveSystemData(); } bool UserInterface::handleOperation(int choice) From 388e459a5affb917fc59ddf027a2f8fa69d7241d Mon Sep 17 00:00:00 2001 From: Jissin Mathew Date: Fri, 22 May 2026 16:52:06 +0530 Subject: [PATCH 18/20] Add documentation headers across system modules --- .../controllers/Controller.cpp | 20 +++ .../models/ComboPackage.cpp | 55 ++++++++ .../models/InventoryItem.cpp | 41 +++++- .../models/Invoice.cpp | 52 +++++++- .../models/JobCard.cpp | 42 +++++++ .../models/Notification.cpp | 39 ++++++ .../models/Service.cpp | 63 ++++++++++ .../models/ServiceBooking.cpp | 70 ++++++++++- .../models/User.cpp | 43 ++++++- .../services/InventoryManagementService.cpp | 57 ++++++++- .../services/PaymentManagementService.cpp | 54 +++++++- .../services/ServiceManagementService.cpp | 117 +++++++++++++++++- .../services/UserManagementService.cpp | 23 +++- .../utilities/FileHelper.h | 32 +++++ .../utilities/FileManager.h | 34 +++++ .../utilities/StringHelper.h | 18 +++ .../utilities/Utility.h | 34 +++++ 17 files changed, 785 insertions(+), 9 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index a6f230d..83eb073 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -141,6 +141,16 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN { } +/* +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() { m_userManagementService.loadUsers(); @@ -155,6 +165,16 @@ void Controller::loadSystemData() 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() { m_userManagementService.saveUsers(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp index c76d727..2947572 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ComboPackage.cpp @@ -27,6 +27,19 @@ 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&, 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& serviceIDs, util::State status) : m_id(id), m_packageName(packageName), @@ -103,6 +116,14 @@ void ComboPackage::setState(util::State 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&, vector of service IDs +Returns: + - std::string: Concatenated service IDs string +*/ static std::string getServiceIDsAsString(const util::Vector& serviceIDs) { int numberOfServices = serviceIDs.getSize(); @@ -118,6 +139,14 @@ static std::string getServiceIDsAsString(const util::Vector& servic 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: Vector of service IDs +*/ static util::Vector getServiceIDsAsVector(const std::string& serviceIDsString) { util::Vector serviceIDs; @@ -130,6 +159,14 @@ static util::Vector getServiceIDsAsVector(const std::string& servic 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::ostringstream serializedComboPackage; @@ -141,6 +178,16 @@ std::string ComboPackage::serialize() const 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) { std::string id, packageName; @@ -171,6 +218,14 @@ 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() { return "ID,PackageName,DiscountPercentage,ServiceIDs,Status"; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp index da0fd3c..874e20b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/InventoryItem.cpp @@ -19,6 +19,19 @@ InventoryItem::InventoryItem(const std::string& partName, int quantity, double p m_status(util::State::ACTIVE), 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) : m_id(id), m_partName(partName), @@ -83,6 +96,14 @@ void InventoryItem::setState(util::State 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::ostringstream serializedInventoryItem; @@ -94,6 +115,16 @@ std::string InventoryItem::serialize() const 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) { std::string id, partName; @@ -125,7 +156,15 @@ 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() { return "ID,PartName,Quantity,Price,Status"; -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp index 622988e..ce44342 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Invoice.cpp @@ -109,6 +109,14 @@ double Invoice::getLaborCost() const return m_laborCost; } +/* +Function: getPartIDs +Description: Retrieves the IDs of parts used in the invoice. +Parameters: + - None +Returns: + - const util::Vector&: Part IDs +*/ const util::Vector& Invoice::getPartIDs() const { return m_partIDs; @@ -216,6 +224,14 @@ void Invoice::setStatus(util::PaymentStatus 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&, vector of part IDs +Returns: + - std::string: Concatenated part IDs string +*/ static std::string getPartIDsAsString(const util::Vector& partIDs) { int numberOfParts = partIDs.getSize(); @@ -231,6 +247,14 @@ static std::string getPartIDsAsString(const util::Vector& partIDs) 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: Vector of part IDs +*/ static util::Vector getPartIDsAsVector(const std::string& partIDsString) { util::Vector partIDs; @@ -243,6 +267,14 @@ static util::Vector getPartIDsAsVector(const std::string& partIDsSt 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::ostringstream serializedInvoice; @@ -260,6 +292,16 @@ std::string Invoice::serialize() const 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) { std::string id, bookingId; @@ -312,7 +354,15 @@ 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() { return "ID,BookingID,InvoiceDate,LaborCost,PartIDs,PartsCost,DiscountPercentage,TotalAmount,PaymentDate,PaymentMethod,Status"; -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp index 6683dc1..977d91f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/JobCard.cpp @@ -35,6 +35,22 @@ JobCard::JobCard(const std::string& bookingId, m_status(status), 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, const std::string& bookingId, const std::string& serviceId, @@ -161,6 +177,14 @@ void JobCard::setCompletionDate(const util::Timestamp& 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::ostringstream serializedJobCard; @@ -174,6 +198,16 @@ std::string JobCard::serialize() const 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) { std::string id, bookingId, serviceId, technicianId; @@ -209,6 +243,14 @@ 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() { return "ID,BookingID,ServiceID,TechnicianID,AssignedDate,Status,CompletionDate"; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp index 86eaaec..a29b836 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Notification.cpp @@ -17,6 +17,19 @@ Notification::Notification(const std::string& recipientUserId, User* recipient, m_message(message), 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) : m_id(id), m_recipientUserId(recipientUserId), @@ -92,6 +105,14 @@ void Notification::setCreatedAt(const util::Timestamp& 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::ostringstream serializedNotification; @@ -103,6 +124,16 @@ std::string Notification::serialize() const 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) { std::string id, recipientUserId, title, message, createdAtTimestampString; @@ -130,6 +161,14 @@ 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() { return "ID,RecipientID,Title,Message,Timestamp"; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp index e83b639..5259370 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/Service.cpp @@ -26,6 +26,19 @@ Service::Service(const std::string& name, const util::Map&, 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& requiredInventoryItemIDs, double laborCost, util::State status) : m_id(id), m_name(name), @@ -50,6 +63,14 @@ const std::string& Service::getName() const return m_name; } +/* +Function: getRequiredInventoryItemIDs +Description: Retrieves the IDs of required inventory items for the service. +Parameters: + - None +Returns: + - const util::Vector&: Inventory item IDs +*/ const util::Vector& Service::getRequiredInventoryItemIDs() const { return m_requiredInventoryItemIDs; @@ -102,6 +123,14 @@ void Service::setState(util::State 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&, vector of inventory item IDs +Returns: + - std::string: Concatenated inventory item IDs string +*/ static std::string getInventoryItemIDsAsString(const util::Vector& inventoryItemIds) { int numberOfInventoryItems = inventoryItemIds.getSize(); @@ -117,6 +146,14 @@ static std::string getInventoryItemIDsAsString(const util::Vector& 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: Vector of inventory item IDs +*/ static util::Vector getInventoryItemIDsAsVector(const std::string& inventoryItemIDsString) { util::Vector inventoryItemIDs; @@ -129,6 +166,14 @@ static util::Vector getInventoryItemIDsAsVector(const std::string& 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::ostringstream serializedService; @@ -140,6 +185,16 @@ std::string Service::serialize() const 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) { std::string id, name; @@ -170,6 +225,14 @@ 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() { return "ID,Name,InventoryIDs,LaborCost,Status"; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index efd6c6a..5c1b6c1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -47,6 +47,24 @@ 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&, 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( const std::string& id, util::ServiceJobStatus status, @@ -87,6 +105,14 @@ util::ServiceJobStatus ServiceBooking::getStatus() const return m_status; } +/* +Function: getServiceIDs +Description: Retrieves the IDs of services booked. +Parameters: + - None +Returns: + - const util::Vector&: Service IDs +*/ const util::Vector& ServiceBooking::getServiceIDs() const { return m_serviceIDs; @@ -199,6 +225,14 @@ void ServiceBooking::setDiscountPercentage(double 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&, vector of service IDs +Returns: + - std::string: Concatenated service IDs string +*/ static std::string getServiceIDsAsString(const util::Vector& serviceIDs) { int numberOfServices = serviceIDs.getSize(); @@ -214,6 +248,14 @@ static std::string getServiceIDsAsString(const util::Vector& servic 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: Vector of service IDs +*/ static util::Vector getServiceIDsAsVector(const std::string& serviceIDsString) { util::Vector serviceIDs; @@ -226,6 +268,14 @@ static util::Vector getServiceIDsAsVector(const std::string& servic 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::ostringstream serializedBooking; @@ -241,6 +291,16 @@ std::string ServiceBooking::serialize() const 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) { std::string id, customerId, vehicleNumber, vehicleBrand, vehicleModel, assignedTechnicianId; @@ -279,7 +339,15 @@ 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() { return "ID,Status,ServiceIDs,CustomerID,VehicleNumber,VehicleBrand,VehicleModel,AssignedTechnicianID,DiscountPercentage"; -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp index 7bea5f0..e52faed 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/User.cpp @@ -22,6 +22,22 @@ User::User(const std::string& userName, const std::string& password, const std:: m_type(role), 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) : m_id(userId), m_userName(userName), @@ -142,6 +158,14 @@ void User::update(Notification* notification) { } +/* +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::ostringstream serializedUser; @@ -156,6 +180,14 @@ std::string User::serialize() const 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) { std::string id, name, username, phone, password, email; @@ -181,8 +213,15 @@ User* User::deserialize(const std::string& record) 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() { return "ID,Username,Password,Name,Phone,Email,UserType,UserStatus"; -} - +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 9aa5166..60b67db 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1,9 +1,28 @@ +/* +File: InventoryManagementService.cpp +Description: Implements the InventoryManagementService class, which manages inventory + items and observer relationships within the system. Provides methods + for loading and saving inventory items from persistent storage, as well + as attaching and persisting observers for notification handling. +Author: Trenser +Date: 22-May-2026 +*/ + #include "InventoryManagementService.h" #include "FileManager.h" #include "InventoryItem.h" #include "Utility.h" #include "Config.h" +/* +Function: getObserverIDs +Description: Retrieves the IDs of all observers currently attached to the + InventoryManagementService. +Parameters: + - None +Returns: + - util::Vector: Vector of observer user IDs +*/ util::Vector InventoryManagementService::getObserverIDs() { util::Vector observerIDs; @@ -19,6 +38,15 @@ util::Vector InventoryManagementService::getObserverIDs() 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() { util::FileManager inventoryItemFileManager(config::file::INVENTORYITEM_FILE); @@ -31,6 +59,15 @@ 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() { util::FileManager inventoryItemFileManager(config::file::INVENTORYITEM_FILE); @@ -38,12 +75,30 @@ void InventoryManagementService::saveInventoryItems() 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() { 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() { util::saveObservers(config::file::INVENTORYMANAGEMENTOBSERVERS, this); -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 055b57c..404f035 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -5,6 +5,15 @@ #include "Utility.h" #include "Config.h" +/* +Function: getObserverIDs +Description: Retrieves the IDs of all observers currently attached to the + PaymentManagementService. +Parameters: + - None +Returns: + - util::Vector: Vector of observer user IDs +*/ util::Vector PaymentManagementService::getObserverIDs() { util::Vector observerIDs; @@ -20,6 +29,19 @@ util::Vector PaymentManagementService::getObserverIDs() 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() { util::FileManager invoiceFileManager(config::file::INVOICE_FILE); @@ -53,6 +75,16 @@ void PaymentManagementService::loadInvoices() 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() { util::FileManager invoiceFileManager(config::file::INVOICE_FILE); @@ -60,12 +92,32 @@ void PaymentManagementService::saveInvoices() 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() { 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() { util::saveObservers(config::file::PAYMENTMANAGEMENTOBSERVERS, this); -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index eeb3e65..5eff646 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -8,6 +8,15 @@ #include "Config.h" #include "Utility.h" +/* +Function: getObserverIDs +Description: Retrieves the IDs of all observers currently attached to the + ServiceManagementService. +Parameters: + - None +Returns: + - util::Vector: Vector of observer user IDs +*/ util::Vector ServiceManagementService::getObserverIDs() { util::Vector observerIDs; @@ -23,6 +32,17 @@ util::Vector ServiceManagementService::getObserverIDs() 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() { util::FileManager serviceFileManager(config::file::SERVICE_FILE); @@ -49,6 +69,15 @@ 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() { util::FileManager serviceFileManager(config::file::SERVICE_FILE); @@ -56,6 +85,17 @@ void ServiceManagementService::saveServices() 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() { util::FileManager comboPackageFileManager(config::file::COMBOPACKAGE_FILE); @@ -82,6 +122,15 @@ 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() { util::FileManager comboPackageFileManager(config::file::COMBOPACKAGE_FILE); @@ -89,6 +138,19 @@ void ServiceManagementService::saveComboPackages() 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() { util::FileManager bookingFileManager(config::file::SERVICEBOOKING_FILE); @@ -143,6 +205,15 @@ 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() { util::FileManager bookingFileManager(config::file::SERVICEBOOKING_FILE); @@ -150,6 +221,20 @@ void ServiceManagementService::saveServiceBookings() 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() { util::FileManager jobCardFileManager(config::file::JOBCARD_FILE); @@ -193,6 +278,16 @@ void ServiceManagementService::loadJobCards() 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() { util::FileManager jobCardFileManager(config::file::JOBCARD_FILE); @@ -200,12 +295,32 @@ void ServiceManagementService::saveJobCards() 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() { 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() { util::saveObservers(config::file::SERVICEMANAGEMENTOBSERVERS, this); -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 8731484..124f46d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -4,6 +4,18 @@ #include "Notification.h" #include "Config.h" +/* +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() { util::FileManager userFileManager(config::file::USER_FILE); @@ -31,6 +43,15 @@ 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() { util::FileManager userFileManager(config::file::USER_FILE); @@ -49,4 +70,4 @@ void UserManagementService::saveUsers() } userFileManager.save(users); notificationFileManager.save(notifications); -} +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h index b9990b2..3a532b1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileHelper.h @@ -1,3 +1,12 @@ +/* +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 #include #include @@ -6,6 +15,17 @@ 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: Vector containing all records (excluding header) + Throws: + - None (creates file if missing) + */ inline util::Vector loadRecords(const std::string& filePath) { util::Vector records; @@ -30,6 +50,18 @@ namespace util 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&, 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& records) { std::ofstream file(filePath, std::ios::trunc); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h index f3b0de5..d84bbfd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/FileManager.h @@ -1,3 +1,14 @@ +/* +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 #include #include @@ -20,6 +31,18 @@ namespace util void save(const objects&); }; + /* + 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 containing deserialized objects + Throws: + - std::runtime_error if deserialization fails for any record + */ template objects FileManager::load() { @@ -57,6 +80,17 @@ namespace util 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&, map of objects to save + Returns: + - void + Throws: + - std::runtime_error if the file cannot be opened for writing + */ template void FileManager::save(const objects& records) { diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h index 64f657c..0d7839a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/StringHelper.h @@ -1,8 +1,26 @@ +/* +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 #include 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) { int result = 0; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h index f3a895f..da6c0c3 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -1,3 +1,13 @@ +/* +File: ObserversHelper.h +Description: Provides utility functions for loading and saving observers + in the notification management system. Ensures that observer + IDs are validated against existing users in the datastore + before attaching them to the notification service. +Author: Trenser +Date: 22-May-2026 +*/ + #pragma once #include "NotificationManagementService.h" #include "FileHelper.h" @@ -5,6 +15,20 @@ namespace util { + /* + 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) { auto observerIDs = util::loadRecords(filePath); @@ -21,6 +45,16 @@ 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) { auto observerIDs = service->getObserverIDs(); From 014d4eaa0d6ba002333dd3b6dd2f5942b6718472 Mon Sep 17 00:00:00 2001 From: Jissin Mathew Date: Fri, 22 May 2026 17:12:47 +0530 Subject: [PATCH 19/20] Align enum string values with actual State names --- .../Trenser.VehicleServiceSystem/utilities/Enums.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h index 24bbdcd..3e0185e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Enums.h @@ -147,9 +147,9 @@ namespace util switch (status) { case State::ACTIVE: - return "STARTED"; + return "ACTIVE"; case State::INACTIVE: - return "COMPLETED"; + return "INACTIVE"; } throw std::invalid_argument("Invalid State"); } @@ -160,7 +160,7 @@ namespace util { return State::ACTIVE; } - if (value == "COMPLETED") + if (value == "INACTIVE") { return State::INACTIVE; } From 1e8fd2829fd8019105fa61d667acf1021055b8e2 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Mon, 25 May 2026 15:46:11 +0530 Subject: [PATCH 20/20] Fix PR review comments and refactor menu helper logic Changes: - Added name parameter to createTechnician for consistency - Added function headers for notification-related methods in InventoryManagementService - Used variables for notification title and message instead of passing strings directly - Fixed payment reminder notification message formatting - Moved common helper functions to MenuHelper.h - Updated CustomerMenu to use shared helper functions instead of duplicate code - Added missing includes in MenuHelper.h - Removed redundant helper code from CustomerMenu.cpp - Minor formatting and comment cleanup --- .../controllers/Controller.cpp | 3 +- .../controllers/Controller.h | 2 +- .../services/InventoryManagementService.cpp | 56 +++++- .../services/PaymentManagementService.cpp | 7 +- .../services/ServiceManagementService.cpp | 12 +- .../views/CustomerMenu.cpp | 145 +-------------- .../views/CustomerMenu.h | 1 + .../views/MenuHelper.h | 173 ++++++++++++++++++ .../views/UserInterface.cpp | 1 + 9 files changed, 240 insertions(+), 160 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index b0c4802..b0a1c25 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -55,6 +55,7 @@ Parameter: const std::string& username - customer 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) { m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER); @@ -71,7 +72,7 @@ const User* Controller::getAuthenticatedUser() return m_authenticationManagementService.getAuthenticatedUser(); } -void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone) +void Controller::createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone) { } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 1b534ea..1cb9603 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -43,7 +43,7 @@ public: 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); const User* getAuthenticatedUser(); - void createTechnician(const std::string& username, 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& phone); void updateUserDetails(const std::string& email, const std::string& phone); util::Map getServices(); util::Map getComboPackages(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 6f675eb..dd702bc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -22,6 +22,14 @@ Date: 22-May-2026 util::Map InventoryManagementService::m_observers{}; +/* +Function: attach +Description: Adds a user to the observer list for receiving inventory notifications. +Parameters: + - user: User*, pointer to the user to be attached as an observer +Returns: + - None +*/ void InventoryManagementService::attach(User* user) { if (user) @@ -34,6 +42,14 @@ 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) { if (user) @@ -46,6 +62,18 @@ 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) { if (user) @@ -72,20 +100,39 @@ 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&, list of admin users to notify +Returns: + - None +*/ static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector& adminUsers) { int adminUsersSize = adminUsers.getSize(); 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( adminUsers[index], - "Low Stock Alert", - "The inventory item with ID " + inventoryItem->getId() + - " has very low quantity in the inventory" - ); + title, + message + ); } } +/* +Function: sendLowStockAlerts +Description: Sends alerts to user for inventory items with low stock +Parameters: + - None +Returns: + - None +*/ void InventoryManagementService::sendLowStockAlerts() { auto& inventoryItems = m_dataStore.getInventoryItems(); @@ -116,7 +163,6 @@ void InventoryManagementService::sendLowStockAlerts() } } - /* Function: getObserverIDs Description: Retrieves the IDs of all observers currently attached to the diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index b7946bf..7cdd80a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -19,7 +19,6 @@ Date: 20-May-2026 #include "User.h" #include "Utility.h" - util::Map PaymentManagementService::m_observers{}; /* @@ -128,9 +127,9 @@ void PaymentManagementService::sendPaymentReminders() User* customer = serviceBooking->getCustomer(); if (customer) { - sendNotification(customer, - "Payment Reminder", - "Your payment for Invoice ID " + invoice->getId() + " is still pending.Please complete the payment." + invoice->getId()); + std::string title = "Payment Reminder"; + std::string message = "Your payment for Invoice ID " + invoice->getId() + " is still pending. Please complete the payment."; + sendNotification(customer, title, message); } } } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index e958839..54210e8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -60,9 +60,9 @@ void ServiceManagementService::purchaseService(const util::Vector& throw std::runtime_error("Failed to create service booking"); } serviceBookingMap[serviceBooking->getId()] = serviceBooking; - sendNotification(authenticatedUser, - "Service Booking succeeded", - "Your service booking has been successfully placed with ID " + serviceBooking->getId()); + std::string title = "Service Booking succeeded"; + std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId(); + sendNotification(authenticatedUser, title, message); } /* @@ -99,9 +99,9 @@ void ServiceManagementService::purchaseComboPackage(const std::string& comboPack throw std::runtime_error("Failed to create combo package service booking"); } serviceBookingMap[serviceBooking->getId()] = serviceBooking; - sendNotification(authenticatedUser, - "Combo Package Service Booking succeeded", - "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId()); + std::string title = "Combo Package Service Booking succeeded"; + std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId(); + sendNotification(authenticatedUser, title, message); } util::Map ServiceManagementService::m_observers{}; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 213fb0d..dbbf27c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -15,7 +15,6 @@ Date:19-May-2026 #include "MenuHelper.h" #include "OutputHelper.h" #include "Service.h" -#include "Utility.h" #include "Validator.h" #include "Vector.h" @@ -25,6 +24,7 @@ Description: Displays the customer menu and handles user input until logout is s Parameter: None Return type: void */ + void CustomerMenu::showMenu() { while (true) @@ -125,19 +125,7 @@ Return type: void */ void CustomerMenu::changePassword() { - 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(); + changePasswordHelper(m_controller); } /* @@ -171,55 +159,6 @@ void CustomerMenu::updateDetails() util::pressEnter(); } -/* -Function: selectServiceFromServices -Description: Displays active services and allows the customer to select one by index. -Parameter: const util::Map& services - list of services -Return type: const Service* - selected service -*/ -static const Service* selectServiceFromServices(const util::Map& services) -{ - util::Map 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: selectService Description: Allows the customer to select a service, provide vehicle details, @@ -253,54 +192,6 @@ void CustomerMenu::selectService() util::pressEnter(); } -/* -Function: selectComboPackageFromPackages -Description: Displays active combo packages and allows the customer to select one by index. -Parameter: const util::Map& comboPackages - list of combo packages -Return type: const ComboPackage* - selected combo package -*/ -static const ComboPackage* selectComboPackageFromPackages(const util::Map& comboPackages) -{ - util::Map 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: selectComboPackage Description: Allows the customer to select a combo package, provide vehicle details, @@ -357,38 +248,6 @@ void CustomerMenu::viewNotifications() 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 diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h index 3dbb439..d491720 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h @@ -7,6 +7,7 @@ Description: Header file declaring the CustomerMenu class, which provides Author: Trenser Date:19-May-2026 */ + #pragma once #include "Controller.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index 3dfbeba..0bb708b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -16,6 +16,10 @@ Date: 21-May-2026 #include "Notification.h" #include "OutputHelper.h" #include "Vector.h" +#include "Validator.h" +#include "Service.h" +#include "ComboPackage.h" +#include "Utility.h" /* Function: selectNotification @@ -112,3 +116,172 @@ inline void viewAndDeleteNotification(Controller& controller) controller.deleteNotification(selectedNotification->getId()); 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& services - list of services +Return type: const Service* - selected service +*/ +inline const Service* selectServiceFromServices(const util::Map& services) +{ + util::Map 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& comboPackages - list of combo packages +Return type: const ComboPackage* - selected combo package +*/ +inline const ComboPackage* selectComboPackageFromPackages(const util::Map& comboPackages) +{ + util::Map 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&, 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(); + } +} + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 4f91641..04f240f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -5,6 +5,7 @@ Description: Implementation file containing the method definitions of the and customer registration logic. Author: Trenser Date:19-May-2026 + */ #include "UserInterface.h" #include "InputHelper.h"