Fix review comments
This commit is contained in:
+14
-15
@@ -1080,7 +1080,7 @@ static bool hasCompletedAllJobs(std::string bookingId, util::Map<std::string, Jo
|
||||
JobCard* currentJob = currentAssignedJobs.getValueAt(iterator);
|
||||
if (currentJob->getBookingId() == bookingId)
|
||||
{
|
||||
if (currentJob->getStatus() == util::ServiceJobStatus::STARTED || currentJob->getStatus() == util::ServiceJobStatus::INPROGRESS)
|
||||
if (currentJob->getStatus() != util::ServiceJobStatus::COMPLETED && currentJob->getStatus() != util::ServiceJobStatus::CANCELLED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1090,16 +1090,17 @@ static bool hasCompletedAllJobs(std::string bookingId, util::Map<std::string, Jo
|
||||
}
|
||||
|
||||
/*
|
||||
Function: completeJob
|
||||
Description: Marks a job card as completed for the authenticated technician.
|
||||
If all job cards in the booking are completed, marks the booking as completed
|
||||
and generates an invoice.
|
||||
Function: updateJobStatus
|
||||
Description:
|
||||
Updates the status of a job card assigned to the currently authenticated technician.
|
||||
- If the job is STARTED, it moves to IN_PROGRESS.
|
||||
- If the job is IN_PROGRESS, it moves to COMPLETED.
|
||||
When all jobs in a service booking are completed, the booking status is updated,
|
||||
an invoice is generated, and a notification is sent to the customer.
|
||||
Parameters:
|
||||
- jobID: std::string, ID of the job card
|
||||
- jobID: const std::string&, unique identifier of the job card to update.
|
||||
Returns:
|
||||
- void
|
||||
Throws:
|
||||
- std::runtime_error if technician is not authenticated, job card not found, or job already completed
|
||||
- void
|
||||
*/
|
||||
void ServiceManagementService::updateJobStatus(const std::string& jobID)
|
||||
{
|
||||
@@ -1126,10 +1127,10 @@ void ServiceManagementService::updateJobStatus(const std::string& jobID)
|
||||
}
|
||||
if (currentJob->getStatus() == util::ServiceJobStatus::STARTED)
|
||||
{
|
||||
currentJob->setStatus(util::ServiceJobStatus::INPROGRESS);
|
||||
currentJob->setStatus(util::ServiceJobStatus::IN_PROGRESS);
|
||||
jobStatusUpdated = true;
|
||||
}
|
||||
else if (currentJob->getStatus() == util::ServiceJobStatus::INPROGRESS)
|
||||
else if (currentJob->getStatus() == util::ServiceJobStatus::IN_PROGRESS)
|
||||
{
|
||||
currentJob->setStatus(util::ServiceJobStatus::COMPLETED);
|
||||
jobStatusUpdated = true;
|
||||
@@ -1146,12 +1147,10 @@ void ServiceManagementService::updateJobStatus(const std::string& jobID)
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Failed to update the job.");
|
||||
throw std::runtime_error("Failed to update job status. Job may already be completed.");
|
||||
}
|
||||
if (!jobStatusUpdated)
|
||||
{
|
||||
throw std::runtime_error("Failed to update the job");
|
||||
throw std::runtime_error("Failed to update job status. Job may already be completed.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace util
|
||||
PENDING,
|
||||
STARTED,
|
||||
COMPLETED,
|
||||
INPROGRESS,
|
||||
IN_PROGRESS,
|
||||
CANCELLED
|
||||
};
|
||||
|
||||
@@ -210,8 +210,8 @@ namespace util
|
||||
return "COMPLETED";
|
||||
case ServiceJobStatus::CANCELLED:
|
||||
return "CANCELLED";
|
||||
case ServiceJobStatus::INPROGRESS:
|
||||
return "INPROGRESS";
|
||||
case ServiceJobStatus::IN_PROGRESS:
|
||||
return "IN_PROGRESS";
|
||||
}
|
||||
throw std::invalid_argument("Invalid ServiceJobStatus");
|
||||
}
|
||||
@@ -244,9 +244,9 @@ namespace util
|
||||
{
|
||||
return ServiceJobStatus::CANCELLED;
|
||||
}
|
||||
if (value == "INPROGRESS")
|
||||
if (value == "IN_PROGRESS")
|
||||
{
|
||||
return ServiceJobStatus::INPROGRESS;
|
||||
return ServiceJobStatus::IN_PROGRESS;
|
||||
}
|
||||
throw std::invalid_argument("Invalid ServiceJobStatus string");
|
||||
}
|
||||
|
||||
@@ -627,7 +627,6 @@ inline void displayInvoices(util::Map<std::string, const Invoice*> currentUserIn
|
||||
std::cout << "Unable to fetch the selected invoice\n";
|
||||
doRun = false;
|
||||
}
|
||||
|
||||
} while (doRun);
|
||||
}
|
||||
}
|
||||
@@ -646,7 +645,7 @@ inline util::Map<std::string, const JobCard*> filterStartedJobCards(util::Map<st
|
||||
for (int iterator = 0; iterator < assignedJobCards.getSize(); iterator++)
|
||||
{
|
||||
const JobCard* currentJobCard = assignedJobCards.getValueAt(iterator);
|
||||
if (currentJobCard && (currentJobCard->getStatus() == util::ServiceJobStatus::STARTED || currentJobCard->getStatus() == util::ServiceJobStatus::INPROGRESS))
|
||||
if (currentJobCard && (currentJobCard->getStatus() == util::ServiceJobStatus::STARTED || currentJobCard->getStatus() == util::ServiceJobStatus::IN_PROGRESS))
|
||||
{
|
||||
startedJobCards.insert(currentJobCard->getId(), currentJobCard);
|
||||
}
|
||||
@@ -659,13 +658,11 @@ Function: filterJobCards
|
||||
Description:
|
||||
Filters the given list of job cards and returns only those
|
||||
whose status matches the specified ServiceJobStatus.
|
||||
|
||||
Parameters:
|
||||
- assignedJobCards: util::Map<std::string, const JobCard*>&
|
||||
Map of job card IDs to JobCard pointers assigned to the technician.
|
||||
- selectedJobStatus: util::ServiceJobStatus
|
||||
The status type to filter job cards by.
|
||||
|
||||
Returns:
|
||||
- util::Map<std::string, const JobCard*>
|
||||
A map containing only job cards with the specified status.
|
||||
@@ -710,7 +707,7 @@ inline void displayAllJobs(util::Map<std::string, const JobCard*>& assignedJobCa
|
||||
for (int iterator = 0; iterator < assignedJobCards.getSize(); iterator++)
|
||||
{
|
||||
const JobCard* currentJobCard = assignedJobCards.getValueAt(iterator);
|
||||
if (currentJobCard && (currentJobCard->getStatus() == util::ServiceJobStatus::STARTED || currentJobCard->getStatus() == util::ServiceJobStatus::INPROGRESS))
|
||||
if (currentJobCard && (currentJobCard->getStatus() == util::ServiceJobStatus::STARTED || currentJobCard->getStatus() == util::ServiceJobStatus::IN_PROGRESS))
|
||||
{
|
||||
std::cout << std::left << std::setw(12) << currentJobCard->getBookingId()
|
||||
<< std::setw(12) << currentJobCard->getId()
|
||||
@@ -745,7 +742,7 @@ inline std::string selectJobCardToUpdate(util::Map<std::string, const JobCard*>&
|
||||
util::clear();
|
||||
std::cout << "Select a job to update to Inprogress\n";
|
||||
}
|
||||
else if (selectedJobStatusType == util::ServiceJobStatus::INPROGRESS)
|
||||
else if (selectedJobStatusType == util::ServiceJobStatus::IN_PROGRESS)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Select a job to update to Completed\n";
|
||||
|
||||
@@ -119,7 +119,7 @@ void TechnicianMenu::updateJobStatus()
|
||||
std::cout << "Update Job Status\n";
|
||||
int choice;
|
||||
std::string selectedJobID;
|
||||
util::ServiceJobStatus selectedJobStatus;
|
||||
util::ServiceJobStatus selectedJobStatus = util::ServiceJobStatus::PENDING;
|
||||
util::Map<std::string, const JobCard*> assignedJobCards = m_controller.getJobCardsByUser();
|
||||
std::cout << "Select the type of job you want to update\n1.Started\n2.Inprogress\nChoice: ";
|
||||
util::read(choice);
|
||||
@@ -129,11 +129,13 @@ void TechnicianMenu::updateJobStatus()
|
||||
}
|
||||
else if (choice == 2)
|
||||
{
|
||||
selectedJobStatus = util::ServiceJobStatus::INPROGRESS;
|
||||
selectedJobStatus = util::ServiceJobStatus::IN_PROGRESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Invalid Index");
|
||||
std::cout << "Invalid choice. Please try again.\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
util::Map<std::string, const JobCard*> selectedTypeJobCard = filterJobCards(assignedJobCards, selectedJobStatus);
|
||||
selectedJobID = selectJobCardToUpdate(selectedTypeJobCard, selectedJobStatus);
|
||||
|
||||
Reference in New Issue
Block a user