Files
Jissin Sam Mathew 9b7d9cf7c1 Implement Assign Job to Technician functionality
<UserStory> SER001: Assign job to technician </UserStory>

<Changes>
    1. Added ServiceManagementService logic to retrieve service bookings and create job cards for assigned technicians.
    2. Added UserManagementService support to retrieve technicians by user type and fetch technician details by ID.
    3. Connected Controller methods with ServiceManagementService and UserManagementService for service booking retrieval, technician listing, and job card creation.
    4. Updated JobCard model to use util::ServiceJobStatus consistently and simplified constructor initialization for assigned and completion timestamps.
    5. Added PENDING status in ServiceJobStatus enum for identifying unassigned service bookings.
    6. Implemented AdminMenu job assignment flow to list pending service bookings, display available technicians, allow technician selection, and assign jobs for services in the booking.
    7. Added notification trigger during job card creation for assigned technicians.
</Changes>

<Test>

Job assignment functionality validation

Precondition:
1. System is running.
2. Pending service bookings are available in the system.
3. Technician users are available in the system.
4. Admin user is logged in and admin menu is active.

Steps:
1. Launch the application and log in as an admin.
2. Select the Assign Job option from the admin menu.
3. View the list of available pending service bookings.
   - Verify that pending bookings are displayed.
4. Select a valid service booking.
5. View the list of available technicians.
   - Verify that technicians are listed for selection.
6. Select a technician to assign the job.
   - Verify that job cards are created for services in the booking.
   - Verify that assigned jobs are visible in the technician’s menu.
   - Verify that a confirmation message is shown.
   - Verify that a confirmation notification is sent to the assigned technician.

</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 14:50:43 +05:30

173 lines
3.7 KiB
C++

#pragma once
#include <stdexcept>
namespace util
{
enum class UserType
{
ADMIN,
TECHNICIAN,
CUSTOMER
};
enum class PaymentMode
{
ONLINE,
OFFLINE
};
enum class PaymentStatus
{
PENDING,
COMPLETED
};
enum class ServiceJobStatus
{
PENDING,
STARTED,
COMPLETED
};
enum class State
{
ACTIVE,
INACTIVE
};
inline std::string getUserTypeString(UserType type)
{
switch (type)
{
case UserType::ADMIN:
return "ADMIN";
case UserType::TECHNICIAN:
return "TECHNICIAN";
case UserType::CUSTOMER:
return "CUSTOMER";
}
throw std::invalid_argument("Invalid UserType");
}
inline UserType getUserType(const std::string& value)
{
if (value == "ADMIN")
{
return UserType::ADMIN;
}
if (value == "TECHNICIAN")
{
return UserType::TECHNICIAN;
}
if (value == "CUSTOMER")
{
return UserType::CUSTOMER;
}
throw std::invalid_argument("Invalid UserType string");
}
inline std::string getPaymentModeString(PaymentMode mode)
{
switch (mode)
{
case PaymentMode::ONLINE:
return "ONLINE";
case PaymentMode::OFFLINE:
return "OFFLINE";
}
throw std::invalid_argument("Invalid PaymentMode");
}
inline PaymentMode getPaymentMode(const std::string& value)
{
if (value == "ONLINE")
{
return PaymentMode::ONLINE;
}
if (value == "OFFLINE")
{
return PaymentMode::OFFLINE;
}
throw std::invalid_argument("Invalid PaymentMode string");
}
inline std::string getPaymentStatusString(PaymentStatus status)
{
switch (status)
{
case PaymentStatus::PENDING:
return "PENDING";
case PaymentStatus::COMPLETED:
return "COMPLETED";
}
throw std::invalid_argument("Invalid PaymentStatus");
}
inline PaymentStatus getPaymentStatus(const std::string& value)
{
if (value == "PENDING")
{
return PaymentStatus::PENDING;
}
if (value == "COMPLETED")
{
return PaymentStatus::COMPLETED;
}
throw std::invalid_argument("Invalid PaymentStatus string");
}
inline std::string getServiceJobStatusString(ServiceJobStatus status)
{
switch (status)
{
case ServiceJobStatus::STARTED:
return "STARTED";
case ServiceJobStatus::COMPLETED:
return "COMPLETED";
case ServiceJobStatus::PENDING:
return "STARTED";
}
throw std::invalid_argument("Invalid ServiceJobStatus");
}
inline ServiceJobStatus getServiceJobStatus(const std::string& value)
{
if (value == "STARTED")
{
return ServiceJobStatus::STARTED;
}
if (value == "COMPLETED")
{
return ServiceJobStatus::COMPLETED;
}
throw std::invalid_argument("Invalid ServiceJobStatus string");
}
inline std::string getStateString(State status)
{
switch (status)
{
case State::ACTIVE:
return "STARTED";
case State::INACTIVE:
return "COMPLETED";
}
throw std::invalid_argument("Invalid State");
}
inline State getState(const std::string& value)
{
if (value == "ACTIVE")
{
return State::ACTIVE;
}
if (value == "COMPLETED")
{
return State::INACTIVE;
}
throw std::invalid_argument("Invalid State string");
}
}