Fix Complete Payment Issue
- Added "Complete Payments" header in CustomerMenu::completePayments for clarity. - Implemented validation to check if invoices list is empty and display appropriate message. - Added logic to verify presence of pending invoices before proceeding with payment. - Enhanced error handling to show "Payment failed" with pressEnter prompt when no invoice is selected. - Updated selectInvoiceFromUserForPayment in MenuHelper.h: - Changed function to inline and added util::clear() at start. - Updated column headers to "Technician ID" and "Technician Name" for clarity. - Removed temporary AdminMenu.cpp file from enc_temp_folder. Fixes #1750
This commit is contained in:
@@ -308,11 +308,35 @@ Returns:
|
||||
void CustomerMenu::completePayments()
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Complete Payments\n";
|
||||
util::Map<std::string, const Invoice*> currentInvoices = m_controller.getInvoicesByUser();
|
||||
if (currentInvoices.isEmpty())
|
||||
{
|
||||
std::cout << "No pending invoices available for payment.\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
bool hasPending = false;
|
||||
for (int index = 0; index < currentInvoices.getSize(); ++index)
|
||||
{
|
||||
const Invoice* invoice = currentInvoices.getValueAt(index);
|
||||
if (invoice && invoice->getStatus() == util::PaymentStatus::PENDING)
|
||||
{
|
||||
hasPending = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasPending)
|
||||
{
|
||||
std::cout << "No pending invoices available for payment.\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
std::string selectedID = selectInvoiceFromUserForPayment(currentInvoices);
|
||||
if (selectedID == "")
|
||||
{
|
||||
std::cout << "Payment failed.\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
util::PaymentMode paymentMode = selectPaymentMode();
|
||||
|
||||
Reference in New Issue
Block a user