Compare commits

..

8 Commits

Author SHA1 Message Date
Avinash Rajesh 6ca659c573 Add standardized documentation headers 2026-05-22 11:27:49 +05:30
Avinash Rajesh 7e9cc27f1c Merge branch 'feature-inventory-management-inv004' into feature-inventory-management 2026-05-21 20:14:03 +05:30
Avinash Rajesh 1377d5fb39 Merge branch 'feature-inventory-management-inv003' into feature-inventory-management 2026-05-21 20:11:55 +05:30
Avinash Rajesh d33f0aa8dc Merge branch 'feature-inventory-management-inv002' into feature-inventory-management 2026-05-21 20:09:53 +05:30
Avinash Rajesh ef41fec208 Implement Check Availability Status Functionality
<UserStory> INV004: Check Availability Status </UserStory>

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

<Test>

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

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

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

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

<Test>

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

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

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

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

<Test>

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

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

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 15:00:59 +05:30
Avinash Rajesh 9f882610b3 Implement View Stock Level Functionality
<UserStory> INV001: View Stock Level </UserStory>

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

<Test>

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

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

<Review>
Sreeja Reghukumar
</Review>
2026-05-21 14:57:16 +05:30
18 changed files with 461 additions and 413 deletions
@@ -176,7 +176,6 @@
<ClInclude Include="utilities\Map.h" /> <ClInclude Include="utilities\Map.h" />
<ClInclude Include="utilities\OutputHelper.h" /> <ClInclude Include="utilities\OutputHelper.h" />
<ClInclude Include="utilities\Timestamp.h" /> <ClInclude Include="utilities\Timestamp.h" />
<ClInclude Include="utilities\Utility.h" />
<ClInclude Include="utilities\Validator.h" /> <ClInclude Include="utilities\Validator.h" />
<ClInclude Include="utilities\Vector.h" /> <ClInclude Include="utilities\Vector.h" />
<ClInclude Include="views\AdminMenu.h" /> <ClInclude Include="views\AdminMenu.h" />
@@ -233,8 +233,5 @@
<ClInclude Include="models\ComboPackage.h"> <ClInclude Include="models\ComboPackage.h">
<Filter>Header Files\Models</Filter> <Filter>Header Files\Models</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="utilities\Utility.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,7 +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" #include "Controller.h"
#include "User.h"
#include "Invoice.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) bool Controller::login(const std::string& username, const std::string& password)
{ {
return false; return false;
@@ -50,22 +63,70 @@ 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<std::string, const InventoryItem*>
*/
util::Map<std::string, const InventoryItem*> Controller::getInventoryItems() util::Map<std::string, const InventoryItem*> Controller::getInventoryItems()
{ {
return util::Map<std::string, const InventoryItem*>(); auto inventoryIems = m_inventoryManagementService.getInventoryItems();
util::Map<std::string, const InventoryItem*> readOnlyInventoryItems;
int inventoryItemsMapSize = inventoryIems.getSize();
for (int index = 0; index < inventoryItemsMapSize; index++)
{
readOnlyInventoryItems.insert(inventoryIems.getKeyAt(index), inventoryIems.getValueAt(index));
}
return readOnlyInventoryItems;
} }
/*
Function: getInventoryItem
Description: Retrieves a specific inventory item by its ID from the inventory management service.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: const InventoryItem*
*/
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID) const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
{ {
return nullptr; return m_inventoryManagementService.getInventoryItem(inventoryItemID);
} }
/*
Function: addInventoryItem
Description: Adds a new inventory item with specified details to the inventory management service.
Parameter: const std::string& partName - name of the part
int quantity - quantity of the part
double price - price of the part
Return type: void
*/
void Controller::addInventoryItem(const std::string& partName, int quantity, double price) void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
{ {
m_inventoryManagementService.addInventoryItem(partName, quantity, price);
} }
/*
Function: removeInventoryItem
Description: Removes an inventory item from the inventory management service by its ID.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: void
*/
void Controller::removeInventoryItem(const std::string& inventoryItemID) void Controller::removeInventoryItem(const std::string& inventoryItemID)
{ {
m_inventoryManagementService.removeInventoryItem(inventoryItemID);
}
/*
Function: addInventoryItemStock
Description: Adds stock to an existing inventory item in the inventory management service.
Parameter: const std::string& selectedItemId - ID of the inventory item
int quantity - quantity to add
Return type: void
*/
void Controller::addInventoryItemStock(const std::string& selectedItemId, int quantity)
{
m_inventoryManagementService.addInventoryItemStock(selectedItemId, quantity);
} }
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings() util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
@@ -121,40 +182,13 @@ void Controller::removeComboPackage(const std::string& comboPackageID)
{ {
} }
/*
Function: getInvoicesByUser
Description: Retrieves all invoices associated with the currently authenticated user.
Converts them into a read-only map before returning.
Parameters:
- None
Returns:
- util::Map<std::string, const Invoice*> containing the users invoices
*/
util::Map<std::string, const Invoice*> Controller::getInvoicesByUser() util::Map<std::string, const Invoice*> Controller::getInvoicesByUser()
{ {
User* currentUser = m_authenticationManagementService.getAuthenticatedUser(); return util::Map<std::string, const Invoice*>();
util::Map<std::string, Invoice*> currentUserInvoices = m_paymentManagementService.getInvoices(currentUser->getId());
util::Map<std::string, const Invoice*> userInvoicesReadOnly;
for (int iterator = 0; iterator < currentUserInvoices.getSize(); iterator++)
{
Invoice* currentInvoice = currentUserInvoices.getValueAt(iterator);
userInvoicesReadOnly.insert(currentInvoice->getId(), currentInvoice);
}
return userInvoicesReadOnly;
} }
/*
Function: completePayment
Description: Completes payment for a specific invoice using the given payment mode.
Parameters:
- invoiceID: std::string, ID of the invoice to be paid
- paymentMode: util::PaymentMode, mode of payment (e.g., ONLINE, OFFLINE)
Returns:
- void
*/
void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode) void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
{ {
m_paymentManagementService.completePayment(invoiceID, paymentMode);
} }
util::Vector<const Notification*> Controller::getNotifications() util::Vector<const Notification*> Controller::getNotifications()
@@ -173,3 +207,4 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
void Controller::runSystemChecks() void Controller::runSystemChecks()
{ {
} }
@@ -1,9 +1,16 @@
/*
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 #pragma once
#include "Map.h" #include "Map.h"
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
#include "PaymentManagementService.h" #include "InventoryManagementService.h";
#include "AuthenticationManagementService.h"
class Service; class Service;
class ComboPackage; class ComboPackage;
@@ -17,8 +24,7 @@ class Notification;
class Controller class Controller
{ {
private: private:
AuthenticationManagementService m_authenticationManagementService; InventoryManagementService m_inventoryManagementService;
PaymentManagementService m_paymentManagementService;
public: public:
bool login(const std::string& username, const std::string& password); bool login(const std::string& username, const std::string& password);
void logout(); void logout();
@@ -52,5 +58,6 @@ public:
util::Vector<const Notification*> getNotifications(); util::Vector<const Notification*> getNotifications();
void deleteNotification(const std::string& notificationID); void deleteNotification(const std::string& notificationID);
void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications); void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications);
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
void runSystemChecks(); void runSystemChecks();
}; };
@@ -16,8 +16,7 @@ Invoice::Invoice(
const std::string& bookingId, const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
const util::Timestamp& invoiceDate, const util::Timestamp& invoiceDate,
double laborCost, double laborCost, const util::Map<int,
const util::Map<std::string,
InventoryItem*>& parts, InventoryItem*>& parts,
double partsCost, double partsCost,
double discountPercentage, double discountPercentage,
@@ -64,7 +63,7 @@ double Invoice::getLaborCost() const
return m_laborCost; return m_laborCost;
} }
const util::Map<std::string, InventoryItem*>& Invoice::getParts() const const util::Map<int, InventoryItem*>& Invoice::getParts() const
{ {
return m_parts; return m_parts;
} }
@@ -124,7 +123,7 @@ void Invoice::setLaborCost(double laborCost)
m_laborCost = laborCost; m_laborCost = laborCost;
} }
void Invoice::setParts(const util::Map<std::string, InventoryItem*>& parts) void Invoice::setParts(const util::Map<int, InventoryItem*>& parts)
{ {
m_parts = parts; m_parts = parts;
} }
@@ -16,7 +16,7 @@ private:
ServiceBooking* m_booking; ServiceBooking* m_booking;
util::Timestamp m_invoiceDate; util::Timestamp m_invoiceDate;
double m_laborCost; double m_laborCost;
util::Map<std::string, InventoryItem*> m_parts; util::Map<int, InventoryItem*> m_parts;
double m_partsCost; double m_partsCost;
double m_discountPercentage; double m_discountPercentage;
double m_totalAmount; double m_totalAmount;
@@ -30,8 +30,8 @@ public:
const std::string& bookingId, const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
const util::Timestamp& invoiceDate, const util::Timestamp& invoiceDate,
double laborCost, double laborCost, const util::Map<int,
const util::Map<std::string,InventoryItem*>& parts, InventoryItem*>& parts,
double partsCost, double partsCost,
double discountPercentage, double discountPercentage,
double totalAmount, double totalAmount,
@@ -44,7 +44,7 @@ public:
ServiceBooking* getBooking() const; ServiceBooking* getBooking() const;
const util::Timestamp& getInvoiceDate() const; const util::Timestamp& getInvoiceDate() const;
double getLaborCost() const; double getLaborCost() const;
const util::Map<std::string, InventoryItem*>& getParts() const; const util::Map<int, InventoryItem*>& getParts() const;
double getPartsCost() const; double getPartsCost() const;
double getDiscountPercentage() const; double getDiscountPercentage() const;
double getTotalAmount() const; double getTotalAmount() const;
@@ -56,7 +56,7 @@ public:
void setBooking(ServiceBooking* booking); void setBooking(ServiceBooking* booking);
void setInvoiceDate(const util::Timestamp& invoiceDate); void setInvoiceDate(const util::Timestamp& invoiceDate);
void setLaborCost(double laborCost); void setLaborCost(double laborCost);
void setParts(const util::Map<std::string, InventoryItem*>& parts); void setParts(const util::Map<int, InventoryItem*>& parts);
void setPartsCost(double partsCost); void setPartsCost(double partsCost);
void setDiscountPercentage(double discountPercentage); void setDiscountPercentage(double discountPercentage);
void setTotalAmount(double totalAmount); void setTotalAmount(double totalAmount);
@@ -7,7 +7,7 @@ JobCard::JobCard()
m_booking(nullptr), m_booking(nullptr),
m_service(nullptr), m_service(nullptr),
m_technician(nullptr), m_technician(nullptr),
m_status(util::ServiceJobStatus()) {} m_status(ServiceJobStatus()) {}
JobCard::JobCard(const std::string& bookingId, JobCard::JobCard(const std::string& bookingId,
ServiceBooking* booking, ServiceBooking* booking,
@@ -16,7 +16,7 @@ JobCard::JobCard(const std::string& bookingId,
const std::string& technicianId, const std::string& technicianId,
User* technician, User* technician,
const util::Timestamp& assignedDate, const util::Timestamp& assignedDate,
util::ServiceJobStatus status, ServiceJobStatus status,
const util::Timestamp& completionDate const util::Timestamp& completionDate
) )
: m_id("JC" + std::to_string(++m_uid)), : m_id("JC" + std::to_string(++m_uid)),
@@ -70,7 +70,7 @@ const util::Timestamp& JobCard::getAssignedDate() const
return m_assignedDate; return m_assignedDate;
} }
util::ServiceJobStatus JobCard::getStatus() const ServiceJobStatus JobCard::getStatus() const
{ {
return m_status; return m_status;
} }
@@ -120,7 +120,7 @@ void JobCard::setAssignedDate(const util::Timestamp& assignedDate)
m_assignedDate = assignedDate; m_assignedDate = assignedDate;
} }
void JobCard::setStatus(util::ServiceJobStatus status) void JobCard::setStatus(ServiceJobStatus status)
{ {
m_status = status; m_status = status;
} }
@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h"
#include "Timestamp.h" #include "Timestamp.h"
class ServiceBooking; class ServiceBooking;
class Service; class Service;
class User; class User;
enum class ServiceJobStatus : int;
class JobCard class JobCard
{ {
@@ -20,7 +20,7 @@ private:
std::string m_technicianId; std::string m_technicianId;
User* m_technician; User* m_technician;
util::Timestamp m_assignedDate; util::Timestamp m_assignedDate;
util::ServiceJobStatus m_status; ServiceJobStatus m_status;
util::Timestamp m_completionDate; util::Timestamp m_completionDate;
public: public:
@@ -32,7 +32,7 @@ public:
const std::string& technicianId, const std::string& technicianId,
User* technician, User* technician,
const util::Timestamp& assignedDate, const util::Timestamp& assignedDate,
util::ServiceJobStatus status, ServiceJobStatus status,
const util::Timestamp& completionDate const util::Timestamp& completionDate
); );
const std::string& getId() const; const std::string& getId() const;
@@ -43,7 +43,7 @@ public:
const std::string& getTechnicianId() const; const std::string& getTechnicianId() const;
User* getTechnician() const; User* getTechnician() const;
const util::Timestamp& getAssignedDate() const; const util::Timestamp& getAssignedDate() const;
util::ServiceJobStatus getStatus() const; ServiceJobStatus getStatus() const;
const util::Timestamp& getCompletionDate() const; const util::Timestamp& getCompletionDate() const;
void setId(const std::string& id); void setId(const std::string& id);
void setBookingId(const std::string& bookingId); void setBookingId(const std::string& bookingId);
@@ -53,6 +53,6 @@ public:
void setTechnicianId(const std::string& technicianId); void setTechnicianId(const std::string& technicianId);
void setTechnician(User* technician); void setTechnician(User* technician);
void setAssignedDate(const util::Timestamp& assignedDate); void setAssignedDate(const util::Timestamp& assignedDate);
void setStatus(util::ServiceJobStatus status); void setStatus(ServiceJobStatus status);
void setCompletionDate(const util::Timestamp& completionDate); void setCompletionDate(const util::Timestamp& completionDate);
}; };
@@ -18,7 +18,7 @@ ServiceBooking::ServiceBooking(
const std::string& vehicleBrand, const std::string& vehicleBrand,
const std::string& vehicleModel, const std::string& vehicleModel,
const std::string& assignedTechnicianId, const std::string& assignedTechnicianId,
const User* assignedTechnician, const std::string& assignedTechnician,
double discountPercentage double discountPercentage
) )
: m_id("SRV" + std::to_string(++m_uid)), : m_id("SRV" + std::to_string(++m_uid)),
@@ -80,7 +80,7 @@ const std::string& ServiceBooking::getAssignedTechnicianId() const
return m_assignedTechnicianId; return m_assignedTechnicianId;
} }
const User* ServiceBooking::getAssignedTechnician() const const std::string& ServiceBooking::getAssignedTechnician() const
{ {
return m_assignedTechnician; return m_assignedTechnician;
} }
@@ -135,7 +135,7 @@ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnici
m_assignedTechnicianId = assignedTechnicianId; m_assignedTechnicianId = assignedTechnicianId;
} }
void ServiceBooking::setAssignedTechnician(const User* assignedTechnician) void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician)
{ {
m_assignedTechnician = assignedTechnician; m_assignedTechnician = assignedTechnician;
} }
@@ -19,7 +19,7 @@ private:
std::string m_vehicleBrand; std::string m_vehicleBrand;
std::string m_vehicleModel; std::string m_vehicleModel;
std::string m_assignedTechnicianId; std::string m_assignedTechnicianId;
const User* m_assignedTechnician; std::string m_assignedTechnician;
double m_discountPercentage; double m_discountPercentage;
public: public:
ServiceBooking(); ServiceBooking();
@@ -34,7 +34,7 @@ public:
const std::string& vehicleBrand, const std::string& vehicleBrand,
const std::string& vehicleModel, const std::string& vehicleModel,
const std::string& assignedTechnicianId, const std::string& assignedTechnicianId,
const User* assignedTechnician, const std::string& assignedTechnician,
double discountPercentage double discountPercentage
); );
const std::string& getId() const; const std::string& getId() const;
@@ -46,7 +46,7 @@ public:
const std::string& getVehicleBrand() const; const std::string& getVehicleBrand() const;
const std::string& getVehicleModel() const; const std::string& getVehicleModel() const;
const std::string& getAssignedTechnicianId() const; const std::string& getAssignedTechnicianId() const;
const User* getAssignedTechnician() const; const std::string& getAssignedTechnician() const;
double getDiscountPercentage() const; double getDiscountPercentage() const;
void setId(const std::string& id); void setId(const std::string& id);
void setStatus(const util::ServiceJobStatus& status); void setStatus(const util::ServiceJobStatus& status);
@@ -57,6 +57,6 @@ public:
void setVehicleBrand(const std::string& vehicleBrand); void setVehicleBrand(const std::string& vehicleBrand);
void setVehicleModel(const std::string& vehicleModel); void setVehicleModel(const std::string& vehicleModel);
void setAssignedTechnicianId(const std::string& assignedTechnicianId); void setAssignedTechnicianId(const std::string& assignedTechnicianId);
void setAssignedTechnician(const User* assignedTechnician); void setAssignedTechnician(const std::string& assignedTechnician);
void setDiscountPercentage(double discountPercentage); void setDiscountPercentage(double discountPercentage);
}; };
@@ -1 +1,93 @@
/*
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 "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<InventoryItem>(partName, quantity, price);
m_dataStore.getInventoryItems().insert(newItem->getId(), newItem);
}
/*
Function: addInventoryItemStock
Description: Increases the stock quantity of an existing inventory item.
Parameter: const std::string& selectedItemId - ID of the inventory item
int quantity - quantity to add
Return type: void
*/
void InventoryManagementService::addInventoryItemStock(const std::string& selectedItemId, int quantity)
{
int index = m_dataStore.getInventoryItems().find(selectedItemId);
if (index != -1)
{
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
if (item != nullptr)
{
int totalQuantity = item->getQuantity() + quantity;
item->setQuantity(totalQuantity);
}
}
}
/*
Function: getInventoryItems
Description: Retrieves all inventory items stored in the DataStore.
Parameter: None
Return type: util::Map<std::string, InventoryItem*>
*/
util::Map<std::string, InventoryItem*> InventoryManagementService::getInventoryItems()
{
return m_dataStore.getInventoryItems();
}
/*
Function: removeInventoryItem
Description: Marks an inventory item as inactive instead of deleting it.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: void
*/
void InventoryManagementService::removeInventoryItem(const std::string& inventoryItemID)
{
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
if (index != -1)
{
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
if (item != nullptr)
{
item->setState(util::State::INACTIVE);
}
}
}
/*
Function: getInventoryItem
Description: Retrieves a specific inventory item by its ID from the DataStore.
Parameter: const std::string& inventoryItemID - ID of the inventory item
Return type: InventoryItem*
*/
InventoryItem* InventoryManagementService::getInventoryItem(const std::string& inventoryItemID)
{
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
if (index != -1)
{
return m_dataStore.getInventoryItems().getValueAt(index);
}
return nullptr;
}
@@ -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 #pragma once
#include <string> #include <string>
#include "Map.h" #include "Map.h"
@@ -17,6 +25,7 @@ public:
InventoryItem* getInventoryItem(const std::string& inventoryItemID); InventoryItem* getInventoryItem(const std::string& inventoryItemID);
void addInventoryItem(const std::string& partName, int quantity, double price); void addInventoryItem(const std::string& partName, int quantity, double price);
void removeInventoryItem(const std::string& inventoryItemID); void removeInventoryItem(const std::string& inventoryItemID);
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
void sendLowStockAlerts(); void sendLowStockAlerts();
void sendNotification(User* user, const std::string& title, const std::string& message) override; void sendNotification(User* user, const std::string& title, const std::string& message) override;
void attach(User* user) override; void attach(User* user) override;
@@ -1,135 +1 @@
#include "PaymentManagementService.h" #include "PaymentManagementService.h"
#include "ServiceBooking.h"
#include "Service.h"
#include "InventoryItem.h"
#include "Utility.h"
#include "Factory.h"
#include "Timestamp.h"
#include "Invoice.h"
#include "JobCard.h"
#include "Enums.h"
/*
Function: createInventoryItemsMap (static helper)
Description: Builds a map of inventory items required for a given service and adds them to the bookings inventory map.
Parameters:
- completeInventoryItemMapOfBooking: util::Map<std::string, InventoryItem*>&, map to store inventory items for the booking
- currentService: const Service*, pointer to the current service
Returns:
- void
*/
static void createInventoryItemsMap(util::Map<std::string, InventoryItem*>& completeInventoryItemMapOfBooking, const Service* currentService)
{
auto& currentRequiredInventoryItems = currentService->getRequiredInventoryItems();
for (int iterator = 0; iterator < currentRequiredInventoryItems.getSize(); iterator++)
{
auto& currentRequiredInventoryItem = currentRequiredInventoryItems.getValueAt(iterator);
completeInventoryItemMapOfBooking.insert(currentRequiredInventoryItem->getId(), currentRequiredInventoryItem);
}
}
/*
Function: generateInvoice
Description: Generates an invoice for a completed service booking.
Validates that all job cards are completed, calculates labor and parts cost, applies discount,
and stores the invoice in the datastore.
Parameters:
- booking: ServiceBooking*, pointer to the service booking
Returns:
- void
Throws:
- std::runtime_error if booking is null or job cards are incomplete
*/
void PaymentManagementService::generateInvoice(ServiceBooking* booking)
{
if (!booking)
{
throw std::runtime_error("Invoice generation failed: booking is null.");
}
double totalLabourCost = 0, totalPartsCost = 0, totalServiceCost = 0;
double discountPercentage = booking->getDiscountPercentage();
std::string bookingID = booking->getId();
util::Map<std::string, Service*> servicesInTheBookedService = booking->getServices();
util::Map<std::string, InventoryItem*> completeInventoryItemMapOfBooking;
util::Map<std::string, JobCard*> currentJobCards = m_dataStore.getJobCards();
for (int iterator = 0; iterator < currentJobCards.getSize(); iterator++)
{
JobCard* currentJobCard = currentJobCards.getValueAt(iterator);
if (currentJobCard->getBookingId() == bookingID && currentJobCard->getStatus() != util::ServiceJobStatus::COMPLETED)
{
throw std::runtime_error("Invoice generation failed: not all job cards are completed for booking '" + bookingID + "'.");
}
}
for (int iterator = 0; iterator < servicesInTheBookedService.getSize(); iterator++)
{
Service* currentService = servicesInTheBookedService.getValueAt(iterator);
if (currentService)
{
createInventoryItemsMap(completeInventoryItemMapOfBooking, currentService);
totalLabourCost += currentService->getLaborCost();
totalPartsCost += calculatePartsCost(currentService);
}
}
totalServiceCost = totalLabourCost + totalPartsCost;
totalServiceCost -= (totalServiceCost * (discountPercentage / 100));
Invoice* invoice = Factory::getObject<Invoice>(bookingID, booking, util::Timestamp(), totalLabourCost, completeInventoryItemMapOfBooking, totalPartsCost, discountPercentage, totalServiceCost, util::Timestamp(), util::PaymentMode::NOTSET, util::PaymentStatus::PENDING);
util::Map<std::string, Invoice*>& currentInvoices = m_dataStore.getInvoices();
currentInvoices.insert(invoice->getId(), invoice);
}
/*
Function: getInvoices
Description: Retrieves all invoices associated with a specific customer.
Parameters:
- customerID: std::string, ID of the customer
Returns:
- util::Map<std::string, Invoice*> containing the customers invoices
*/
util::Map<std::string, Invoice*> PaymentManagementService::getInvoices(const std::string& customerID)
{
util::Map<std::string, Invoice*>& currentInvoices = m_dataStore.getInvoices();
util::Map<std::string, Invoice*> currentUserInvoices;
for (int iterator = 0; iterator < currentInvoices.getSize(); iterator++)
{
Invoice* currentInvoice = currentInvoices.getValueAt(iterator);
if (currentInvoice->getBooking()->getCustomerId() == customerID)
{
currentUserInvoices.insert(currentInvoice->getId(), currentInvoice);
}
}
return currentUserInvoices;
}
/*
Function: completePayment
Description: Completes payment for a specific invoice. Updates payment method, date, and status,
then sends a notification to the customer.
Parameters:
- invoiceID: std::string, ID of the invoice
- paymentMode: util::PaymentMode, mode of payment (e.g., ONLINE, OFFLINE)
Returns:
- void
Throws:
- std::runtime_error if the invoice ID is invalid
*/
void PaymentManagementService::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
{
auto& currentInvoices = m_dataStore.getInvoices();
int invoiceIndex = currentInvoices.find(invoiceID);
if (invoiceIndex != -1)
{
Invoice* invoice = currentInvoices.getValueAt(invoiceIndex);
User* currentUser = invoice->getBooking()->getCustomer();
invoice->setPaymentMethod(paymentMode);
invoice->setPaymentDate(util::Timestamp());
invoice->setStatus(util::PaymentStatus::COMPLETED);
std::string title, message;
title = "Payment successful";
message = "Payment successful for invoice ID " + invoiceID;
sendNotification(currentUser, title, message);
}
else
{
throw std::runtime_error("Payment failed: invalid invoice ID.");
}
}
@@ -13,8 +13,7 @@ namespace util
enum class PaymentMode enum class PaymentMode
{ {
ONLINE, ONLINE,
OFFLINE, OFFLINE
NOTSET
}; };
enum class PaymentStatus enum class PaymentStatus
@@ -74,8 +73,6 @@ namespace util
return "ONLINE"; return "ONLINE";
case PaymentMode::OFFLINE: case PaymentMode::OFFLINE:
return "OFFLINE"; return "OFFLINE";
case PaymentMode::NOTSET:
return "NOTSET";
} }
throw std::invalid_argument("Invalid PaymentMode"); throw std::invalid_argument("Invalid PaymentMode");
} }
@@ -1,15 +0,0 @@
#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;
}
@@ -1,7 +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 <iomanip>
#include "AdminMenu.h" #include "AdminMenu.h"
#include "InventoryItem.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.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() void AdminMenu::showMenu()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -40,20 +56,252 @@ 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() 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;
}
}
}
} }
/*
Function: filterActiveItems
Description: Filters out inactive inventory items and returns a map
containing only active items.
Parameter: const util::Map<std::string, const InventoryItem*>& inventoryItems -
map of all inventory items
Return type: util::Map<std::string, const InventoryItem*>
*/
static util::Map<std::string, const InventoryItem*>
filterActiveItems(const util::Map<std::string, const InventoryItem*>& inventoryItems)
{
util::Map<std::string, const InventoryItem*> 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;
}
/*
Function: displayInventoryWithItems
Description: Displays inventory items in a tabular format with index, ID,
part name, quantity, and price.
Parameter: util::Map<std::string, const InventoryItem*>& inventoryItems -
map of inventory items to display
Return type: void
*/
static void displayInventoryWithItems(util::Map<std::string, const InventoryItem*>& 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;
}
}
}
/*
Function: addQuantityToItem
Description: Allows the admin to select an active inventory item and
increase its stock quantity.
Parameter: util::Map<std::string, const InventoryItem*>& inventoryItems -
map of inventory items
Controller& m_controller - controller instance to update stock
Return type: void
*/
static void addQuantityToItem(util::Map<std::string, const InventoryItem*>& 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;
}
}
/*
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() 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();
} }
/*
Function: removeInventoryItem
Description: Removes an active inventory item by marking it inactive
after user selection.
Parameter: None
Return type: void
*/
void AdminMenu::removeInventoryItem() 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();
} }
/*
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() 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() void AdminMenu::assignJob()
@@ -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 #pragma once
#include "Controller.h" #include "Controller.h"
@@ -1,15 +1,6 @@
#include <iomanip>
#include <iostream>
#include "CustomerMenu.h" #include "CustomerMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "Invoice.h"
#include "Enums.h"
#include "ServiceBooking.h"
#include "User.h"
#include "Timestamp.h"
#include "Service.h"
#include "InventoryItem.h"
void CustomerMenu::showMenu() void CustomerMenu::showMenu()
{ {
@@ -64,197 +55,12 @@ void CustomerMenu::viewServiceHistory()
{ {
} }
/*
Function: selectInvoiceFromUserForPayment (static helper)
Description: Lists all pending invoices for the customer and allows selection by index.
Parameters:
- currentInvoices: util::Map<std::string, const Invoice*>&, map of customer invoices
Returns:
- std::string: ID of the selected invoice, or empty string if none selected
*/
static std::string selectInvoiceFromUserForPayment(const util::Map<std::string, const Invoice*>& currentInvoices)
{
int currentIndex = 1, choice;
util::Map<int, const Invoice*> pendingInvoicesForPayment;
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(12) << "BookingID"
<< std::setw(15) << "VehicleBrand"
<< std::setw(15) << "VehicleNumber"
<< std::setw(12) << "TechID"
<< std::setw(20) << "TechnicianName"
<< std::setw(10) << "Discount(%)"
<< std::setw(12) << "TotalAmount"
<< std::setw(20) << "InvoiceDate"
<< std::endl;
for (int iterator = 0; iterator < currentInvoices.getSize(); iterator++)
{
const Invoice* currentInvoice = currentInvoices.getValueAt(iterator);
if (currentInvoice && currentInvoice->getStatus() == util::PaymentStatus::PENDING)
{
std::cout << std::left
<< std::setw(6) << currentIndex
<< std::setw(12) << currentInvoice->getBookingId()
<< std::setw(15) << currentInvoice->getBooking()->getVehicleBrand()
<< std::setw(15) << currentInvoice->getBooking()->getVehicleNumber()
<< std::setw(12) << currentInvoice->getBooking()->getAssignedTechnician()->getId()
<< std::setw(20) << currentInvoice->getBooking()->getAssignedTechnician()->getName()
<< std::setw(10) << currentInvoice->getDiscountPercentage()
<< std::setw(12) << currentInvoice->getTotalAmount()
<< std::setw(20) << currentInvoice->getInvoiceDate().toString()
<< std::endl;
pendingInvoicesForPayment.insert(currentIndex++, currentInvoice);
}
}
if (pendingInvoicesForPayment.getSize() == 0)
{
std::cout << "No pending invoices available for payment.\n";
return "";
}
std::cout << "Select the Invoice to pay (Index): ";
util::read(choice);
int selectedIndex = pendingInvoicesForPayment.find(choice);
if (selectedIndex != -1)
{
const Invoice* selectedInvoice = pendingInvoicesForPayment.getValueAt(selectedIndex);
return selectedInvoice->getId();
}
else
{
std::cout << "Invalid choice.\n";
return "";
}
}
/*
Function: selectPaymentMode (static helper)
Description: Allows the customer to select a payment mode (ONLINE or OFFLINE).
Parameters:
- None
Returns:
- util::PaymentMode: Selected payment mode
*/
static util::PaymentMode selectPaymentMode()
{
int choice;
std::cout << "Enter the payment Mode\n1.OFFLINE\n2.ONLINE\nChoice: ";
util::read(choice);
if (choice == 1)
{
std::cout << "Offline mode selected.\n";
return util::PaymentMode::OFFLINE;
}
else if (choice == 2)
{
std::cout << "Online mode selected.\n";
return util::PaymentMode::ONLINE;
}
else
{
std::cout << "Invalid choice, Offline mode selected.\n";
return util::PaymentMode::OFFLINE;
}
}
/*
Function: completePayments
Description: Allows the customer to complete pending payments for invoices.
Validates invoice selection and payment mode before completing payment.
Parameters:
- None
Returns:
- void
*/
void CustomerMenu::completePayments() void CustomerMenu::completePayments()
{ {
util::clear();
util::Map<std::string, const Invoice*> currentInvoices = m_controller.getInvoicesByUser();
std::string selectedID = selectInvoiceFromUserForPayment(currentInvoices);
if (selectedID == "")
{
std::cout << "Payment failed.\n";
return;
}
util::PaymentMode paymentMode = selectPaymentMode();
m_controller.completePayment(selectedID, paymentMode);
std::cout << "Payment completed successfully.\n";
} }
/*
Function: displayInvoices (static helper)
Description: Displays detailed information for all invoices associated with the customer,
including booking details, technician, discount, total amount, payment status, and items used.
Parameters:
- currentUserInvoices: util::Map<std::string, const Invoice*>, customers invoices
Returns:
- void
Throws:
- std::runtime_error if a null invoice is encountered
*/
static void displayInvoices(util::Map<std::string, const Invoice*> currentUserInvoices)
{
if (currentUserInvoices.getSize() == 0)
{
std::cout << "No invoices found for this account." << std::endl;
util::pressEnter();
return;
}
else
{
for (int index = 0; index < currentUserInvoices.getSize(); index++)
{
const Invoice* currentInvoice = currentUserInvoices.getValueAt(index);
if (currentInvoice)
{
std::cout << "\nInvoice Details\n";
std::cout << "Booking ID: " << currentInvoice->getBookingId() << std::endl;
std::cout << "Vehicle Brand: " << currentInvoice->getBooking()->getVehicleBrand() << std::endl;
std::cout << "Vehicle Number: " << currentInvoice->getBooking()->getVehicleNumber() << std::endl;
std::cout << "Technician ID: " << currentInvoice->getBooking()->getAssignedTechnician()->getId() << std::endl;
std::cout << "Technician Name: " << currentInvoice->getBooking()->getAssignedTechnician()->getName() << std::endl;
std::cout << "Discount(%): " << currentInvoice->getDiscountPercentage() << std::endl;
std::cout << "Total Amount: " << currentInvoice->getTotalAmount() << std::endl;
std::cout << "Invoice Date: " << currentInvoice->getInvoiceDate().toString() << std::endl;
std::cout << "Payment Status: " << util::getPaymentStatusString(currentInvoice->getStatus()) << std::endl;
auto inventoryItemsInInvoice = currentInvoice->getParts();
std::cout << "\nItems Used:\n";
std::cout << std::left
<< std::setw(20) << "ItemName"
<< std::setw(10) << "Quantity"
<< std::setw(10) << "Price"
<< std::endl;
std::cout << std::string(40, '-') << std::endl;
for (int iterator = 0; iterator < inventoryItemsInInvoice.getSize(); iterator++)
{
InventoryItem* currentItem = inventoryItemsInInvoice.getValueAt(iterator);
std::cout << std::left
<< std::setw(20) << currentItem->getPartName()
<< std::setw(10) << currentItem->getQuantity()
<< std::setw(10) << currentItem->getPrice()
<< std::endl;
}
}
else
{
throw std::runtime_error("Null invoice encountered while displaying invoices.");
}
}
}
}
/*
Function: viewInvoices
Description: Displays invoices associated with the customer by calling displayInvoices.
Parameters:
- None
Returns:
- void
*/
void CustomerMenu::viewInvoices() void CustomerMenu::viewInvoices()
{ {
util::clear();
util::Map<std::string, const Invoice*> currentUserInvoices = m_controller.getInvoicesByUser();
displayInvoices(currentUserInvoices);
} }
void CustomerMenu::viewNotifications() void CustomerMenu::viewNotifications()