Implement Purchase Combo functionality
<UserStory> CUS007: Purchase Combo Package </UserStory>
<Changes>
1. Added combo package selection flow in CustomerMenu to list all active combo packages with estimated cost and allow customer selection.
2. Implemented Controller::purchaseComboPackage to delegate combo package booking requests to ServiceManagementService.
3. Added ServiceManagementService::purchaseComboPackage logic to validate authenticated user, fetch selected combo package, create a ServiceBooking, persist it in DataStore, and send booking confirmation notification.
4. Added helper functions in CustomerMenu to calculate combo package estimated cost based on included services and required inventory items.
5. Updated ServiceBooking model to use User* reference for assigned technician and simplified constructor to align booking model with object references.
</Changes>
<Test>
Precondition:
1. Customer account exists and is logged into the system.
2. Active combo packages are available in the system.
3. Combo package contains one or more active services.
4. Service bookings and notifications can be created successfully.
Steps:
1. Navigate to Customer Menu and select the combo package booking option.
2. View the list of available combo packages.
- Verify that all active combo packages are displayed with their details.
3. Select one combo package and enter vehicle number, vehicle brand, and vehicle model.
- Verify that a booking request is generated successfully.
4. Complete the booking flow.
- Verify that a confirmation message is displayed to the customer.
5. Check customer notifications.
- Verify that a booking confirmation notification is received.
</Test>
<Review>
Sreeja Reghukumar, please review
</Review>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#include <iomanip>
|
||||
#include "CustomerMenu.h"
|
||||
#include "ComboPackage.h"
|
||||
#include "Service.h"
|
||||
#include "InventoryItem.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "Utility.h"
|
||||
|
||||
void CustomerMenu::showMenu()
|
||||
{
|
||||
@@ -47,8 +52,70 @@ void CustomerMenu::selectService()
|
||||
{
|
||||
}
|
||||
|
||||
static const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
|
||||
{
|
||||
util::Map<int, const ComboPackage*> activeComboPackages;
|
||||
int currentIndex = 1;
|
||||
int userInputIndex;
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << "Index"
|
||||
<< std::setw(15) << "Combo Package ID"
|
||||
<< std::setw(15) << "Combo Package Name"
|
||||
<< std::setw(15) << "Estimate Cost"
|
||||
<< std::endl;
|
||||
for (int index = 0; index < comboPackages.getSize(); index++)
|
||||
{
|
||||
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
|
||||
if (currentComboPackage->getState() != util::State::ACTIVE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
activeComboPackages.insert(currentIndex, currentComboPackage);
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << currentIndex
|
||||
<< std::setw(15) << currentComboPackage->getId()
|
||||
<< std::setw(25) << currentComboPackage->getPackageName()
|
||||
<< std::setw(15) << calculateComboServiceEstimatedCost(currentComboPackage)
|
||||
<< std::endl;
|
||||
currentIndex++;
|
||||
}
|
||||
if (activeComboPackages.getSize() == 0)
|
||||
{
|
||||
std::cout << "No active combo packages available." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
std::cout << "Enter combo package index: ";
|
||||
util::read(userInputIndex);
|
||||
if (activeComboPackages.find(userInputIndex) == -1)
|
||||
{
|
||||
std::cout << "Invalid combo package index." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return activeComboPackages[userInputIndex];
|
||||
}
|
||||
|
||||
void CustomerMenu::selectComboPackage()
|
||||
{
|
||||
std::string vehicleNumber, vehicleBrand, vehicleModel;
|
||||
auto comboPackages = m_controller.getComboPackages();
|
||||
util::clear();
|
||||
const ComboPackage* selectedComboPackage = selectComboPackageFromPackages(comboPackages);
|
||||
if (selectedComboPackage == nullptr)
|
||||
{
|
||||
std::cout << "Failed to book combo package!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
util::clear();
|
||||
std::cout << "Enter vehicle number: ";
|
||||
util::read(vehicleNumber);
|
||||
std::cout << "Enter vehicle brand: ";
|
||||
util::read(vehicleBrand);
|
||||
std::cout << "Enter vehicle model: ";
|
||||
util::read(vehicleModel);
|
||||
m_controller.purchaseComboPackage(selectedComboPackage->getId(), vehicleNumber, vehicleBrand, vehicleModel);
|
||||
std::cout << "Combo Package has been booked successfully";
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
void CustomerMenu::viewServiceHistory()
|
||||
|
||||
Reference in New Issue
Block a user