Fixed payroll ID handling and improved payroll update flow
<SRS> SRS02 : Employee Management </SRS> <Changes> - Fixed Payroll constructor to use given ID during deserialization - Cleaned up salary update logic in PayslipManagementService - Improved employee selection display in Finance menu - Added employee type column in selection list - Fixed typo in Employee menu (Ticket) - Added confirmation message after payroll update </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -13,7 +13,7 @@ Payroll::Payroll(const std::string& id,
|
|||||||
double foodAllowance,
|
double foodAllowance,
|
||||||
double employeePFContribution,
|
double employeePFContribution,
|
||||||
double employerPFContribution)
|
double employerPFContribution)
|
||||||
: m_id("PR" + std::to_string(++m_uid)),
|
: m_id(id),
|
||||||
m_employeeId(employeeId),
|
m_employeeId(employeeId),
|
||||||
m_basicSalary(basicSalary),
|
m_basicSalary(basicSalary),
|
||||||
m_houseRentAllowance(houseRentAllowance),
|
m_houseRentAllowance(houseRentAllowance),
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ void PayslipManagementService::updateSalary(const std::string& employeeId, doubl
|
|||||||
auto employee = m_dataStore.getEmployees().find(employeeId);
|
auto employee = m_dataStore.getEmployees().find(employeeId);
|
||||||
if (employee != m_dataStore.getEmployees().end() && employee->second->getEmployeeType() != Enums::EmployeeType::ADMIN)
|
if (employee != m_dataStore.getEmployees().end() && employee->second->getEmployeeType() != Enums::EmployeeType::ADMIN)
|
||||||
{
|
{
|
||||||
(employee->second)->getPayroll()->setBasicSalary(basicSalary);
|
auto payroll = employee->second->getPayroll();
|
||||||
(employee->second)->getPayroll()->setHouseRentAllowance(houseRentAllowance);
|
payroll->setBasicSalary(basicSalary);
|
||||||
(employee->second)->getPayroll()->setFoodAllowance(foodAllowance);
|
payroll->setHouseRentAllowance(houseRentAllowance);
|
||||||
(employee->second)->getPayroll()->setEmployeePFContribution(employeePFContribution);
|
payroll->setFoodAllowance(foodAllowance);
|
||||||
(employee->second)->getPayroll()->setEmployerPFContribution(employerPFContribution);
|
payroll->setEmployeePFContribution(employeePFContribution);
|
||||||
|
payroll->setEmployerPFContribution(employerPFContribution);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void EmployeeMenu::run()
|
|||||||
{
|
{
|
||||||
int choice;
|
int choice;
|
||||||
util::clear();
|
util::clear();
|
||||||
std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticke\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n14. Update Profile\n15. Logout\nEnter your Choice: ";
|
std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticket\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n14. Update Profile\n15. Logout\nEnter your Choice: ";
|
||||||
util::read(choice);
|
util::read(choice);
|
||||||
if (!handleOperation(choice))
|
if (!handleOperation(choice))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ std::string FinanceExecutiveMenu::getSelectedUserId()
|
|||||||
std::map<int, std::shared_ptr<const Employee>> employeeList;
|
std::map<int, std::shared_ptr<const Employee>> employeeList;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
auto allEmployees = m_zenvyController->getEmployees();
|
auto allEmployees = m_zenvyController->getEmployees();
|
||||||
|
util::clear();
|
||||||
|
std::cout << "Select the Employee\n";
|
||||||
for (auto& currentEmployee : allEmployees)
|
for (auto& currentEmployee : allEmployees)
|
||||||
{
|
{
|
||||||
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
|
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
|
||||||
@@ -43,14 +45,16 @@ std::string FinanceExecutiveMenu::getSelectedUserId()
|
|||||||
employeeList[++index] = currentEmployee;
|
employeeList[++index] = currentEmployee;
|
||||||
}
|
}
|
||||||
std::cout << std::left
|
std::cout << std::left
|
||||||
<< std::setw(6) << "Index"
|
<< std::setw(10) << "Index"
|
||||||
<< std::setw(15) << "Employee Id"
|
<< std::setw(15) << "Employee ID"
|
||||||
<< std::setw(25) << "Name" << std::endl;
|
<< std::setw(20) << "Name"
|
||||||
|
<< std::setw(20) << "Employee Type" << std::endl;
|
||||||
for (const auto& employee : employeeList)
|
for (const auto& employee : employeeList)
|
||||||
{
|
{
|
||||||
std::cout << std::left << std::setw(6) << employee.first
|
std::cout << std::left << std::setw(10) << employee.first
|
||||||
<< std::setw(15) << employee.second->getId()
|
<< std::setw(15) << employee.second->getId()
|
||||||
<< std::setw(25) << employee.second->getEmployeeName()
|
<< std::setw(20) << employee.second->getEmployeeName()
|
||||||
|
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
std::cout << "Enter the Index: ";
|
std::cout << "Enter the Index: ";
|
||||||
@@ -71,6 +75,7 @@ void FinanceExecutiveMenu::updatePayroll()
|
|||||||
std::string employeeId;
|
std::string employeeId;
|
||||||
double basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution;
|
double basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution;
|
||||||
employeeId = getSelectedUserId();
|
employeeId = getSelectedUserId();
|
||||||
|
util::clear();
|
||||||
if (employeeId != "") {
|
if (employeeId != "") {
|
||||||
std::cout << "Enter the New Basic Salary: ";
|
std::cout << "Enter the New Basic Salary: ";
|
||||||
util::read(basicSalary);
|
util::read(basicSalary);
|
||||||
@@ -83,6 +88,8 @@ void FinanceExecutiveMenu::updatePayroll()
|
|||||||
std::cout << "Enter the New EmplyerPFContribution: ";
|
std::cout << "Enter the New EmplyerPFContribution: ";
|
||||||
util::read(employerPFContribution);
|
util::read(employerPFContribution);
|
||||||
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
||||||
|
std::cout << "Payroll Updated";
|
||||||
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw std::runtime_error("Unexpected error occured");
|
throw std::runtime_error("Unexpected error occured");
|
||||||
|
|||||||
Reference in New Issue
Block a user