fix: cleanup and small improvements

- added empty check in inventory alerts
- corrected parts cost calculation
- removed unused getUser method
- updated default admin password
- fixed missing includes in menus
- cleaned up MenuHelper comments
This commit is contained in:
Jissin Mathew
2026-05-25 20:14:01 +05:30
parent 9ee392ab3c
commit 19acbed1fd
7 changed files with 21 additions and 40 deletions
@@ -59,6 +59,10 @@ Returns:
void InventoryManagementService::sendLowStockAlerts()
{
auto& inventoryItems = m_dataStore.getInventoryItems();
if (inventoryItems.isEmpty())
{
return;
}
int inventoryItemsSize = inventoryItems.getSize();
auto& usersMap = m_dataStore.getUsers();
int usersMapSize = usersMap.getSize();
@@ -315,7 +315,7 @@ void PaymentManagementService::generateInvoice(ServiceBooking* booking)
{
createInventoryItemsMap(completeInventoryItemMapOfBooking, currentService);
totalLabourCost += currentService->getLaborCost();
totalPartsCost += calculatePartsCost(currentService);
totalPartsCost += util::calculatePartsCost(currentService);
}
}
totalServiceCost = totalLabourCost + totalPartsCost;
@@ -305,18 +305,4 @@ util::Map<std::string, User*> UserManagementService::getUsers(util::UserType typ
}
}
return filteredUsersMap;
}
User* UserManagementService::getUser(const std::string& userID)
{
util::Map<std::string, User*>& currentUsers = m_dataStore.getUsers();
for (int iterator = 0; iterator < currentUsers.getSize(); iterator++)
{
User* currentUser = currentUsers.getValueAt(iterator);
if (currentUser->getId() == userID)
{
return currentUser;
}
}
return nullptr;
}
}
@@ -15,7 +15,7 @@ namespace config
{
constexpr const char* DEFAULT_ADMIN_USERNAME = "admin";
constexpr const char* DEFAULT_ADMIN_NAME = "admin";
constexpr const char* DEFAULT_ADMIN_PASSWORD = "";
constexpr const char* DEFAULT_ADMIN_PASSWORD = "admin";
constexpr const char* DEFAULT_ADMIN_EMAIL = "admin@vss";
constexpr const char* DEFAULT_ADMIN_PHONE = "0000000000";
}
@@ -10,6 +10,7 @@ Date: 19-May-2026
#include <iomanip>
#include <iostream>
#include "AdminMenu.h"
#include "Enums.h"
#include "InputHelper.h"
#include "InventoryItem.h"
@@ -10,8 +10,10 @@ Date:19-May-2026
#include <iomanip>
#include "ComboPackage.h"
#include "CustomerMenu.h"
#include "MenuHelper.h"
#include "Enums.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "InventoryItem.h"
#include "Invoice.h"
#include "Map.h"
@@ -29,9 +29,8 @@ Date: 21-May-2026
#include "Validator.h"
#include "Vector.h"
/*
Function: selectServicesToRemove (static helper)
Function: selectServicesToRemove
Description: Allows selection of a service to remove by index.
Parameters:
- currentServices: util::Map<std::string, const Service*>, available services
@@ -84,7 +83,7 @@ inline std::string selectServicesToRemove(util::Map<std::string, const Service*>
}
/*
Function: selectInventoryItems (static helper)
Function: selectInventoryItems
Description: Allows selection of inventory items by index for creating a service.
Parameters:
- currentInventoryItems: util::Map<std::string, const InventoryItem*>&, available inventory items
@@ -158,7 +157,7 @@ static void selectInventoryItems(util::Map<std::string, const InventoryItem*>& c
}
/*
Function: listServiceBookings (static helper)
Function: listServiceBookings
Description: Lists all pending service bookings and maps them to indices for selection.
Parameters:
- currentBookings: util::Map<std::string, const ServiceBooking*>&, current bookings
@@ -214,7 +213,7 @@ static bool listServiceBookings(util::Map<std::string, const ServiceBooking*>& c
}
/*
Function: selectPendingServiceBookings (static helper)
Function: selectPendingServiceBookings
Description: Allows selection of a pending service booking by index.
Parameters:
- serviceBookingsMap: util::Map<int, const ServiceBooking*>&, map of indexed bookings
@@ -238,7 +237,7 @@ static const ServiceBooking* selectPendingServiceBookings(util::Map<int, const S
}
/*
Function: listAvailableTechnicians (static helper)
Function: listAvailableTechnicians
Description: Lists all available technicians and maps them to indices for selection.
Parameters:
- currentAvailableTechnicians: util::Map<std::string, const User*>, available technicians
@@ -278,7 +277,7 @@ static void listAvailableTechnicians(util::Map<std::string, const User*> current
}
/*
Function: selectTechnician (static helper)
Function: selectTechnician
Description: Allows selection of a technician by index.
Parameters:
- currentAvailableTechniciansMap: util::Map<int, const User*>&, map of indexed technicians
@@ -301,7 +300,7 @@ static const User* selectTechnician(util::Map<int, const User*>& currentAvailabl
}
/*
Function: selectInvoiceFromUserForPayment (static helper)
Function: selectInvoiceFromUserForPayment
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
@@ -366,7 +365,7 @@ static std::string selectInvoiceFromUserForPayment(const util::Map<std::string,
}
/*
Function: selectPaymentMode (static helper)
Function: selectPaymentMode
Description: Allows the customer to select a payment mode (ONLINE or OFFLINE).
Parameters:
- None
@@ -396,7 +395,7 @@ static util::PaymentMode selectPaymentMode()
}
/*
Function: displayInvoices (static helper)
Function: displayInvoices
Description: Displays detailed information for all invoices associated with the customer,
including booking details, technician, discount, total amount, payment status, and items used.
Parameters:
@@ -464,7 +463,7 @@ static void displayInvoices(util::Map<std::string, const Invoice*> currentUserIn
}
/*
Function: selectJobCardToComplete (static helper)
Function: selectJobCardToComplete
Description: Lists all incomplete job cards assigned to the technician and allows selection by index.
Parameters:
- assignedJobCards: util::Map<std::string, const JobCard*>&, job cards assigned to the technician
@@ -801,18 +800,7 @@ inline const ComboPackage* selectComboPackageFromPackages(const util::Map<std::s
}
/*
Function: sendLowStockAlertsToAdmins (static helper)
Description: Sends low stock alert notifications to all admin users for a given inventory item.
Parameters:
- inventoryManagementService: InventoryManagementService&, service used to send notifications
- inventoryItem: const InventoryItem*, pointer to the low-stock inventory item
- adminUsers: const util::Vector<User*>&, list of admin users to notify
Returns:
- None
*/
/*
Function: getNotificationPreference (static helper)
Function: getNotificationPreference
Description: Helper function to configure notification preferences for a specific service.
Parameters:
- serviceName: Name of the service for which notifications are being configured.