Files
Jissin Mathew cb3bed4050 Implement Complete Payments
<UserStory> PAY002: Complete Payments </UserStory>

<Changes>
    1. Integrated Controller with PaymentManagementService to support payment completion workflow.
    2. Implemented PaymentManagementService::completePayment with validation for invoice ID, payment mode, and status update.
    3. Enhanced CustomerMenu with helper functions to display pending invoices in tabular format and allow index-based selection.
    4. Added CustomerMenu::selectPaymentMode to capture payment mode choice (OFFLINE/ONLINE).
    5. Updated CustomerMenu::completePayments to handle invoice selection, payment mode input, and trigger payment completion via Controller.
    6. Implemented notification logic to send confirmation to customers upon successful payment.
</Changes>

<Test>

 Acceptance Criteria:
 1. Payment status marked completed.
 2. Confirmation message shown.
 3. Confirmation notification sent.

 Precondition:
  1. Customer is logged into the system.
  2. At least one pending invoice exists for the customer.
  3. Datastore is available for storing invoices and updating payment status.

 Steps:
  1. Navigate to Customer menu and choose "Complete Payments".
    - Verify that the system lists pending invoices with tabular details.
  2. Select an invoice by index.
    - Verify that the chosen invoice is retrieved correctly.
  3. Enter payment mode (OFFLINE/ONLINE).
    - Verify that the selected mode is applied to the invoice.
  4. Confirm payment completion.
    - Verify that the invoice status changes to COMPLETED.
    - Verify that a confirmation message is displayed.
    - Verify that a notification is sent to the customer.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 15:08:25 +05:30

159 lines
4.2 KiB
C++

#include "Controller.h"
#include "User.h"
#include "Invoice.h"
bool Controller::login(const std::string& username, const std::string& password)
{
return false;
}
void Controller::logout()
{
}
void Controller::changePassword(const std::string& newPassword)
{
}
void Controller::createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
{
}
const User* Controller::getAuthenticatedUser()
{
return nullptr;
}
void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
{
}
void Controller::updateUserDetails(const std::string& email, const std::string& phone)
{
}
util::Map<std::string, const Service*> Controller::getServices()
{
return util::Map<std::string, const Service*>();
}
util::Map<std::string, const ComboPackage*> Controller::getComboPackages()
{
return util::Map<std::string, const ComboPackage*>();
}
void Controller::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{
}
void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
{
}
util::Map<std::string, const InventoryItem*> Controller::getInventoryItems()
{
return util::Map<std::string, const InventoryItem*>();
}
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
{
return nullptr;
}
void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
{
}
void Controller::removeInventoryItem(const std::string& inventoryItemID)
{
}
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
{
return util::Map<std::string, const ServiceBooking*>();
}
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookingsByUser(const std::string userID)
{
return util::Map<std::string, const ServiceBooking*>();
}
util::Map<std::string, const User*> Controller::getUsers()
{
return util::Map<std::string, const User*>();
}
util::Map<std::string, const User*> Controller::getUsers(util::UserType userType)
{
return util::Map<std::string, const User*>();
}
void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{
}
void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{
}
void Controller::removeService(const std::string& serviceID)
{
}
util::Map<std::string, const JobCard*> Controller::getJobCardsByUser()
{
return util::Map<std::string, const JobCard*>();
}
void Controller::completeJob(const std::string& jobID)
{
}
void Controller::removeUser(const std::string& userID)
{
}
void Controller::createComboPackage(const std::string& name, const util::Vector<std::string>& serviceIDs, double discountPercentage)
{
}
void Controller::removeComboPackage(const std::string& comboPackageID)
{
}
util::Map<std::string, const Invoice*> Controller::getInvoicesByUser()
{
User* currentUser = m_authenticationManagementService.getAuthenticatedUser();
util::Map<std::string, Invoice*> currentUserInvoices = m_paymentManagementService.getInvoices(currentUser->getId());
util::Map<std::string, const Invoice*> userInvoicesReadOnly;
for (int iterator = 0; iterator < currentUserInvoices.getSize(); iterator++)
{
Invoice* currentInvoice = currentUserInvoices.getValueAt(iterator);
userInvoicesReadOnly.insert(currentInvoice->getId(), currentInvoice);
}
return userInvoicesReadOnly;
}
void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
{
m_paymentManagementService.completePayment(invoiceID, paymentMode);
}
util::Vector<const Notification*> Controller::getNotifications()
{
return util::Vector<const Notification*>();
}
void Controller::deleteNotification(const std::string& notificationID)
{
}
void Controller::configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications)
{
}
void Controller::runSystemChecks()
{
}