Compare commits

...

7 Commits

Author SHA1 Message Date
Avinash Rajesh 05b9fc7962 Merged PR 1200: Fix Customer Allowed to Create Service Bookings While Having Unpaid Invoices
Changes:
- Added verifyAllPaymentsCompleted() helper in MenuHelper.h to check if the authenticated customer has completed all invoices.
- Integrated payment verification into CustomerMenu::selectService() to block new service bookings when pending payments exist.
- Integrated payment verification into CustomerMenu::selectComboPackage() to block new combo package bookings when invoices are incomplete.
- Implemented iteration over customer invoices to ensure only users with all payments marked as COMPLETED can proceed with new bookings.
- Added user-facing messages to inform customers when bookings are denied due to outstanding payments.

Related work items: #2116
2026-06-18 19:55:12 +05:30
joelthomastrenser 956ef58c79 Implement review fixes 2026-06-18 19:54:12 +05:30
Jissin Mathew 32f1fa33ce Merged PR 1199: Fix Multiple Notifications Contain Formatting Issues, Vague Messaging, and Duplicate Entries
Changes:

- Updated ServiceManagementService::createJobCard() to prevent duplicate
  "Technician assigned" notifications when multiple job cards exist for
  the same booking.
- Refined job card creation notification to include Job Card ID, Service
  ID, and Booking ID for clearer technician communication.
- Corrected service booking cancellation notification formatting by
  standardizing capitalization and improving message clarity.
- Improved service booking completion notification to explicitly mention
  the booking ID and confirm invoice generation.
- Ensured consistent notification titles and messages across the
  workflow for better user understanding.

Fixes

#2114

Related work items: #2114
2026-06-18 19:44:35 +05:30
joelthomastrenser 976547e7d1 Merged PR 1201: Fix invoice display issues and improve combo package handling
**Changes**:

- Removed inventory quantity from invoice item display.
- Added null checks when displaying combo packages.
- Added null checks when selecting combo packages.
- Replaced unnecessary object copies with references.
- Zero-initialized SerializedObserver.
- Initialized event handle array before use.

Fixes
#2115

Related work items: #2115
2026-06-18 19:37:31 +05:30
joelthomastrenser 4fa143946e Fix combo package null handling and cleanup initialization
- Added null checks in combo package display/selection flows
- Replaced unnecessary copies with references
- Zero-initialized SerializedObserver
- Initialized event handle array
2026-06-18 19:31:18 +05:30
Avinash Rajesh bdb8431773 Customer Allowed to Create Service Bookings While Having Unpaid Invoices
- Added verifyAllPaymentsCompleted() helper in MenuHelper.h to check if the authenticated customer has completed all invoices.

- Integrated payment verification into CustomerMenu::selectService() to block new service bookings when pending payments exist.

- Integrated payment verification into CustomerMenu::selectComboPackage() to block new combo package bookings when invoices are incomplete.

- Implemented iteration over customer invoices to ensure only users with all payments marked as COMPLETED can proceed with new bookings.

- Added user-facing messages to inform customers when bookings are denied due to outstanding payments.

Fixes #2116
2026-06-18 19:26:45 +05:30
joelthomastrenser 931913fa30 Fix: remove inventory quantity from invoice display
- Removed Quantity column from invoice item listing
- Removed inventory stock quantity values from invoice output
- Display only item name and price in generated invoices

Fixes #2115
2026-06-18 19:20:02 +05:30
4 changed files with 87 additions and 27 deletions
@@ -358,7 +358,7 @@ util::Map<std::string, TrackedRecord<ServiceBooking>>& DataStore::getServiceBook
{
throw std::runtime_error("Invalid service index.");
}
auto currentService = services.getValueAt(serviceIndex);
auto& currentService = services.getValueAt(serviceIndex);
servicesInBooking[currentServiceId] = currentService.data;
}
serviceBooking->setServices(servicesInBooking);
@@ -369,7 +369,7 @@ util::Map<std::string, TrackedRecord<ServiceBooking>>& DataStore::getServiceBook
{
throw std::runtime_error("Invalid user index.");
}
auto customer = users.getValueAt(userIndex);
auto& customer = users.getValueAt(userIndex);
serviceBooking->setCustomer(customer.data);
}
if (!serviceBooking->getAssignedTechnicianId().empty())
@@ -379,7 +379,7 @@ util::Map<std::string, TrackedRecord<ServiceBooking>>& DataStore::getServiceBook
{
throw std::runtime_error("Invalid technician index.");
}
auto technician = users.getValueAt(technicianIndex);
auto& technician = users.getValueAt(technicianIndex);
serviceBooking->setAssignedTechnician(technician.data);
}
}
@@ -423,7 +423,7 @@ util::Map<std::string, TrackedRecord<JobCard>>& DataStore::getJobCards()
{
throw std::runtime_error("Invalid service ID: " + serviceId);
}
auto trackedService = services.getValueAt(serviceIndex);
auto& trackedService = services.getValueAt(serviceIndex);
jobCard->setService(trackedService.data);
const std::string& technicianId = jobCard->getTechnicianId();
if (!technicianId.empty())
@@ -433,7 +433,7 @@ util::Map<std::string, TrackedRecord<JobCard>>& DataStore::getJobCards()
{
throw std::runtime_error("Invalid technician ID: " + technicianId);
}
auto trackedTechnician = users.getValueAt(technicianIndex);
auto& trackedTechnician = users.getValueAt(technicianIndex);
jobCard->setTechnician(trackedTechnician.data);
}
}
@@ -691,7 +691,7 @@ void DataStore::saveObservers(MappingInfo& mapping, util::Map<std::string, User*
SharedMemory::setRecordCount(mapping, observerCount);
for (size_t index = 0; index < observerCount; index++)
{
SerializedObserver serializedObserver;
SerializedObserver serializedObserver{};
User* user = observers.getValueAt(static_cast<int>(index));
strcpy_s(serializedObserver.id, sizeof(serializedObserver.id), user->getId().c_str());
SerializedObserver* destination = static_cast<SerializedObserver*>(SharedMemory::getRecordAddress(mapping, index));
@@ -220,6 +220,13 @@ void CustomerMenu::selectService()
util::pressEnter();
return;
}
if (!verifyAllPaymentsCompleted(m_controller))
{
std::cout << "Your booking cannot be processed because you have pending payments for previous services. Please complete all outstanding invoices before booking a new service."
<< std::endl;
util::pressEnter();
return;
}
util::Vector<std::string> selectedServices;
const Service* selectedService = selectServiceFromServices(services);
if (selectedService == nullptr)
@@ -262,6 +269,13 @@ void CustomerMenu::selectComboPackage()
util::pressEnter();
return;
}
if (!verifyAllPaymentsCompleted(m_controller))
{
std::cout << "Your booking cannot be processed because you have pending payments for previous services. Please complete all outstanding invoices before booking a new combo package."
<< std::endl;
util::pressEnter();
return;
}
const ComboPackage* selectedComboPackage = selectComboPackageFromPackages(activeComboPackages);
if (selectedComboPackage == nullptr)
{
@@ -67,7 +67,7 @@ Return type: void
*/
void Menu::eventListenerLoop()
{
HANDLE handles[3];
HANDLE handles[3] = { NULL, NULL, NULL };
handles[0] = m_accountDisabledEvent;
handles[1] = m_notificationAvailableEvent;
handles[2] = m_shutdownEvent;
@@ -588,7 +588,7 @@ inline void displayInvoices(util::Map<std::string, const Invoice*> currentUserIn
<< util::getPaymentStatusString(selectedInvoice->getStatus()) << std::endl;
std::cout << std::left << std::setw(20) << "Payment Mode:"
<< util::getPaymentModeString(selectedInvoice->getPaymentMethod()) << std::endl;
auto inventoryItemsInInvoice = selectedInvoice->getParts();
auto& inventoryItemsInInvoice = selectedInvoice->getParts();
if (inventoryItemsInInvoice.isEmpty())
{
std::cout << "No inventory items used.\n\n";
@@ -597,7 +597,6 @@ inline void displayInvoices(util::Map<std::string, const Invoice*> currentUserIn
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;
@@ -606,7 +605,6 @@ inline void displayInvoices(util::Map<std::string, const Invoice*> currentUserIn
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;
}
@@ -1146,15 +1144,18 @@ inline void displayAllComboPackages(util::Map<std::string, const ComboPackage*>
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage && currentComboPackage->getState() != util::State::ACTIVE)
if (currentComboPackage)
{
continue;
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
std::cout << std::left
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(35) << util::truncateString(currentComboPackage->getPackageName(), 30)
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
}
std::cout << std::left
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(35) << util::truncateString(currentComboPackage->getPackageName(), 30)
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
}
}
@@ -1180,18 +1181,21 @@ inline const ComboPackage* selectComboPackageFromPackages(const util::Map<std::s
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage && currentComboPackage->getState() != util::State::ACTIVE)
if (currentComboPackage)
{
continue;
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(35) << util::truncateString(currentComboPackage->getPackageName(), 30)
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(35) << util::truncateString(currentComboPackage->getPackageName(), 30)
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
if (activeComboPackages.getSize() == 0)
{
@@ -1467,3 +1471,45 @@ inline void displayNewNotification(util::Vector<const Notification*> notificatio
MB_ICONINFORMATION);
}
}
/*
Function: verifyAllPaymentsCompleted
Description: Checks whether the authenticated customer has completed
all payments for their invoices. Iterates through all
invoices belonging to the customer and verifies that
each invoice has a payment status of COMPLETED.
Parameters: Controller& m_controller -
reference to the Controller object used to access
authenticated user and invoice data
Return type: bool
true if all invoices for the authenticated customer
are completed, false if any invoice is pending or not completed
Throws: std::runtime_error if no authenticated user is found
*/
inline bool verifyAllPaymentsCompleted(Controller& m_controller)
{
const User* authenticatedUser = m_controller.getAuthenticatedUser();
if (!authenticatedUser)
{
throw std::runtime_error("No authenticated user found.");
}
const std::string& authenticatedUserId = authenticatedUser->getId();
util::Map<std::string, const Invoice*> listOfInvoices = m_controller.getAllInvoices();
for (int invoiceIndex = 0; invoiceIndex < listOfInvoices.getSize(); ++invoiceIndex)
{
const Invoice* invoice = listOfInvoices.getValueAt(invoiceIndex);
if (!invoice)
{
continue;
}
const std::string& customerId = invoice->getBooking()->getCustomerId();
if (customerId == authenticatedUserId)
{
if (invoice->getStatus() != util::PaymentStatus::COMPLETED)
{
return false;
}
}
}
return true;
}