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