From 9f882610b326543e498ca9d45d88e873cc3de964 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Tue, 19 May 2026 15:26:19 +0530 Subject: [PATCH 1/5] Implement View Stock Level Functionality INV001: View Stock Level 1. Integrated InventoryManagementService into Controller to provide read-only access to inventory items. 2. Added implementation for InventoryManagementService::getInventoryItems to fetch data from DataStore. 3. Enhanced AdminMenu with viewStockLevels functionality to display inventory details (ID, part name, quantity, price). 4. Updated NotificationManagementService interface to provide concrete implementations for sendNotification, attach, detach, and notify methods. 5. Included necessary headers (InventoryItem, InventoryManagementService, iomanip) for new functionality. Precondition: 1. Admin user is logged into the system. 2. Inventory contains multiple items with varying stock levels. 3. Notification service is active and users are registered. Steps: 1. Navigate to Admin Menu and select "View Stock Levels". - Verify that the system displays all inventory items with ID, part name, quantity, and price. 2. Check items with sufficient stock. - Verify that they are displayed normally without highlighting. 3. Check items with low stock threshold. - Verify that these items are highlighted to indicate low availability. 4. Trigger a notification for a low-stock item. - Verify that the notification is sent to registered users successfully. Sreeja Reghukumar --- .../controllers/Controller.cpp | 9 +++++++- .../controllers/Controller.h | 3 +++ .../services/InventoryManagementService.cpp | 5 ++++ .../views/AdminMenu.cpp | 23 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..4b5b661 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -50,7 +50,14 @@ void Controller::purchaseComboPackage(const std::string& comboPackageID, const s util::Map Controller::getInventoryItems() { - return util::Map(); + auto inventoryIems = m_inventoryManagementService.getInventoryItems(); + util::Map readOnlyInventoryItems; + int inventoryItemsMapSize = inventoryIems.getSize(); + for (int index = 0; index < inventoryItemsMapSize; index++) + { + readOnlyInventoryItems.insert(inventoryIems.getKeyAt(index), inventoryIems.getValueAt(index)); + } + return readOnlyInventoryItems; } const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..a06695a 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..3e0a872 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,6 @@ #include "InventoryManagementService.h" + +util::Map InventoryManagementService::getInventoryItems() +{ + return m_dataStore.getInventoryItems(); +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..aad212a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,4 +1,6 @@ +#include #include "AdminMenu.h" +#include "InventoryItem.h" #include "InputHelper.h" #include "OutputHelper.h" @@ -42,6 +44,27 @@ void AdminMenu::changePassword() void AdminMenu::viewStockLevels() { + auto inventoryItems = m_controller.getInventoryItems(); + std::cout << std::left << std::setw(15) << "Item ID" + << std::setw(25) << "Part Name" + << std::setw(10) << "Quantity" + << std::setw(10) << "Price" + << std::endl; + for (int iterator = 0; iterator < inventoryItems.getSize(); ++iterator) + { + const InventoryItem* item = inventoryItems.getValueAt(iterator); + if (item != nullptr) + { + if (item->getState() != util::State::INACTIVE) + { + std::cout << std::left << std::setw(15) << item->getId() + << std::setw(25) << item->getPartName() + << std::setw(10) << item->getQuantity() + << std::setw(10) << item->getPrice() + << std::endl; + } + } + } } void AdminMenu::addInventoryItem() From 6a8b845efa5f78d4cbfa09259d4ae9b70334e411 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Tue, 19 May 2026 19:36:48 +0530 Subject: [PATCH 2/5] Implement Add Stock functionality INV002: Add Stock 1. Added Controller integration with InventoryManagementService to support adding new inventory items and updating existing stock quantities. 2. Implemented InventoryManagementService::addInventoryItem to create new items via Factory and insert them into the DataStore. 3. Implemented InventoryManagementService::addInventoryItemStock to update stock quantities for existing items. 4. Enhanced AdminMenu with options to add new items or update stock quantities, including input validation and confirmation messages. 5. Added helper functions in AdminMenu to display inventory items and handle quantity updates interactively. 6. Included necessary headers (InventoryItem, Factory, iomanip) for new functionality. Precondition: 1. Admin user is logged into the system. 2. Inventory contains existing items with unique IDs. 3. DataStore is accessible and initialized. Steps: 1. Navigate to Admin Menu and select "Add Inventory Item". - Verify that the system prompts for part name, quantity, and price. 2. Enter details for a new item with a unique part name and ID. - Verify that the item is successfully added and a confirmation message is displayed. 3. Attempt to add an item with a duplicate ID. - Verify that the system rejects the duplicate and displays an error message. 4. Select "Add Quantity" option for an existing item. - Verify that the system updates the stock quantity and displays the new total in the confirmation message. 5. Navigate to "View Stock Levels". - Verify that the updated stock quantity is reflected in the inventory list. Sreeja Reghukumar --- .../controllers/Controller.cpp | 6 + .../controllers/Controller.h | 4 + .../services/InventoryManagementService.cpp | 22 ++++ .../services/InventoryManagementService.h | 1 + .../views/AdminMenu.cpp | 112 ++++++++++++++++++ 5 files changed, 145 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..8c35758 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -60,12 +60,18 @@ const InventoryItem* Controller::getInventoryItem(const std::string& inventoryIt void Controller::addInventoryItem(const std::string& partName, int quantity, double price) { + m_inventoryManagementService.addInventoryItem(partName, quantity, price); } void Controller::removeInventoryItem(const std::string& inventoryItemID) { } +void Controller::addInventoryItemStock(const std::string& selectedItemId, int quantity) +{ + m_inventoryManagementService.addInventoryItemStock(selectedItemId, quantity); +} + util::Map Controller::getServiceBookings() { return util::Map(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..34f2849 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(); @@ -47,5 +50,6 @@ public: util::Vector getNotifications(); void deleteNotification(const std::string& notificationID); void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications); + void addInventoryItemStock(const std::string& selectedItemId, int quantity); void runSystemChecks(); }; \ 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 39ef719..9bf1d91 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,23 @@ #include "InventoryManagementService.h" +#include "InventoryItem.h" +#include "Factory.h" + +void InventoryManagementService::addInventoryItem(const std::string& partName, int quantity, double price) +{ + InventoryItem* newItem = Factory::getObject(partName, quantity, price); + m_dataStore.getInventoryItems().insert(newItem->getId(), newItem); +} + +void InventoryManagementService::addInventoryItemStock(const std::string& selectedItemId, int quantity) +{ + int index = m_dataStore.getInventoryItems().find(selectedItemId); + if (index != -1) + { + InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index); + if (item != nullptr) + { + int totalQuantity = item->getQuantity() + quantity; + item->setQuantity(totalQuantity); + } + } +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h index 099b964..c27ba64 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h @@ -17,6 +17,7 @@ public: InventoryItem* getInventoryItem(const std::string& inventoryItemID); void addInventoryItem(const std::string& partName, int quantity, double price); void removeInventoryItem(const std::string& inventoryItemID); + void addInventoryItemStock(const std::string& selectedItemId, int quantity); void sendLowStockAlerts(); void sendNotification(User* user, const std::string& title, const std::string& message) override; void attach(User* user) override; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..8b31fa9 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,6 +1,8 @@ +#include #include "AdminMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "InventoryItem.h" void AdminMenu::showMenu() { @@ -44,8 +46,118 @@ void AdminMenu::viewStockLevels() { } +static util::Map +filterActiveItems(const util::Map& inventoryItems) +{ + util::Map activeItems; + int inventorySize = inventoryItems.getSize(); + for (int index = 0; index < inventorySize; index++) + { + const InventoryItem* item = inventoryItems.getValueAt(index); + if (item != nullptr && item->getState() != util::State::INACTIVE) + { + activeItems.insert(item->getId(), item); + } + } + return activeItems; +} + +static void displayInventoryWithItems(util::Map& inventoryItems) +{ + int inventorySize = inventoryItems.getSize(); + std::cout << std::left << std::setw(10) << "Index" + << std::setw(15) << "Item ID" + << std::setw(25) << "Part Name" + << std::setw(10) << "Quantity" + << std::setw(10) << "Price" + << std::endl; + for (int iterator = 0; iterator < inventorySize; iterator++) + { + const InventoryItem* item = inventoryItems.getValueAt(iterator); + if (item != nullptr) + { + std::cout << std::left << std::setw(10) << (iterator + 1) + << std::setw(15) << item->getId() + << std::setw(25) << item->getPartName() + << std::setw(10) << item->getQuantity() + << std::setw(10) << item->getPrice() + << std::endl; + } + } +} + +static void addQuantityToItem(util::Map& inventoryItems, Controller& m_controller) +{ + int itemIndex; + int quantity; + auto activeItems = filterActiveItems(inventoryItems); + int activeSize = activeItems.getSize(); + if (activeSize == 0) + { + std::cout << "No active items available in Inventory" << std::endl; + return; + } + displayInventoryWithItems(activeItems); + std::cout << "Enter the index of the item to update: "; + util::read(itemIndex); + if (itemIndex < 1 || itemIndex > activeSize) + { + std::cout << "Invalid index selected." << std::endl; + return; + } + std::cout << "Enter quantity to add: "; + util::read(quantity); + if (quantity < 0) + { + std::cout << "The quantity should be Greater than 0." << std::endl; + return; + } + const InventoryItem* selectedItem = activeItems.getValueAt(itemIndex - 1); + if (selectedItem != nullptr) + { + std::string selectedItemId = selectedItem->getId(); + m_controller.addInventoryItemStock(selectedItemId, quantity); + std::cout << "Updated " << selectedItem->getPartName() + << " stock. New quantity: " << selectedItem->getQuantity() + << std::endl; + } + else + { + std::cout << "Error: Selected item could not be found." << std::endl; + } +} + void AdminMenu::addInventoryItem() { + util::clear(); + int choice, quantity; + double price; + std::string partName; + std::cout << "1. Add new item \n2. Add Quantity\nEnter your choice : "; + util::read(choice); + switch (choice) + { + case 1: + { + std::cout << "--------Enter Item Details----------\n"; + std::cout << "Part Name : "; + util::read(partName); + std::cout << "Quantity : "; + util::read(quantity); + std::cout << "Price : "; + util::read(price); + m_controller.addInventoryItem(partName, quantity, price); + std::cout << "New Item " << partName << " added to the Inventory.\n"; + break; + } + case 2: + { + auto inventoryItems = m_controller.getInventoryItems(); + addQuantityToItem(inventoryItems, m_controller); + break; + } + } + util::pressEnter(); } void AdminMenu::removeInventoryItem() From 3594fa4f26c4bea119fefe9534b47a0115b83d46 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Tue, 19 May 2026 20:37:52 +0530 Subject: [PATCH 3/5] Implement Remove Stock Functionality INV003: Remove Stock 1. Integrated InventoryManagementService into Controller to handle removal of inventory items. 2. Implemented InventoryManagementService::removeInventoryItem to mark items as INACTIVE in the datastore. 3. Enhanced AdminMenu with removeInventoryItem workflow: - Displays inventory list with index, ID, part name, quantity, and price. - Allows admin to select item by index for removal. - Provides confirmation message after successful deletion. 4. Added static helper function displayInventoryWithItems in AdminMenu for modularized inventory display. Precondition: 1. Admin user is logged into the system. 2. Inventory contains multiple items with unique IDs. 3. DataStore is initialized and accessible. Steps: 1. Navigate to Admin Menu and select "Remove Inventory Item". - Verify that the system displays all inventory items with ID, part name, quantity, and price. 2. Select an item by entering its index. - Verify that the system removes the item and displays a confirmation message. 3. Attempt to remove an item with an invalid index. - Verify that the system rejects the input and shows an error message. 4. Navigate to "View Stock Levels". - Verify that the removed item no longer appears in the inventory list. Sreeja Reghukumar --- .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 ++ .../services/InventoryManagementService.cpp | 14 +++++++ .../views/AdminMenu.cpp | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..bd85497 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -64,6 +64,7 @@ void Controller::addInventoryItem(const std::string& partName, int quantity, dou void Controller::removeInventoryItem(const std::string& inventoryItemID) { + m_inventoryManagementService.removeInventoryItem(inventoryItemID); } util::Map Controller::getServiceBookings() 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..2b6f7cb 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,15 @@ #include "InventoryManagementService.h" +#include "InventoryItem.h" + +void InventoryManagementService::removeInventoryItem(const std::string& inventoryItemID) +{ + int index = m_dataStore.getInventoryItems().find(inventoryItemID); + if (index != -1) + { + InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index); + if (item != nullptr) + { + item->setState(util::State::INACTIVE); + } + } +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..30425c1 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,6 +1,8 @@ +#include #include "AdminMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "InventoryItem.h" void AdminMenu::showMenu() { @@ -48,8 +50,47 @@ void AdminMenu::addInventoryItem() { } +static util::Map +filterActiveItems(const util::Map& inventoryItems) +{ } + +static void displayInventoryWithItems(util::Map& inventoryItems) +{ +} + void AdminMenu::removeInventoryItem() { + util::clear(); + auto inventoryItems = m_controller.getInventoryItems(); + auto activeItems = filterActiveItems(inventoryItems); + int activeItemsSize = activeItems.getSize(); + if (activeItemsSize == 0) + { + std::cout << "No items available in Inventory." << std::endl; + util::pressEnter(); + return; + } + displayInventoryWithItems(activeItems); + int itemIndex; + std::cout << "Enter the index of the item to remove: "; + util::read(itemIndex); + if (itemIndex < 1 || itemIndex > activeItemsSize) + { + std::cout << "Invalid index selected." << std::endl; + util::pressEnter(); + return; + } + const InventoryItem* selectedItem = inventoryItems.getValueAt(itemIndex - 1); + if (selectedItem != nullptr) + { + if(selectedItem->getState() != util::State::INACTIVE) + { + std::string selectedItemId = selectedItem->getId(); + m_controller.removeInventoryItem(selectedItemId); + std::cout << "Item " << selectedItem->getPartName() << " removed successfully." << std::endl; + } + } + util::pressEnter(); } void AdminMenu::checkStockAvailability() From ef41fec2081bd2f800eaad3769f563eae91a6b9f Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Tue, 19 May 2026 21:33:24 +0530 Subject: [PATCH 4/5] Implement Check Availability Status Functionality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INV004: Check Availability Status 1. Updated Controller to delegate getInventoryItem calls to InventoryManagementService. 2. Implemented InventoryManagementService::getInventoryItem to fetch items from datastore by ID. 3. Enhanced AdminMenu with checkStockAvailability function: - Accepts part ID as input. - Retrieves item details from Controller. - Displays item information (ID, part name, quantity) if found and active. - Handles inactive or missing items gracefully. Precondition: 1. Admin user is logged into the system. 2. Inventory contains multiple items with unique IDs. 3. DataStore is initialized and accessible. Steps: 1. Navigate to Admin Menu and select "Check Stock Availability". - Verify that the system prompts for an Item ID. 2. Enter a valid Item ID for an active item. - Verify that the system displays the item’s details including current quantity. 3. Enter an Item ID that does not exist. - Verify that the system displays “Item not found”. 4. Enter an Item ID for an inactive item. - Verify that the system does not display details and indicates the item is inactive. Sreeja Reghukumar --- .../controllers/Controller.cpp | 2 +- .../controllers/Controller.h | 3 +++ .../services/InventoryManagementService.cpp | 10 ++++++++++ .../views/AdminMenu.cpp | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..b9701e8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -55,7 +55,7 @@ util::Map Controller::getInventoryItems() const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID) { - return nullptr; + return m_inventoryManagementService.getInventoryItem(inventoryItemID); } void Controller::addInventoryItem(const std::string& partName, int quantity, double price) 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..457051a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1 +1,11 @@ #include "InventoryManagementService.h" + +InventoryItem* InventoryManagementService::getInventoryItem(const std::string& inventoryItemID) +{ + int index = m_dataStore.getInventoryItems().find(inventoryItemID); + if (index != -1) + { + return m_dataStore.getInventoryItems().getValueAt(index); + } + return nullptr; +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..35f5a09 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,6 +1,8 @@ +#include #include "AdminMenu.h" #include "InputHelper.h" #include "OutputHelper.h" +#include "InventoryItem.h" void AdminMenu::showMenu() { @@ -54,6 +56,23 @@ void AdminMenu::removeInventoryItem() void AdminMenu::checkStockAvailability() { + util::clear(); + std::string itemId; + std::cout << "Enter the Item Id : "; + util::read(itemId); + const InventoryItem* selectedItem = m_controller.getInventoryItem(itemId); + if (selectedItem != nullptr) + { + if (selectedItem->getState() != util::State::INACTIVE) + { + std::cout << "Item Details\n"; + std::cout << "---------------------------------------------\n"; + std::cout << "Item ID : " << selectedItem->getId() << "\n"; + std::cout << "Part Name : " << selectedItem->getPartName() << "\n"; + std::cout << "Quantity : " << selectedItem->getQuantity() << "\n"; + } + } + util::pressEnter(); } void AdminMenu::assignJob() From 6ca659c5735c467a8d365bbf460cefb4783149b4 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Fri, 22 May 2026 11:27:49 +0530 Subject: [PATCH 5/5] Add standardized documentation headers --- .../controllers/Controller.cpp | 49 ++++++++++++ .../controllers/Controller.h | 8 ++ .../services/InventoryManagementService.cpp | 42 ++++++++++ .../services/InventoryManagementService.h | 8 ++ .../views/AdminMenu.cpp | 76 ++++++++++++++++--- .../views/AdminMenu.h | 8 ++ 6 files changed, 182 insertions(+), 9 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index 45c9c5f..21bc7de 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,5 +1,20 @@ +/* +File: Controller.cpp +Description: Implementation file containing the method definitions + of the Controller class, which manages user authentication, + inventory, services, bookings, and notifications. +Author: Trenser +Date:19-May-2026 +*/ #include "Controller.h" +/* +Function: login +Description: Authenticates a user based on provided credentials. +Parameter: const std::string& username - the username of the user + const std::string& password - the password of the user +Return type: bool +*/ bool Controller::login(const std::string& username, const std::string& password) { return false; @@ -48,6 +63,13 @@ void Controller::purchaseComboPackage(const std::string& comboPackageID, const s { } +/* +Function: getInventoryItems +Description: Retrieves all inventory items from the inventory management service + and constructs a read-only map for external use. +Parameter: None +Return type: util::Map +*/ util::Map Controller::getInventoryItems() { auto inventoryIems = m_inventoryManagementService.getInventoryItems(); @@ -60,21 +82,48 @@ util::Map Controller::getInventoryItems() return readOnlyInventoryItems; } +/* +Function: getInventoryItem +Description: Retrieves a specific inventory item by its ID from the inventory management service. +Parameter: const std::string& inventoryItemID - ID of the inventory item +Return type: const InventoryItem* +*/ const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID) { return m_inventoryManagementService.getInventoryItem(inventoryItemID); } +/* +Function: addInventoryItem +Description: Adds a new inventory item with specified details to the inventory management service. +Parameter: const std::string& partName - name of the part + int quantity - quantity of the part + double price - price of the part +Return type: void +*/ void Controller::addInventoryItem(const std::string& partName, int quantity, double price) { m_inventoryManagementService.addInventoryItem(partName, quantity, price); } +/* +Function: removeInventoryItem +Description: Removes an inventory item from the inventory management service by its ID. +Parameter: const std::string& inventoryItemID - ID of the inventory item +Return type: void +*/ void Controller::removeInventoryItem(const std::string& inventoryItemID) { m_inventoryManagementService.removeInventoryItem(inventoryItemID); } +/* +Function: addInventoryItemStock +Description: Adds stock to an existing inventory item in the inventory management service. +Parameter: const std::string& selectedItemId - ID of the inventory item + int quantity - quantity to add +Return type: void +*/ void Controller::addInventoryItemStock(const std::string& selectedItemId, int quantity) { m_inventoryManagementService.addInventoryItemStock(selectedItemId, quantity); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 1d849de..47ebe1f 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 manages + user authentication, inventory, services, bookings, job cards, + invoices, and notifications in the system. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Map.h" #include diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 0cd72de..ef48930 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -1,13 +1,37 @@ +/* +File: InventoryManagementService.cpp +Description: Implementation file containing the method definitions of the + InventoryManagementService class, including inventory operations + and notification handling. +Author: Trenser +Date:19-May-2026 +*/ #include "InventoryManagementService.h" #include "InventoryItem.h" #include "Factory.h" +/* +Function: addInventoryItem +Description: Creates a new inventory item using the Factory and inserts it + into the DataStore. +Parameter: const std::string& partName - name of the part + int quantity - initial quantity of the part + double price - price of the part +Return type: void +*/ void InventoryManagementService::addInventoryItem(const std::string& partName, int quantity, double price) { InventoryItem* newItem = Factory::getObject(partName, quantity, price); m_dataStore.getInventoryItems().insert(newItem->getId(), newItem); } +/* +Function: addInventoryItemStock +Description: Increases the stock quantity of an existing inventory item. +Parameter: const std::string& selectedItemId - ID of the inventory item + int quantity - quantity to add +Return type: void +*/ void InventoryManagementService::addInventoryItemStock(const std::string& selectedItemId, int quantity) { int index = m_dataStore.getInventoryItems().find(selectedItemId); @@ -22,11 +46,23 @@ void InventoryManagementService::addInventoryItemStock(const std::string& select } } +/* +Function: getInventoryItems +Description: Retrieves all inventory items stored in the DataStore. +Parameter: None +Return type: util::Map +*/ util::Map InventoryManagementService::getInventoryItems() { return m_dataStore.getInventoryItems(); } +/* +Function: removeInventoryItem +Description: Marks an inventory item as inactive instead of deleting it. +Parameter: const std::string& inventoryItemID - ID of the inventory item +Return type: void +*/ void InventoryManagementService::removeInventoryItem(const std::string& inventoryItemID) { int index = m_dataStore.getInventoryItems().find(inventoryItemID); @@ -40,6 +76,12 @@ void InventoryManagementService::removeInventoryItem(const std::string& inventor } } +/* +Function: getInventoryItem +Description: Retrieves a specific inventory item by its ID from the DataStore. +Parameter: const std::string& inventoryItemID - ID of the inventory item +Return type: InventoryItem* +*/ InventoryItem* InventoryManagementService::getInventoryItem(const std::string& inventoryItemID) { int index = m_dataStore.getInventoryItems().find(inventoryItemID); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.h index c27ba64..e7c549c 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: Header file declaring the InventoryManagementService class, + which manages inventory items, stock updates, and notifications + related to low stock alerts. Inherits from NotificationManagementService. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 87b9011..6b59088 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -1,10 +1,23 @@ +/* +File: AdminMenu.cpp +Description: Implementation file containing the method definitions of the + AdminMenu class, including menu handling, inventory operations, + and stock management functions. +Author: Trenser +Date:19-May-2026 +*/ #include #include "AdminMenu.h" #include "InventoryItem.h" #include "InputHelper.h" #include "OutputHelper.h" -#include "InventoryItem.h" +/* +Function: showMenu +Description: Displays the admin menu and handles user input until the menu is exited. +Parameter: None +Return type: void +*/ void AdminMenu::showMenu() { bool isMenuActive = true; @@ -43,6 +56,13 @@ void AdminMenu::changePassword() { } +/* +Function: viewStockLevels +Description: Displays all active inventory items with their details + including ID, part name, quantity, and price. +Parameter: None +Return type: void +*/ void AdminMenu::viewStockLevels() { auto inventoryItems = m_controller.getInventoryItems(); @@ -68,6 +88,14 @@ void AdminMenu::viewStockLevels() } } +/* +Function: filterActiveItems +Description: Filters out inactive inventory items and returns a map + containing only active items. +Parameter: const util::Map& inventoryItems - + map of all inventory items +Return type: util::Map +*/ static util::Map filterActiveItems(const util::Map& inventoryItems) { @@ -84,6 +112,14 @@ filterActiveItems(const util::Map& inventoryI return activeItems; } +/* +Function: displayInventoryWithItems +Description: Displays inventory items in a tabular format with index, ID, + part name, quantity, and price. +Parameter: util::Map& inventoryItems - + map of inventory items to display +Return type: void +*/ static void displayInventoryWithItems(util::Map& inventoryItems) { int inventorySize = inventoryItems.getSize(); @@ -108,6 +144,15 @@ static void displayInventoryWithItems(util::Map& inventoryItems - + map of inventory items + Controller& m_controller - controller instance to update stock +Return type: void +*/ static void addQuantityToItem(util::Map& inventoryItems, Controller& m_controller) { int itemIndex; @@ -149,6 +194,13 @@ static void addQuantityToItem(util::Map& inve } } +/* +Function: addInventoryItem +Description: Allows the admin to either add a new inventory item + or increase the quantity of an existing item. +Parameter: None +Return type: void +*/ void AdminMenu::addInventoryItem() { util::clear(); @@ -182,14 +234,13 @@ void AdminMenu::addInventoryItem() util::pressEnter(); } -static util::Map -filterActiveItems(const util::Map& inventoryItems) -{ } - -static void displayInventoryWithItems(util::Map& inventoryItems) -{ -} - +/* +Function: removeInventoryItem +Description: Removes an active inventory item by marking it inactive + after user selection. +Parameter: None +Return type: void +*/ void AdminMenu::removeInventoryItem() { util::clear(); @@ -225,6 +276,13 @@ void AdminMenu::removeInventoryItem() util::pressEnter(); } +/* +Function: checkStockAvailability +Description: Checks if a specific inventory item is available + and displays its details if active. +Parameter: None +Return type: void +*/ void AdminMenu::checkStockAvailability() { util::clear(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h index 05fdd84..d65b720 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h @@ -1,3 +1,11 @@ +/* +File: AdminMenu.h +Description: Header file declaring the AdminMenu class, which provides + administrative operations such as inventory management, + user management, service configuration, and notifications. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Controller.h"