Files
Jissin Mathew 8162a2fe3d Implement Update Service Status
<UserStory> SER005: Update Service Status </UserStory>

<Changes>
    1. Integrated Controller with ServiceManagementService to support job completion workflow.
    2. Implemented ServiceManagementService::completeJob with validation for technician assignment, job existence, and status transition.
    3. Enhanced TechnicianMenu with job selection helper to display assigned jobs, allow index-based selection, and handle invalid choices.
    4. Updated TechnicianMenu::completeJob to mark job as completed via Controller and provide user feedback.
    5. Added logic to check if all jobs in a booking are completed, triggering invoice generation and customer notification.
</Changes>

<Test>

 Acceptance Criteria:
 1. Status updates are visible to customers immediately after technician marks job as completed.

 Precondition:
  1. Technician is logged into the system.
  2. At least one active job card is assigned to the technician.
  3. Datastore contains valid service bookings linked to jobs.

 Steps:
  1. Navigate to Technician menu and choose "Complete Job".
    - Verify that the system lists active jobs with index-based selection.
  2. Select a job card by index.
    - Verify that the job status changes from STARTED to COMPLETED.
  3. Check customer view.
    - Verify that the updated status is reflected in the customer’s booking history.
  4. If all jobs in the booking are completed:
    - Verify that an invoice is generated and a notification is sent to the customer.
</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
2026-05-21 15:02:46 +05:30

131 lines
2.4 KiB
C++

#include "JobCard.h"
int JobCard::m_uid = 0;
JobCard::JobCard()
: m_id("JC" + std::to_string(++m_uid)),
m_booking(nullptr),
m_service(nullptr),
m_technician(nullptr),
m_status(util::ServiceJobStatus()) {}
JobCard::JobCard(const std::string& bookingId,
ServiceBooking* booking,
Service* service,
const std::string& serviceId,
const std::string& technicianId,
User* technician,
const util::Timestamp& assignedDate,
util::ServiceJobStatus status,
const util::Timestamp& completionDate
)
: m_id("JC" + std::to_string(++m_uid)),
m_bookingId(bookingId),
m_booking(booking),
m_service(service),
m_serviceId(serviceId),
m_technicianId(technicianId),
m_technician(technician),
m_assignedDate(assignedDate),
m_status(status),
m_completionDate(completionDate) {}
const std::string& JobCard::getId() const
{
return m_id;
}
const std::string& JobCard::getBookingId() const
{
return m_bookingId;
}
ServiceBooking* JobCard::getBooking() const
{
return m_booking;
}
Service* JobCard::getService() const
{
return m_service;
}
const std::string& JobCard::getServiceId() const
{
return m_serviceId;
}
const std::string& JobCard::getTechnicianId() const
{
return m_technicianId;
}
User* JobCard::getTechnician() const
{
return m_technician;
}
const util::Timestamp& JobCard::getAssignedDate() const
{
return m_assignedDate;
}
util::ServiceJobStatus JobCard::getStatus() const
{
return m_status;
}
const util::Timestamp& JobCard::getCompletionDate() const
{
return m_completionDate;
}
void JobCard::setId(const std::string& id)
{
m_id = id;
}
void JobCard::setBookingId(const std::string& bookingId)
{
m_bookingId = bookingId;
}
void JobCard::setBooking(ServiceBooking* booking)
{
m_booking = booking;
}
void JobCard::setService(Service* service)
{
m_service = service;
}
void JobCard::setServiceId(const std::string& serviceId)
{
m_serviceId = serviceId;
}
void JobCard::setTechnicianId(const std::string& technicianId)
{
m_technicianId = technicianId;
}
void JobCard::setTechnician(User* technician)
{
m_technician = technician;
}
void JobCard::setAssignedDate(const util::Timestamp& assignedDate)
{
m_assignedDate = assignedDate;
}
void JobCard::setStatus(util::ServiceJobStatus status)
{
m_status = status;
}
void JobCard::setCompletionDate(const util::Timestamp& completionDate)
{
m_completionDate = completionDate;
}