diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index 3d8e591..a4cfe33 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -327,39 +327,38 @@ Returns: */ inline std::string selectInvoiceFromUserForPayment(const util::Map& currentInvoices) { - util::clear(); int currentIndex = 1, choice; util::Map 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 activeServicesMap; int currentIndex = 1; int userInputIndex; - std::cout << std::endl; std::cout << std::left << std::setw(10) << "Index" << std::setw(15) << "Service ID"