diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index c19e440..6292130 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -34,6 +34,14 @@ void Controller::updateUserDetails(const std::string& email, const std::string& { } +/* +Function: getServices +Description: Retrieves all available services in read-only form. +Parameters: + - None +Returns: + - util::Map containing all services +*/ util::Map Controller::getServices() { util::Map currentServices = m_serviceManagementService.getServices(); @@ -77,6 +85,14 @@ void Controller::removeInventoryItem(const std::string& inventoryItemID) { } +/* +Function: getServiceBookings +Description: Retrieves all service bookings in read-only form. +Parameters: + - None +Returns: + - util::Map containing service bookings +*/ util::Map Controller::getServiceBookings() { auto serviceBookings = m_serviceManagementService.getServiceBookings(); @@ -88,6 +104,14 @@ util::Map Controller::getServiceBookings() return readOnlyServiceBookings; } +/* +Function: getServiceBookingsByUser +Description: Retrieves all service bookings for a specific user. +Parameters: + - userID: std::string, the user ID +Returns: + - util::Map containing bookings for the user +*/ util::Map Controller::getServiceBookingsByUser(const std::string userID) { util::Map readOnlyServiceBookingsByUserMap; @@ -104,6 +128,14 @@ util::Map Controller::getUsers() return util::Map(); } +/* +Function: getUsers +Description: Retrieves users filtered by user type. +Parameters: + - userType: util::UserType, type of user (CUSTOMER, TECHNICIAN, ADMIN) +Returns: + - util::Map containing users of the specified type +*/ util::Map Controller::getUsers(util::UserType userType) { auto userMap = m_userManagementService.getUsers(userType); @@ -115,21 +147,57 @@ util::Map Controller::getUsers(util::UserType userType return readOnlyUserMap; } +/* +Function: createJobCard +Description: Creates a job card for a service booking assigned to a technician. +Parameters: + - bookingID: std::string, ID of the service booking + - technicianID: std::string, ID of the technician + - serviceID: std::string, ID of the service +Returns: + - void +*/ void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID) { m_serviceManagementService.createJobCard(bookingID, technicianID, serviceID); } +/* +Function: createService +Description: Creates a new service with associated inventory items and labor cost. +Parameters: + - name: std::string, name of the service + - inventoryItemIDs: Vector of inventory item IDs + - laborCost: double, labor cost +Returns: + - void +*/ void Controller::createService(const std::string& name, const util::Vector& inventoryItemIDs, double laborCost) { m_serviceManagementService.createService(name, inventoryItemIDs, laborCost); } +/* +Function: removeService +Description: Removes a service from the system by ID. +Parameters: + - serviceID: std::string, ID of the service +Returns: + - void +*/ void Controller::removeService(const std::string& serviceID) { m_serviceManagementService.removeService(serviceID); } +/* +Function: getJobCardsByUser +Description: Retrieves job cards assigned to the authenticated technician. +Parameters: + - None +Returns: + - util::Map containing job cards +*/ util::Map Controller::getJobCardsByUser() { const User* currentUser = getAuthenticatedUser(); @@ -143,6 +211,14 @@ util::Map Controller::getJobCardsByUser() return readOnlyJobCardMap; } +/* +Function: completeJob +Description: Marks a job card as completed. +Parameters: + - jobID: std::string, ID of the job card +Returns: + - void +*/ void Controller::completeJob(const std::string& jobID) { m_serviceManagementService.completeJob(jobID); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 4f67c0d..393fe8d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -12,11 +12,27 @@ #include "NotificationManagementService.h" #include "User.h" +/* +Function: getServiceBookings +Description: Retrieves all service bookings from the datastore. +Parameters: + - None +Returns: + - util::Map containing all service bookings +*/ util::Map ServiceManagementService::getServiceBookings() { return m_dataStore.getServiceBookings(); } +/* +Function: getServiceBooking +Description: Retrieves a specific service booking by its ID. +Parameters: + - serviceID: std::string, ID of the service booking +Returns: + - ServiceBooking*: Pointer to the service booking, or nullptr if not found +*/ ServiceBooking* ServiceManagementService::getServiceBooking(const std::string& serviceID) { auto currentServiceBookings = getServiceBookings(); @@ -30,6 +46,19 @@ ServiceBooking* ServiceManagementService::getServiceBooking(const std::string& s return nullptr; } +/* +Function: createJobCard +Description: Creates a job card for a given service booking, service, and technician. + Validates booking, service, technician, and inventory availability before creation. +Parameters: + - bookingID: std::string, ID of the service booking + - technicianID: std::string, ID of the technician + - serviceID: std::string, ID of the service +Returns: + - void +Throws: + - std::runtime_error if booking, service, technician, or inventory validation fails +*/ void ServiceManagementService::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID) { UserManagementService m_userManagementService; @@ -74,6 +103,19 @@ void ServiceManagementService::createJobCard(const std::string& bookingID, const sendNotification(selectedTechnician,title, message); } +/* +Function: createService +Description: Creates a new service with associated inventory items and labor cost. + Validates inventory items before creation. +Parameters: + - name: std::string, name of the service + - inventoryItemIDs: util::Vector, IDs of required inventory items + - laborCost: double, labor cost for the service +Returns: + - void +Throws: + - std::runtime_error if inventory items are not found or service creation fails +*/ void ServiceManagementService::createService(const std::string& name, const util::Vector& inventoryItemIDs, double laborCost) { util::Map currentServiceInventoryItems; @@ -110,11 +152,29 @@ void ServiceManagementService::createService(const std::string& name, const util currentServices.insert(newService->getId(), newService); } +/* +Function: getServices +Description: Retrieves all services from the datastore. +Parameters: + - None +Returns: + - util::Map containing all services +*/ util::Map ServiceManagementService::getServices() { return m_dataStore.getServices(); } +/* +Function: removeService +Description: Marks a service as inactive by its ID. +Parameters: + - serviceID: std::string, ID of the service +Returns: + - void +Throws: + - std::runtime_error if the service is not found +*/ void ServiceManagementService::removeService(const std::string& serviceID) { util::Map currentServices = getServices(); @@ -128,6 +188,14 @@ void ServiceManagementService::removeService(const std::string& serviceID) } } +/* +Function: getServiceBookings (overloaded) +Description: Retrieves all service bookings for a specific customer. +Parameters: + - customerID: std::string, ID of the customer +Returns: + - util::Map containing bookings for the customer +*/ util::Map ServiceManagementService::getServiceBookings(const std::string& customerID) { util::Map currentServiceBookings = getServiceBookings(); @@ -146,6 +214,14 @@ util::Map ServiceManagementService::getServiceBook return currentUserServiceBookings; } +/* +Function: getJobCards +Description: Retrieves all job cards assigned to a specific technician. +Parameters: + - technicianID: std::string, ID of the technician +Returns: + - util::Map containing job cards assigned to the technician +*/ util::Map ServiceManagementService::getJobCards(const std::string& technicianID) { util::Map jobCards = m_dataStore.getJobCards(); @@ -161,6 +237,15 @@ util::Map ServiceManagementService::getJobCards(const std return technicianJobCards; } +/* +Function: hasAllJobCardsinServiceBookingCompleted (static helper) +Description: Checks if all job cards for a given service booking are completed. +Parameters: + - bookingId: std::string, ID of the service booking + - currentAssignedJobs: util::Map&, map of assigned job cards +Returns: + - bool: True if all job cards are completed, False otherwise +*/ static bool hasAllJobCardsinServiceBookingCompleted(std::string bookingId, util::Map& currentAssignedJobs) { for (int iterator = 0; iterator < currentAssignedJobs.getSize(); iterator++) @@ -177,6 +262,18 @@ static bool hasAllJobCardsinServiceBookingCompleted(std::string bookingId, util: return true; } +/* +Function: completeJob +Description: Marks a job card as completed for the authenticated technician. + If all job cards in the booking are completed, marks the booking as completed + and generates an invoice. +Parameters: + - jobID: std::string, ID of the job card +Returns: + - void +Throws: + - std::runtime_error if technician is not authenticated, job card not found, or job already completed +*/ void ServiceManagementService::completeJob(const std::string& jobID) { AuthenticationManagementService authenticationManagementService; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index dd9b1fa..b539aa8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -62,6 +62,16 @@ void AdminMenu::checkStockAvailability() { } +/* +Function: listServiceBookings (static helper) +Description: Lists all pending service bookings and maps them to indices for selection. +Parameters: + - currentBookings: util::Map&, current bookings + - bookingsSize: int&, number of bookings + - serviceBookingsMap: util::Map&, map of indexed bookings +Returns: + - bool: True if pending services exist, False otherwise +*/ static bool listServiceBookings(util::Map& currentBookings, int& bookingsSize, util::Map& serviceBookingsMap) { int currentIndex = 1; @@ -107,6 +117,14 @@ static bool listServiceBookings(util::Map& c return true; } +/* +Function: selectPendingServiceBookings (static helper) +Description: Allows selection of a pending service booking by index. +Parameters: + - serviceBookingsMap: util::Map&, map of indexed bookings +Returns: + - const ServiceBooking*: Pointer to the selected booking, or nullptr if invalid +*/ static const ServiceBooking* selectPendingServiceBookings(util::Map& serviceBookingsMap) { int userInputIndex; @@ -123,6 +141,16 @@ static const ServiceBooking* selectPendingServiceBookings(util::Map, available technicians + - numberOfTechnicians: int, number of technicians + - currentAvailableTechniciansMap: util::Map&, map of indexed technicians +Returns: + - void +*/ static void listAvailableTechnicians( util::Map currentAvailableTechnicians, int numberOfTechnicians, util::Map& currentAvailableTechniciansMap) { bool hasTechnicians = false; @@ -153,6 +181,14 @@ static void listAvailableTechnicians( util::Map curren } } +/* +Function: selectTechnician (static helper) +Description: Allows selection of a technician by index. +Parameters: + - currentAvailableTechniciansMap: util::Map&, map of indexed technicians +Returns: + - const User*: Pointer to the selected technician, or nullptr if invalid +*/ static const User* selectTechnician(util::Map& currentAvailableTechniciansMap) { int userInputIndex; @@ -168,6 +204,15 @@ static const User* selectTechnician(util::Map& currentAvailabl } } +/* +Function: assignJob +Description: Allows the admin to assign pending service bookings to available technicians. + Creates job cards for selected services. +Parameters: + - None +Returns: + - void +*/ void AdminMenu::assignJob() { util::clear(); @@ -205,6 +250,15 @@ void AdminMenu::assignJob() } +/* +Function: selectInventoryItems (static helper) +Description: Allows selection of inventory items by index for creating a service. +Parameters: + - currentInventoryItems: util::Map&, available inventory items + - selectedInventoryItems: util::Vector&, vector to store selected item IDs +Returns: + - void +*/ static void selectInventoryItems(util::Map& currentInventoryItems, util::Vector& selectedInventoryItems) { bool doRun = true, hasInventoryItems = false; @@ -270,6 +324,14 @@ static void selectInventoryItems(util::Map& c } } +/* +Function: createService +Description: Allows the admin to create a new service by selecting inventory items and specifying labor cost. +Parameters: + - None +Returns: + - void +*/ void AdminMenu::createService() { util::clear(); @@ -286,6 +348,14 @@ void AdminMenu::createService() std::cout << "Service created sucessfully.\n"; } +/* +Function: selectServicesToRemove (static helper) +Description: Allows selection of a service to remove by index. +Parameters: + - currentServices: util::Map, available services +Returns: + - std::string: ID of the selected service, or empty string if invalid +*/ static std::string selectServicesToRemove(util::Map currentServices) { util::Map currentServicesMap; @@ -331,6 +401,14 @@ static std::string selectServicesToRemove(util::Map } } +/* +Function: removeService +Description: Allows the admin to remove an existing service by selecting from available services. +Parameters: + - None +Returns: + - void +*/ void AdminMenu::removeService() { util::clear(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index f2444b1..38c3090 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -55,6 +55,15 @@ void CustomerMenu::selectComboPackage() { } +/* +Function: viewServiceHistory +Description: Displays the customer’s past service bookings in tabular format, + including booking ID, technician, vehicle details, discount percentage, and status. +Parameters: + - None +Returns: + - void +*/ void CustomerMenu::viewServiceHistory() { util::clear(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index 2b94fe3..041877e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -35,6 +35,15 @@ bool TechnicianMenu::handleOperation(int choice) return false; } +/* +Function: selectJobCardToComplete (static helper) +Description: Lists all incomplete job cards assigned to the technician and allows selection by index. +Parameters: + - assignedJobCards: util::Map&, job cards assigned to the technician + - incompleteJobCards: util::Map&, map of incomplete job cards indexed for selection +Returns: + - std::string: ID of the selected job card, or empty string if none selected +*/ static std::string selectJobCardToComplete(util::Map& assignedJobCards, util::Map& incompleteJobCards) { int currentIndex = 1; @@ -82,6 +91,15 @@ static std::string selectJobCardToComplete(util::Map assignedJobCards = m_controller.getJobCardsByUser();