Merge branch 'feature-notification-management-not005' into feature-notification-management
This commit is contained in:
@@ -164,5 +164,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
|
|||||||
void Controller::runSystemChecks()
|
void Controller::runSystemChecks()
|
||||||
{
|
{
|
||||||
m_inventoryManagementService.sendLowStockAlerts();
|
m_inventoryManagementService.sendLowStockAlerts();
|
||||||
|
m_paymentManagementService.sendPaymentReminders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "UserManagementService.h"
|
#include "UserManagementService.h"
|
||||||
#include "InventoryManagementService.h"
|
#include "InventoryManagementService.h"
|
||||||
|
#include "PaymentManagementService.h"
|
||||||
|
|
||||||
class Service;
|
class Service;
|
||||||
class ComboPackage;
|
class ComboPackage;
|
||||||
@@ -21,6 +22,7 @@ private:
|
|||||||
AuthenticationManagementService m_authenticationManagementService;
|
AuthenticationManagementService m_authenticationManagementService;
|
||||||
UserManagementService m_userManagementService;
|
UserManagementService m_userManagementService;
|
||||||
InventoryManagementService m_inventoryManagementService;
|
InventoryManagementService m_inventoryManagementService;
|
||||||
|
PaymentManagementService m_paymentManagementService;
|
||||||
public:
|
public:
|
||||||
bool login(const std::string& username, const std::string& password);
|
bool login(const std::string& username, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
|
|||||||
+34
@@ -1 +1,35 @@
|
|||||||
#include "PaymentManagementService.h"
|
#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
|
namespace threshold
|
||||||
{
|
{
|
||||||
constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5;
|
constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5;
|
||||||
|
constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user