Fix: improve complete payments table formatting and payment mode validation

- Increased spacing between invoice table columns for better readability
- Updated invoice table headers with clearer labels
- Prevented screen clear before invoice listing display
- Changed payment mode selection to re-prompt on invalid input instead of defaulting to offline mode
- Removed unnecessary blank line before service listing display

Fixes #1786
This commit is contained in:
2026-05-27 13:02:40 +05:30
parent 83e2bed432
commit 67e5917a57
@@ -327,19 +327,18 @@ Returns:
*/
inline std::string selectInvoiceFromUserForPayment(const util::Map<std::string, const Invoice*>& currentInvoices)
{
util::clear();
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) << "Technician ID"
<< std::setw(20) << "Technician Name"
<< std::setw(10) << "Discount(%)"
<< std::setw(12) << "TotalAmount"
<< std::setw(20) << "InvoiceDate"
<< std::setw(8) << "Index"
<< std::setw(15) << "Booking ID"
<< std::setw(20) << "Vehicle Brand"
<< std::setw(20) << "Vehicle Number"
<< std::setw(18) << "Technician ID"
<< std::setw(25) << "Technician Name"
<< std::setw(15) << "Discount(%)"
<< std::setw(15) << "TotalAmount"
<< std::setw(22) << "Invoice Timestamp"
<< std::endl;
for (int iterator = 0; iterator < currentInvoices.getSize(); iterator++)
{
@@ -348,17 +347,17 @@ inline std::string selectInvoiceFromUserForPayment(const util::Map<std::string,
{
const User* currentTechnician = currentInvoice->getBooking()->getAssignedTechnician();
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) << ((currentTechnician != nullptr && currentTechnician->getId() != "") ?
<< std::setw(8) << currentIndex
<< std::setw(15) << currentInvoice->getBookingId()
<< std::setw(20) << currentInvoice->getBooking()->getVehicleBrand()
<< std::setw(20) << currentInvoice->getBooking()->getVehicleNumber()
<< std::setw(18) << ((currentTechnician != nullptr && currentTechnician->getId() != "") ?
currentTechnician->getId() : "Null")
<< std::setw(20) << ((currentTechnician != nullptr && currentTechnician->getName() != "") ?
<< std::setw(25) << ((currentTechnician != nullptr && currentTechnician->getName() != "") ?
currentTechnician->getName() : "Null")
<< std::setw(10) << currentInvoice->getDiscountPercentage()
<< std::setw(12) << currentInvoice->getTotalAmount()
<< std::setw(20) << currentInvoice->getInvoiceDate().toString()
<< std::setw(15) << currentInvoice->getDiscountPercentage()
<< std::setw(15) << currentInvoice->getTotalAmount()
<< std::setw(22) << currentInvoice->getInvoiceDate().toString()
<< std::endl;
pendingInvoicesForPayment.insert(currentIndex++, currentInvoice);
}
@@ -394,6 +393,9 @@ Returns:
inline util::PaymentMode selectPaymentMode()
{
int choice;
while (true)
{
util::clear();
std::cout << "Enter the payment Mode\n1.OFFLINE\n2.ONLINE\nChoice: ";
util::read(choice);
if (choice == 1)
@@ -408,8 +410,9 @@ inline util::PaymentMode selectPaymentMode()
}
else
{
std::cout << "Invalid choice. Offline mode selected.\n";
return util::PaymentMode::OFFLINE;
std::cout << "Invalid choice. Try again.\n";
util::pressEnter();
}
}
}
@@ -780,7 +783,6 @@ inline const Service* selectServiceFromServices(const util::Map<std::string, con
util::Map<int, const Service*> activeServicesMap;
int currentIndex = 1;
int userInputIndex;
std::cout << std::endl;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Service ID"