Merged PR 963: UserStory EMP012 Add Shortlisted Candidates As Employee
Related work items: #957
This commit is contained in:
@@ -47,6 +47,11 @@ bool ZenvyController::updateDesignation(const std::string& id,Enums::EmployeeDes
|
||||
return m_employeeManagementService->updateDesignation(id,designation);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Candidate>> ZenvyController::getShorlistedCandidates()
|
||||
{
|
||||
return m_employeeManagementService->getShorlistedCandidates();
|
||||
}
|
||||
|
||||
//Payslip Management
|
||||
void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
void updateProfile(const std::string&,const std::string&);
|
||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
||||
bool updateDesignation(const std::string&,Enums::EmployeeDesignation);
|
||||
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates();
|
||||
|
||||
template <typename ...Types>
|
||||
Employees getEmployees(Types ...types)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,11 @@ logMap& DataStore::getLogs()
|
||||
return m_logs;
|
||||
}
|
||||
|
||||
candidateMap& DataStore::getCandidates()
|
||||
{
|
||||
return m_candidates;
|
||||
}
|
||||
|
||||
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
|
||||
{
|
||||
return m_authenticatedEmployee;
|
||||
|
||||
@@ -25,6 +25,7 @@ using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
|
||||
using payrollMap = std::map<std::string, std::shared_ptr<Payroll>>;
|
||||
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>;
|
||||
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>;
|
||||
using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>;
|
||||
|
||||
class DataStore
|
||||
{
|
||||
@@ -34,6 +35,7 @@ private:
|
||||
payrollMap m_payrolls;
|
||||
payslipMap m_payslips;
|
||||
logMap m_logs;
|
||||
candidateMap m_candidates;
|
||||
DataStore() = default;
|
||||
public:
|
||||
static DataStore& getInstance();
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
payrollMap& getPayrolls();
|
||||
payslipMap& getPayslips();
|
||||
logMap& getLogs();
|
||||
candidateMap& getCandidates();
|
||||
std::shared_ptr<Employee>& getAuthenticatedEmployee();
|
||||
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
|
||||
};
|
||||
@@ -12,7 +12,7 @@ const std::string& Candidate::getCandidateName() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
long int Candidate::getCandidatePhone() const
|
||||
const std::string& Candidate::getCandidatePhone() const
|
||||
{
|
||||
return m_phone;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void Candidate::setCandidateName(const std::string& name)
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void Candidate::setCandidatePhone(long int phone)
|
||||
void Candidate::setCandidatePhone(const std::string& phone)
|
||||
{
|
||||
m_phone = phone;
|
||||
}
|
||||
|
||||
@@ -8,24 +8,24 @@ private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_name;
|
||||
long int m_phone;
|
||||
std::string m_phone;
|
||||
std::string m_qualification;
|
||||
Enums::CandidateStatus m_status;
|
||||
public:
|
||||
Candidate() : m_id("CD" + std::to_string(++m_uid)), m_name(""), m_phone(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
|
||||
Candidate() : m_id("CD" + std::to_string(++m_uid)), m_name(""), m_phone(""), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
|
||||
Candidate(const std::string& name,
|
||||
long int phone,
|
||||
const std::string& phone,
|
||||
const std::string& qualification,
|
||||
Enums::CandidateStatus status)
|
||||
: m_id("CD" + std::to_string(++m_uid)), m_name(name), m_phone(phone), m_qualification(qualification), m_status(status) {}
|
||||
const std::string& getCandidateId() const;
|
||||
const std::string& getCandidateName() const;
|
||||
long int getCandidatePhone() const;
|
||||
const std::string& getCandidatePhone() const;
|
||||
const std::string& getCandidateQualification() const;
|
||||
Enums::CandidateStatus getCandidateStatus() const;
|
||||
void setCandidateId(const std::string& id);
|
||||
void setCandidateName(const std::string& name);
|
||||
void setCandidatePhone(long int phone);
|
||||
void setCandidatePhone(const std::string& phone);
|
||||
void setCandidateQualification(const std::string& qualification);
|
||||
void setCandidateStatus(Enums::CandidateStatus status);
|
||||
};
|
||||
@@ -235,3 +235,17 @@ void EmployeeManagementService::saveEmployees()
|
||||
employeeFileManager.save(employees);
|
||||
generalEmployeeFileManager.save(generalEmployees);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Candidate>> EmployeeManagementService::getShorlistedCandidates()
|
||||
{
|
||||
candidateMap candidates = m_dataStore.getCandidates();
|
||||
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates;
|
||||
for (auto& candidate : candidates)
|
||||
{
|
||||
if (candidate.second->getCandidateStatus() == Enums::CandidateStatus::SHORTLISTED)
|
||||
{
|
||||
shortlistedCandidates.push_back(candidate.second);
|
||||
}
|
||||
}
|
||||
return shortlistedCandidates;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
void updateProfile(const std::string&,const std::string&);
|
||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
||||
std::shared_ptr<const Employee> getCurrentEmployee();
|
||||
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates();
|
||||
void loadEmployees();
|
||||
void saveEmployees();
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace Enums {
|
||||
{
|
||||
PENDING,
|
||||
SHORTLISTED,
|
||||
REJECTED
|
||||
REJECTED,
|
||||
HIRED
|
||||
};
|
||||
|
||||
enum class NotificationStatus
|
||||
|
||||
@@ -13,7 +13,7 @@ void AdminMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Update Designation \n7. Logout\nEnter your Choice: ";
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Update Designation \n7. Add Shortlisted Candidate As Employee\n8. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -51,6 +51,9 @@ bool AdminMenu::handleOperation(int choice)
|
||||
updateDesignation(m_zenvyController);
|
||||
break;
|
||||
case 7:
|
||||
addShortlistedCandidateAsEmployee(m_zenvyController);
|
||||
break;
|
||||
case 8:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
|
||||
@@ -13,7 +13,7 @@ void HRManagerMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Register CandidateAsEmployee\n12. Update Profile\n13. Deactivate Employee\n14. View Profile\n15. Update Designation\n16. Logout\nEnter your Choice: ";
|
||||
std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Update Profile\n12. Deactivate Employee\n13. View Profile\n14. Update Designation\n15. Add Shortlisted Candidate as Employee\n16. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -41,18 +41,21 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
case 8:
|
||||
createEmployee(m_zenvyController);
|
||||
break;
|
||||
case 12:
|
||||
case 11:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 13:
|
||||
case 12:
|
||||
deactivateEmployee(m_zenvyController);
|
||||
break;
|
||||
case 14:
|
||||
case 13:
|
||||
viewProfile(m_zenvyController);
|
||||
break;
|
||||
case 15:
|
||||
case 14:
|
||||
updateDesignation(m_zenvyController);
|
||||
break;
|
||||
case 15:
|
||||
addShortlistedCandidateAsEmployee(m_zenvyController);
|
||||
break;
|
||||
case 16:
|
||||
return false;
|
||||
default:
|
||||
|
||||
@@ -30,12 +30,12 @@ static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
|
||||
{ Enums::EmployeeType::TALENT_ACQUISITION, "Talent Executive" },
|
||||
{ Enums::EmployeeType::GENERAL, "General Employee" }
|
||||
};
|
||||
auto it = employeeTypeOptions.find(employeeType);
|
||||
if (it == employeeTypeOptions.end())
|
||||
auto employeeOptionsIterator = employeeTypeOptions.find(employeeType);
|
||||
if (employeeOptionsIterator == employeeTypeOptions.end())
|
||||
{
|
||||
throw std::runtime_error("You do not have the authority to create a new Employee!");
|
||||
}
|
||||
const auto& options = it->second;
|
||||
const auto& options = employeeOptionsIterator->second;
|
||||
std::cout << "Select Employee Type\n";
|
||||
for (int index = 0; index < options.size(); ++index)
|
||||
{
|
||||
@@ -121,4 +121,82 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
|
||||
std::cout << "Employee not found\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void displayCandidateDetails(const std::vector<std::shared_ptr<Candidate>>& shorlistedCandidates)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << "Index"
|
||||
<< std::setw(10) << "ID"
|
||||
<< std::setw(20) << "Name"
|
||||
<< std::setw(15) << "Phone"
|
||||
<< std::setw(15) << "Qualification"
|
||||
<< std::setw(10) << "Status"
|
||||
<< std::endl;
|
||||
int index = 0;
|
||||
for (auto& candidate : shorlistedCandidates)
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << ++index
|
||||
<< std::setw(10) << candidate->getCandidateId()
|
||||
<< std::setw(20) << candidate->getCandidateName()
|
||||
<< std::setw(15) << candidate->getCandidatePhone()
|
||||
<< std::setw(15) << candidate->getCandidateQualification()
|
||||
<< std::setw(10) << Enums::getCandidateStatusString(candidate->getCandidateStatus())
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller)
|
||||
{
|
||||
int index;
|
||||
std::string name, email, phone;
|
||||
util::clear();
|
||||
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates = controller->getShorlistedCandidates();
|
||||
if (shortlistedCandidates.empty())
|
||||
{
|
||||
std::cout << "No candidates Found!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
displayCandidateDetails(shortlistedCandidates);
|
||||
std::cout << "Enter the Index: ";
|
||||
util::read(index);
|
||||
auto currentEmployee = controller->getCurrentEmployee();
|
||||
Enums::EmployeeType employeeType;
|
||||
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
||||
if (index > 0 && index <= shortlistedCandidates.size())
|
||||
{
|
||||
employeeType = getEmployeeType(currentEmployee->getEmployeeType());
|
||||
std::shared_ptr<Candidate> candidate = shortlistedCandidates[index - 1];
|
||||
switch (employeeType)
|
||||
{
|
||||
case Enums::EmployeeType::INVALID:
|
||||
std::cout << "Invalid Choice";
|
||||
util::pressEnter();
|
||||
return;
|
||||
case Enums::EmployeeType::GENERAL:
|
||||
employeeDesignation = getEmployeeDesignation();
|
||||
if (employeeDesignation == Enums::EmployeeDesignation::INVALID)
|
||||
{
|
||||
std::cout << "Invalid Choice";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
std::cout << "Enter email: ";
|
||||
util::read(email);
|
||||
name = candidate->getCandidateName();
|
||||
phone = candidate->getCandidatePhone();
|
||||
controller->createEmployee(employeeType, employeeDesignation, email, name, phone);
|
||||
candidate->setCandidateStatus(Enums::CandidateStatus::HIRED);
|
||||
std::cout << "\nCreated Employee Successfully.";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Enter a valid Index.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ inline void viewProfile(std::shared_ptr<ZenvyController> controller)
|
||||
}
|
||||
}
|
||||
|
||||
void displayCandidateDetails(const std::vector<std::shared_ptr<const Candidate>>& shorlistedCandidates);
|
||||
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller);
|
||||
|
||||
inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
{
|
||||
int choice;
|
||||
@@ -223,7 +226,7 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
inline void searchEmployee(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
{
|
||||
std::string name;
|
||||
util::clear();
|
||||
|
||||
Reference in New Issue
Block a user