diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index 97a2b90..91f72fc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -121,6 +121,15 @@ void Controller::removeComboPackage(const std::string& comboPackageID) { } +/* +Function: getInvoicesByUser +Description: Retrieves all invoices associated with the currently authenticated user. + Converts them into a read-only map before returning. +Parameters: + - None +Returns: + - util::Map containing the user’s invoices +*/ util::Map Controller::getInvoicesByUser() { User* currentUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -134,6 +143,15 @@ util::Map Controller::getInvoicesByUser() return userInvoicesReadOnly; } +/* +Function: completePayment +Description: Completes payment for a specific invoice using the given payment mode. +Parameters: + - invoiceID: std::string, ID of the invoice to be paid + - paymentMode: util::PaymentMode, mode of payment (e.g., ONLINE, OFFLINE) +Returns: + - void +*/ void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode) { m_paymentManagementService.completePayment(invoiceID, paymentMode); @@ -154,5 +172,4 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { -} - +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 094e104..8b67c7d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -9,6 +9,15 @@ #include "JobCard.h" #include "Enums.h" +/* +Function: createInventoryItemsMap (static helper) +Description: Builds a map of inventory items required for a given service and adds them to the booking’s inventory map. +Parameters: + - completeInventoryItemMapOfBooking: util::Map&, map to store inventory items for the booking + - currentService: const Service*, pointer to the current service +Returns: + - void +*/ static void createInventoryItemsMap(util::Map& completeInventoryItemMapOfBooking, const Service* currentService) { auto& currentRequiredInventoryItems = currentService->getRequiredInventoryItems(); @@ -19,6 +28,18 @@ static void createInventoryItemsMap(util::Map& comp } } +/* +Function: generateInvoice +Description: Generates an invoice for a completed service booking. + Validates that all job cards are completed, calculates labor and parts cost, applies discount, + and stores the invoice in the datastore. +Parameters: + - booking: ServiceBooking*, pointer to the service booking +Returns: + - void +Throws: + - std::runtime_error if booking is null or job cards are incomplete +*/ void PaymentManagementService::generateInvoice(ServiceBooking* booking) { if (!booking) @@ -56,6 +77,14 @@ void PaymentManagementService::generateInvoice(ServiceBooking* booking) currentInvoices.insert(invoice->getId(), invoice); } +/* +Function: getInvoices +Description: Retrieves all invoices associated with a specific customer. +Parameters: + - customerID: std::string, ID of the customer +Returns: + - util::Map containing the customer’s invoices +*/ util::Map PaymentManagementService::getInvoices(const std::string& customerID) { util::Map& currentInvoices = m_dataStore.getInvoices(); @@ -71,6 +100,18 @@ util::Map PaymentManagementService::getInvoices(const std return currentUserInvoices; } +/* +Function: completePayment +Description: Completes payment for a specific invoice. Updates payment method, date, and status, + then sends a notification to the customer. +Parameters: + - invoiceID: std::string, ID of the invoice + - paymentMode: util::PaymentMode, mode of payment (e.g., ONLINE, OFFLINE) +Returns: + - void +Throws: + - std::runtime_error if the invoice ID is invalid +*/ void PaymentManagementService::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode) { auto& currentInvoices = m_dataStore.getInvoices(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index a9f4d21..9f1d696 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -64,6 +64,14 @@ void CustomerMenu::viewServiceHistory() { } +/* +Function: selectInvoiceFromUserForPayment (static helper) +Description: Lists all pending invoices for the customer and allows selection by index. +Parameters: + - currentInvoices: util::Map&, map of customer invoices +Returns: + - std::string: ID of the selected invoice, or empty string if none selected +*/ static std::string selectInvoiceFromUserForPayment(const util::Map& currentInvoices) { int currentIndex = 1, choice; @@ -118,6 +126,14 @@ static std::string selectInvoiceFromUserForPayment(const util::Map, customer’s invoices +Returns: + - void +Throws: + - std::runtime_error if a null invoice is encountered +*/ static void displayInvoices(util::Map currentUserInvoices) { if (currentUserInvoices.getSize() == 0) @@ -206,6 +242,14 @@ static void displayInvoices(util::Map currentUserIn } } +/* +Function: viewInvoices +Description: Displays invoices associated with the customer by calling displayInvoices. +Parameters: + - None +Returns: + - void +*/ void CustomerMenu::viewInvoices() { util::clear();