Minor fixes and formatting updates in payroll, enums, and menus

<SRS> SRS02 : Employee Management </SRS>

<Changes>
- Fixed variable naming issue in Payroll deserialization
- Added braces for consistency in enum string-to-value helpers
- Improved readability in validation logic
- Corrected typo in Finance Executive payroll menu text
</Changes>

<Review>
Smitha Mohan
</Review>
This commit is contained in:
2026-04-13 11:46:55 +05:30
parent 7fc468ac4b
commit ed1cf4e306
4 changed files with 36 additions and 5 deletions
@@ -109,11 +109,11 @@ std::string Payroll::serialize() const
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record) std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
{ {
std::string id, employeeId; std::string id, employeeId;
std::string basicSalaryStr, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString; std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
std::istringstream serializedPayroll(record); std::istringstream serializedPayroll(record);
std::getline(serializedPayroll, id, ','); std::getline(serializedPayroll, id, ',');
std::getline(serializedPayroll, employeeId, ','); std::getline(serializedPayroll, employeeId, ',');
std::getline(serializedPayroll, basicSalaryStr, ','); std::getline(serializedPayroll, basicSalaryString, ',');
std::getline(serializedPayroll, houseRentAllowanceString, ','); std::getline(serializedPayroll, houseRentAllowanceString, ',');
std::getline(serializedPayroll, foodAllowanceString, ','); std::getline(serializedPayroll, foodAllowanceString, ',');
std::getline(serializedPayroll, employeePFString, ','); std::getline(serializedPayroll, employeePFString, ',');
@@ -121,7 +121,7 @@ std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
try try
{ {
double basicSalary = std::stod(basicSalaryStr); double basicSalary = std::stod(basicSalaryString);
double houseRentAllowance = std::stod(houseRentAllowanceString); double houseRentAllowance = std::stod(houseRentAllowanceString);
double foodAllowance = std::stod(foodAllowanceString); double foodAllowance = std::stod(foodAllowanceString);
double employeePFContribution = std::stod(employeePFString); double employeePFContribution = std::stod(employeePFString);
@@ -162,48 +162,76 @@ namespace Enums {
inline AccountStatus getAccountStatus(const std::string& input) inline AccountStatus getAccountStatus(const std::string& input)
{ {
if (input == "ACTIVE") if (input == "ACTIVE")
{
return AccountStatus::ACTIVE; return AccountStatus::ACTIVE;
}
if (input == "INACTIVE") if (input == "INACTIVE")
{
return AccountStatus::INACTIVE; return AccountStatus::INACTIVE;
}
return AccountStatus::INACTIVE; return AccountStatus::INACTIVE;
} }
inline EmployeeType getEmployeeType(const std::string& input) inline EmployeeType getEmployeeType(const std::string& input)
{ {
if (input == "GENERAL") if (input == "GENERAL")
{
return EmployeeType::GENERAL; return EmployeeType::GENERAL;
}
if (input == "IT") if (input == "IT")
{
return EmployeeType::IT; return EmployeeType::IT;
}
if (input == "FINANCE") if (input == "FINANCE")
{
return EmployeeType::FINANCE; return EmployeeType::FINANCE;
}
if (input == "TALENT_ACQUISITION") if (input == "TALENT_ACQUISITION")
{
return EmployeeType::TALENT_ACQUISITION; return EmployeeType::TALENT_ACQUISITION;
}
if (input == "HR") if (input == "HR")
{
return EmployeeType::HR; return EmployeeType::HR;
}
if (input == "TEAM") if (input == "TEAM")
{
return EmployeeType::TEAM; return EmployeeType::TEAM;
}
if (input == "ADMIN") if (input == "ADMIN")
{
return EmployeeType::ADMIN; return EmployeeType::ADMIN;
}
return EmployeeType::INVALID; return EmployeeType::INVALID;
} }
inline TeamStatus getTeamStatus(const std::string& str) inline TeamStatus getTeamStatus(const std::string& str)
{ {
if (str == "IN_TEAM") if (str == "IN_TEAM")
{
return TeamStatus::IN_TEAM; return TeamStatus::IN_TEAM;
}
if (str == "NOT_IN_TEAM") if (str == "NOT_IN_TEAM")
{
return TeamStatus::NOT_IN_TEAM; return TeamStatus::NOT_IN_TEAM;
}
return TeamStatus::NOT_IN_TEAM; return TeamStatus::NOT_IN_TEAM;
} }
inline EmployeeDesignation getEmployeeDesignation(const std::string& input) inline EmployeeDesignation getEmployeeDesignation(const std::string& input)
{ {
if (input == "JUNIOR") if (input == "JUNIOR")
{
return EmployeeDesignation::JUNIOR; return EmployeeDesignation::JUNIOR;
}
if (input == "SENIOR") if (input == "SENIOR")
{
return EmployeeDesignation::SENIOR; return EmployeeDesignation::SENIOR;
}
if (input == "TEAM_LEAD") if (input == "TEAM_LEAD")
{
return EmployeeDesignation::TEAM_LEAD; return EmployeeDesignation::TEAM_LEAD;
}
return EmployeeDesignation::INVALID; return EmployeeDesignation::INVALID;
} }
} }
@@ -18,7 +18,10 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) {
bool util::isEmailValid(const std::string& email) { bool util::isEmailValid(const std::string& email) {
size_t index = email.find('@'); size_t index = email.find('@');
if (index == std::string::npos) return false; if (index == std::string::npos)
{
return false;
}
if (email.find('@', index + 1) != std::string::npos) if (email.find('@', index + 1) != std::string::npos)
{ {
return false; return false;
@@ -43,7 +43,7 @@ void FinanceExecutiveMenu::updatePayroll()
util::read(foodAllowance); util::read(foodAllowance);
std::cout << "Enter the New EmployeePFContribution: "; std::cout << "Enter the New EmployeePFContribution: ";
util::read(employeePFContribution); util::read(employeePFContribution);
std::cout << "Enter the New EmplyerPFContribution: "; std::cout << "Enter the New EmployerPFContribution: ";
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"; std::cout << "Payroll Updated";