Implement Check Availability Status Functionality

<UserStory> INV004: Check Availability Status </UserStory>

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

<Test>

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

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

<Review>
Sreeja Reghukumar
</Review>
This commit is contained in:
Avinash Rajesh
2026-05-19 21:33:24 +05:30
parent 56c5c2dc70
commit ef41fec208
4 changed files with 33 additions and 1 deletions
@@ -55,7 +55,7 @@ util::Map<std::string, const InventoryItem*> 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)
@@ -2,6 +2,7 @@
#include "Map.h"
#include <string>
#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();
@@ -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;
}
@@ -1,6 +1,8 @@
#include <iomanip>
#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()