diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index 1220088..c68f511 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -164,5 +164,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN void Controller::runSystemChecks() { m_inventoryManagementService.sendLowStockAlerts(); + m_paymentManagementService.sendPaymentReminders(); } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 041f6e2..a3eae11 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -5,6 +5,7 @@ #include "AuthenticationManagementService.h" #include "UserManagementService.h" #include "InventoryManagementService.h" +#include "PaymentManagementService.h" class Service; class ComboPackage; @@ -21,6 +22,7 @@ private: AuthenticationManagementService m_authenticationManagementService; UserManagementService m_userManagementService; InventoryManagementService m_inventoryManagementService; + 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 index 7a96ed6..8b7b488 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -5,5 +5,6 @@ namespace config namespace threshold { constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5; + constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168; } }