Merged PR 964: UserStory EMP005 Update Designation
Related work items: #949
This commit is contained in:
@@ -42,6 +42,11 @@ std::shared_ptr<const Employee> ZenvyController::getCurrentEmployee()
|
|||||||
return m_employeeManagementService->getCurrentEmployee();
|
return m_employeeManagementService->getCurrentEmployee();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZenvyController::updateDesignation(const std::string& id,Enums::EmployeeDesignation designation)
|
||||||
|
{
|
||||||
|
return m_employeeManagementService->updateDesignation(id,designation);
|
||||||
|
}
|
||||||
|
|
||||||
//Payslip Management
|
//Payslip Management
|
||||||
void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
|
void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
std::shared_ptr<const Employee> getCurrentEmployee();
|
std::shared_ptr<const Employee> getCurrentEmployee();
|
||||||
void updateProfile(const std::string&,const std::string&);
|
void updateProfile(const std::string&,const std::string&);
|
||||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(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);
|
||||||
template <typename ...Types>
|
template <typename ...Types>
|
||||||
Employees getEmployees(Types ...types)
|
Employees getEmployees(Types ...types)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "GeneralEmployee.h"
|
#include "GeneralEmployee.h"
|
||||||
#include "Factory.h"
|
#include "Factory.h"
|
||||||
|
|
||||||
Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
|
Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
|
||||||
{
|
{
|
||||||
return m_designation;
|
return m_designation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,24 @@ bool EmployeeManagementService::deactivateEmployee(const std::string& id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation)
|
||||||
|
{
|
||||||
|
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
|
||||||
|
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
|
||||||
|
std::map<std::string, std::shared_ptr<Employee>> employees = m_dataStore.getEmployees();
|
||||||
|
auto employeeIterator = employees.find(id);
|
||||||
|
if (employeeIterator == employees.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*employeeIterator).second);
|
||||||
|
if (generalEmployee)
|
||||||
|
{
|
||||||
|
generalEmployee->setDesignation(designation);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<const Employee> EmployeeManagementService::getCurrentEmployee()
|
std::shared_ptr<const Employee> EmployeeManagementService::getCurrentEmployee()
|
||||||
{
|
{
|
||||||
return m_dataStore.getAuthenticatedEmployee();
|
return m_dataStore.getAuthenticatedEmployee();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
|
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||||
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
|
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
|
||||||
bool deactivateEmployee(const std::string&);
|
bool deactivateEmployee(const std::string&);
|
||||||
|
bool updateDesignation(const std::string&,Enums::EmployeeDesignation);
|
||||||
void updateProfile(const std::string&,const std::string&);
|
void updateProfile(const std::string&,const std::string&);
|
||||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(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::shared_ptr<const Employee> getCurrentEmployee();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void AdminMenu::run()
|
|||||||
{
|
{
|
||||||
int choice;
|
int choice;
|
||||||
util::clear();
|
util::clear();
|
||||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. 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. Logout\nEnter your Choice: ";
|
||||||
util::read(choice);
|
util::read(choice);
|
||||||
if (!handleOperation(choice))
|
if (!handleOperation(choice))
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,9 @@ bool AdminMenu::handleOperation(int choice)
|
|||||||
updateProfile(m_zenvyController);
|
updateProfile(m_zenvyController);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
updateDesignation(m_zenvyController);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
std::cout << "Enter a valid choice!" << std::endl;
|
std::cout << "Enter a valid choice!" << std::endl;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void HRManagerMenu::run()
|
|||||||
{
|
{
|
||||||
int choice;
|
int choice;
|
||||||
util::clear();
|
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. 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. Register CandidateAsEmployee\n12. Update Profile\n13. Deactivate Employee\n14. View Profile\n15. Update Designation\n16. Logout\nEnter your Choice: ";
|
||||||
util::read(choice);
|
util::read(choice);
|
||||||
if (!handleOperation(choice))
|
if (!handleOperation(choice))
|
||||||
{
|
{
|
||||||
@@ -51,6 +51,9 @@ bool HRManagerMenu::handleOperation(int choice)
|
|||||||
viewProfile(m_zenvyController);
|
viewProfile(m_zenvyController);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
|
updateDesignation(m_zenvyController);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
std::cout << "Enter a valid choice!" << std::endl;
|
std::cout << "Enter a valid choice!" << std::endl;
|
||||||
|
|||||||
@@ -102,3 +102,23 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
|
|||||||
std::cout << "\nCreated Employee Successfully.";
|
std::cout << "\nCreated Employee Successfully.";
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||||
|
{
|
||||||
|
std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees(Enums::EmployeeType::GENERAL));
|
||||||
|
if (selectedEmployeeId.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Enums::EmployeeDesignation designation = getEmployeeDesignation();
|
||||||
|
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
|
||||||
|
{
|
||||||
|
std::cout << "Assigned Employee Role Successfully\n";
|
||||||
|
util::pressEnter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Employee not found\n";
|
||||||
|
util::pressEnter();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
|
||||||
void createEmployee(std::shared_ptr<ZenvyController> controller);
|
void createEmployee(std::shared_ptr<ZenvyController> controller);
|
||||||
|
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController);
|
||||||
|
|
||||||
inline void viewProfile(std::shared_ptr<ZenvyController> controller)
|
inline void viewProfile(std::shared_ptr<ZenvyController> controller)
|
||||||
{
|
{
|
||||||
@@ -134,14 +135,28 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
|||||||
<< std::setw(10) << "Index"
|
<< std::setw(10) << "Index"
|
||||||
<< std::setw(15) << "Employee ID"
|
<< std::setw(15) << "Employee ID"
|
||||||
<< std::setw(20) << "Name"
|
<< std::setw(20) << "Name"
|
||||||
<< std::setw(20) << "Employee Type" << std::endl;
|
<< std::setw(20) << "Employee Type"
|
||||||
|
<< std::setw(20) << "Employee Designation" << std::endl;
|
||||||
for (const auto& employee : employeeList)
|
for (const auto& employee : employeeList)
|
||||||
{
|
{
|
||||||
std::cout << std::left << std::setw(10) << employee.first
|
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second);
|
||||||
|
std::cout << std::left
|
||||||
|
<< std::setw(10) << employee.first
|
||||||
<< std::setw(15) << employee.second->getId()
|
<< std::setw(15) << employee.second->getId()
|
||||||
<< std::setw(20) << employee.second->getEmployeeName()
|
<< std::setw(20) << employee.second->getEmployeeName()
|
||||||
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
|
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType());
|
||||||
<< std::endl;
|
if (generalEmployee)
|
||||||
|
{
|
||||||
|
std::cout << std::left
|
||||||
|
<< std::setw(20) << Enums::getEmployeeDesignationString(generalEmployee->getDesignation())
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << std::left
|
||||||
|
<< std::setw(20) << "NULL"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::cout << "Enter the Index: ";
|
std::cout << "Enter the Index: ";
|
||||||
util::read(choice);
|
util::read(choice);
|
||||||
@@ -163,7 +178,7 @@ inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controlle
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(controller->deactivateEmployee(selectedEmployeeId))
|
if (controller->deactivateEmployee(selectedEmployeeId))
|
||||||
{
|
{
|
||||||
std::cout << "Employee deactivated successfully\n";
|
std::cout << "Employee deactivated successfully\n";
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
@@ -210,13 +225,13 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
|||||||
|
|
||||||
inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
util::clear();
|
util::clear();
|
||||||
std::cout << "Enter Employee Name: ";
|
std::cout << "Enter Employee Name: ";
|
||||||
util::read(name);
|
util::read(name);
|
||||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
|
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
|
||||||
if (!(searchResults.second).empty())
|
if (!(searchResults.second).empty())
|
||||||
{
|
{
|
||||||
std::cout << std::left
|
std::cout << std::left
|
||||||
<< std::setw(10) << "ID"
|
<< std::setw(10) << "ID"
|
||||||
<< std::setw(20) << "Name"
|
<< std::setw(20) << "Name"
|
||||||
@@ -238,10 +253,10 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
|||||||
<< std::setw(15) << "HouseRentAllowance";
|
<< std::setw(15) << "HouseRentAllowance";
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
for (const auto& employee : searchResults.second)
|
for (const auto& employee : searchResults.second)
|
||||||
{
|
{
|
||||||
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
|
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
|
||||||
{
|
{
|
||||||
std::cout << std::left
|
std::cout << std::left
|
||||||
<< std::setw(10) << employee->getId()
|
<< std::setw(10) << employee->getId()
|
||||||
<< std::setw(20) << employee->getEmployeeName()
|
<< std::setw(20) << employee->getEmployeeName()
|
||||||
@@ -257,8 +272,8 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
|||||||
{
|
{
|
||||||
std::cout << std::setw(15) << employee->getEmployeeTeamId();
|
std::cout << std::setw(15) << employee->getEmployeeTeamId();
|
||||||
}
|
}
|
||||||
if (searchResults.first == Enums::EmployeeType::FINANCE
|
if (searchResults.first == Enums::EmployeeType::FINANCE
|
||||||
|| searchResults.first == Enums::EmployeeType::HR
|
|| searchResults.first == Enums::EmployeeType::HR
|
||||||
|| searchResults.first == Enums::EmployeeType::ADMIN)
|
|| searchResults.first == Enums::EmployeeType::ADMIN)
|
||||||
{
|
{
|
||||||
std::cout << std::left
|
std::cout << std::left
|
||||||
@@ -270,12 +285,12 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
|||||||
<< std::setw(15) << employee->getPayroll()->getHouseRentAllowance();
|
<< std::setw(15) << employee->getPayroll()->getHouseRentAllowance();
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "No Employee found with this name" << std::endl;
|
std::cout << "No Employee found with this name" << std::endl;
|
||||||
}
|
}
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user