Merge branch 'feature-notification-management-not005' into feature-notification-management

This commit is contained in:
Jissin Mathew
2026-05-21 21:00:20 +05:30
4 changed files with 38 additions and 0 deletions
@@ -164,5 +164,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
void Controller::runSystemChecks()
{
m_inventoryManagementService.sendLowStockAlerts();
m_paymentManagementService.sendPaymentReminders();
}
@@ -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();
@@ -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());
}
}
}
}
}
}
@@ -5,5 +5,6 @@ namespace config
namespace threshold
{
constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5;
constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168;
}
}