From b9be43acca667f1f7a51aaf85c7140e7020245c0 Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Wed, 20 May 2026 18:02:13 +0530 Subject: [PATCH] Implement Payment Reminder functionality NOT005: Payment Reminder 1. Added payment reminder check in Controller::runSystemChecks() to trigger reminder processing during system startup. 2. Implemented PaymentManagementService::sendPaymentReminders() to identify unpaid invoices that exceed the pending payment threshold and send reminder notifications to customers. 3. Added reminder notification logic to include invoice details and stop reminders once invoice payment status changes from Pending to Paid. Precondition: 1. Customer has an invoice with PaymentStatus::PENDING. 2. Invoice age exceeds the configured payment reminder threshold. 3. Application is started and system checks execute. Steps: 1. Start the application. 2. Allow system checks to run during startup. 3. Navigate to View Notifications. - Verify that a payment reminder notification is displayed. 4. Open the generated notification. - Verify that the notification includes the invoice ID and due date. 5. Complete payment for the invoice and restart the application. - Verify that no further reminder notifications are generated for the paid invoice. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 1 + .../controllers/Controller.h | 3 ++ .../services/PaymentManagementService.cpp | 34 +++++++++++++++++++ .../utilities/Config.h | 11 ++++++ .../views/UserInterface.cpp | 1 + 6 files changed, 51 insertions(+) create mode 100644 Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index a65c46d..1b76c8a 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -171,6 +171,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..af788dc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -143,5 +143,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { + m_paymentManagementService.sendPaymentReminders(); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..7cfc875 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #include "Enums.h" +#include "PaymentManagementService.h" class Service; class ComboPackage; @@ -14,6 +15,8 @@ class Notification; class Controller { +private: + PaymentManagementService m_paymentManagementService; public: bool login(const std::string& username, const std::string& password); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index 786ebcf..4eaedbd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -1 +1,35 @@ #include "PaymentManagementService.h" +#include "Invoice.h" +#include "ServiceBooking.h" +#include "Enums.h" +#include "Timestamp.h" +#include "Config.h" + +void PaymentManagementService::sendPaymentReminders() +{ + auto& invoicesMap = m_dataStore.getInvoices(); + int invoicesMapSize = invoicesMap.getSize(); + for (int index = 0; index < invoicesMapSize; index++) + { + const Invoice* invoice = invoicesMap.getValueAt(index); + if (invoice && invoice->getStatus() == util::PaymentStatus::PENDING) + { + util::Timestamp invoiceCreationTimestamp = invoice->getInvoiceDate(); + util::Timestamp currentTimestamp; + if (util::Timestamp::getDurationInHours(invoiceCreationTimestamp, currentTimestamp) >= config::threshold::PAYMENT_REMINDER_THRESHOLD_HOURS) + { + const ServiceBooking* serviceBooking = invoice->getBooking(); + if (serviceBooking) + { + User* customer = serviceBooking->getCustomer(); + if (customer) + { + sendNotification(customer, + "Payment Reminder", + "Your payment for Invoice ID " + invoice->getId() + " is still pending.Please complete the payment." + invoice->getId()); + } + } + } + } + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h new file mode 100644 index 0000000..dc101ac --- /dev/null +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -0,0 +1,11 @@ +#pragma once + +#pragma once + +namespace config +{ + namespace threshold + { + constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168; + } +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 122f9a8..cc47e47 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -4,6 +4,7 @@ void UserInterface::run() { + m_controller.runSystemChecks(); bool isMenuActive = true; while (isMenuActive) {