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:
@@ -327,39 +327,38 @@ 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::endl;
|
||||
std::cout << std::left
|
||||
<< 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++)
|
||||
{
|
||||
const Invoice* currentInvoice = currentInvoices.getValueAt(iterator);
|
||||
if (currentInvoice && currentInvoice->getStatus() == util::PaymentStatus::PENDING)
|
||||
{
|
||||
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() != "") ?
|
||||
currentTechnician->getId() : "Null")
|
||||
<< std::setw(20) << ((currentTechnician != nullptr && currentTechnician->getName() != "") ?
|
||||
currentTechnician->getName() : "Null")
|
||||
<< std::setw(10) << currentInvoice->getDiscountPercentage()
|
||||
<< std::setw(12) << currentInvoice->getTotalAmount()
|
||||
<< std::setw(20) << currentInvoice->getInvoiceDate().toString()
|
||||
<< std::endl;
|
||||
std::cout << std::left
|
||||
<< 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(25) << ((currentTechnician != nullptr && currentTechnician->getName() != "") ?
|
||||
currentTechnician->getName() : "Null")
|
||||
<< std::setw(15) << currentInvoice->getDiscountPercentage()
|
||||
<< std::setw(15) << currentInvoice->getTotalAmount()
|
||||
<< std::setw(22) << currentInvoice->getInvoiceDate().toString()
|
||||
<< std::endl;
|
||||
pendingInvoicesForPayment.insert(currentIndex++, currentInvoice);
|
||||
}
|
||||
}
|
||||
@@ -393,23 +392,27 @@ Returns:
|
||||
*/
|
||||
inline util::PaymentMode selectPaymentMode()
|
||||
{
|
||||
int choice;
|
||||
std::cout << "Enter the payment Mode\n1.OFFLINE\n2.ONLINE\nChoice: ";
|
||||
util::read(choice);
|
||||
if (choice == 1)
|
||||
int choice;
|
||||
while (true)
|
||||
{
|
||||
std::cout << "Offline mode selected.\n";
|
||||
return util::PaymentMode::OFFLINE;
|
||||
}
|
||||
else if (choice == 2)
|
||||
util::clear();
|
||||
std::cout << "Enter the payment Mode\n1.OFFLINE\n2.ONLINE\nChoice: ";
|
||||
util::read(choice);
|
||||
if (choice == 1)
|
||||
{
|
||||
std::cout << "Online mode selected.\n";
|
||||
return util::PaymentMode::ONLINE;
|
||||
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. Try again.\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Invalid choice. Offline mode selected.\n";
|
||||
return util::PaymentMode::OFFLINE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user