Implement Payment Reminder functionality
<UserStory>
NOT005: Payment Reminder
</UserStory>
<Changes>
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.
</Changes>
<Test>
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.
</Test>
<Review>
Sreeja Reghukumar, please review
</Review>
This commit is contained in:
+1
@@ -171,6 +171,7 @@
|
||||
<ClInclude Include="services\PaymentManagementService.h" />
|
||||
<ClInclude Include="services\ServiceManagementService.h" />
|
||||
<ClInclude Include="services\UserManagementService.h" />
|
||||
<ClInclude Include="utilities\Config.h" />
|
||||
<ClInclude Include="utilities\Enums.h" />
|
||||
<ClInclude Include="utilities\InputHelper.h" />
|
||||
<ClInclude Include="utilities\Map.h" />
|
||||
|
||||
@@ -143,5 +143,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
|
||||
|
||||
void Controller::runSystemChecks()
|
||||
{
|
||||
m_paymentManagementService.sendPaymentReminders();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Map.h"
|
||||
#include <string>
|
||||
#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();
|
||||
|
||||
+34
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace config
|
||||
{
|
||||
namespace threshold
|
||||
{
|
||||
constexpr int PAYMENT_REMINDER_THRESHOLD_HOURS = 168;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
void UserInterface::run()
|
||||
{
|
||||
m_controller.runSystemChecks();
|
||||
bool isMenuActive = true;
|
||||
while (isMenuActive)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user