14 Commits

Author SHA1 Message Date
joelthomastrenser ed1cf4e306 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>
2026-04-13 11:46:55 +05:30
joelthomastrenser 7fc468ac4b Merge branch 'feature-employee-management' into feature-employee-management-emp007 2026-04-13 11:37:24 +05:30
joelthomastrenser 8668a615ea Merged PR 957: Employee system updates
- Cleaned up employee menus and selection flow
- Fixed payroll ID issues and update logic
- Added saving/loading for employees and payroll
- Improved and centralized validation checks
- Added FileManager for file handling and cleanup
2026-04-13 10:44:14 +05:30
joelthomastrenser 282ab721b5 Improved employee view formatting and menu text
<SRS> SRS02 : Employee Management </SRS>

<Changes>
 - Updated "View Employee" to "View Employees" in Admin Menu
 - Added clear screen and header for employee list display
 - Improved column spacing and alignment for better readability
 - Reordered fields for a cleaner layout
 - Added pressEnter prompt after viewing employees
</Changes>

<Review>
Smitha Mohan
</Review>
2026-04-11 17:54:20 +05:30
joelthomastrenser 2c9740e776 Merge branch 'feature-employee-management' into feature-employee-management-emp007 2026-04-11 17:41:57 +05:30
joelthomastrenser aa21853a65 Refactored employee selection and cleaned up menu logic
<SRS> SRS02 : Employee Management </SRS>

<Changes>
 - Removed getSelectedUserId() from FinanceExecutiveMenu
 - Added reusable selectEmployeeId() in MenuHelper
 - Simplified deactivateEmployee() using common selection logic
 - Fixed missing break in HRManagerMenu
</Changes>

<Review>
Smitha Mohan
</Review>
2026-04-11 14:59:41 +05:30
joelthomastrenser 66c80fd055 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>
2026-04-11 12:58:09 +05:30
joelthomastrenser 47b44ccaa0 Added payroll persistance and updated Talent Acquisition role
<SRS> SRS02 : Employee Management </SRS>

<Changes>
 - Added Payroll  getHeaders, serialize and deserialize functions
 - Stored payrolls in DataStore
 - Loaded and saved payrolls along with employees
 - Linked payroll to employees during creation and load
 - Added employeeId to Payroll
- Renamed TAG role to TALENT_ACQUISITION across the project
 - Added missing TalentExecutive case in Employee deserialization
 - Added constructor to TalentExecutive for FileManager integration
 - Renamed ID counters to m_uid for consistency
 - Updated salary values in ApplicationConfig
</Changes>

<Review>
Smitha Mohan
</Review>
2026-04-11 12:13:23 +05:30
joelthomastrenser 1d94f1680c Refactored validation logic and centralized employee validators
<SRS> SRS02 : Employee Management </SRS>

<Changes>
 - Moved employee validation logic (active type check, email and phone duplication) to Validator utility
 - Updated service to use util::hasActiveEmployeeOfType, util::isEmailDuplicate, and util::isPhoneDuplicate
 - Integrated validator usage in MenuHelper for input validation
 - Cleaned up formatting and minor inconsistencies
</Changes>

<Review>
Smitha Mohan
</Review>
2026-04-10 20:29:55 +05:30
joelthomastrenser c50700e70c Added CSV header support and persistence for employees
<SRS> SRS02 : Employee Management </SRS>

<Changes>
 - Added header handling in FileManager load by skipping first line during deserialization
 - Added support for writing headers using T::getHeaders() in FileManager save
 - Implemented getHeaders() for Employee and GeneralEmployee models
 - Added saveEmployees functionality in EmployeeManagementService
 - Added persistStates method in ZenvyController
 - Added deserialization failure check with exception handling
 - Minor formatting cleanup in FileIO
</Changes>

<Review>
Smitha Mohan
</Review>
2026-04-10 19:41:08 +05:30
Tinu Johnson e470dbc791 Updated MenuHelper.h
<UserStory> EMP007 : View Employees </UserStory>

<Changes>
 - Updated logic in viewEmployees() method.
</Changes>

<Review>
  Smitha Mohan
</Review>
2026-04-08 11:04:09 +05:30
Tinu Johnson c27ca5240a Added MenuHelper feature for ViewEmployee
<UserStory> EMP007 : View Employees </UserStory>

<Changes>
 - Added MenuHelper.cpp and MenuHelper.h to project configuration
 - Moved viewEmployees() implementation from individual menu classes into MenuHelper
 - Added inline viewEmployees(shared_ptr<ZenvyController>) helper with formatted output
 - Added enumToString() to MenuHelper for employee role display
 - Updated AdminMenu, EmployeeMenu, FinanceExecutiveMenu, HRManagerMenu,
   ITExecutiveMenu, TalentExecutiveMenu, TeamExecutiveMenu, and TeamLeadMenu
   to use viewEmployees(m_zenvyController) instead of per‑menu implementations
 - Removed old viewEmployees() method from EmployeeMenu
 - Updated menu options to reflect new centralized viewEmployees() function
</Changes>

<Review>
  Smitha Mohan
</Review>
2026-04-07 20:32:30 +05:30
Tinu Johnson 6256b9ea82 Implement Review fixes
<UserStory> EMP007 : View All Employees  </UserStory>

<Changes>
 - Added check for empty employee map
 - Filtered only ACTIVE employees
 - Added formatted table using <iomanip> in EmplopyeeMenu::viewEmployee()
 - Added check for empty employee list
</Changes>

<Review>
  Smitha Mohan
</Review>
2026-04-07 19:19:08 +05:30
Tinu Johnson 1785660e94 Add Employee Listing Feature
<UserStory> EMP007 : View All Employees  </UserStory>

<Changes>
 - Implemented getEmployees() in ZenvyController to return list of employees
 - Added working getEmployees() implementation in EmployeeManagementService
 - Fixed iterator usage to correctly extract map values into Employees vector
 - Added viewEmployees() UI flow in EmployeeMenu
 - Integrated employee listing into EmployeeMenu option flow
 - Added enumToString() helper for printing employee roles
 - Improved formatting and filtering of ACTIVE employees in employee listing
 - Performed minor code cleanup and consistency adjustments in controller and menu
</Changes>

<Review>
  Smitha Mohan
</Review>
2026-04-07 17:38:53 +05:30
55 changed files with 611 additions and 304 deletions
@@ -22,7 +22,6 @@ void FileIO::writeAllLines(const std::string& path,
std::ofstream file(path, std::ios::trunc);
if (!file.is_open())
throw std::runtime_error("Failed to open file " + path);
for (const auto& line : lines)
file << line << '\n';
}
@@ -1,4 +1,5 @@
#pragma once
#include <stdexcept>
#include "FileIO.h"
template <typename T> using objects = std::map<std::string, std::shared_ptr<T>>;
@@ -20,9 +21,19 @@ objects<T> FileManager<T>::load()
{
objects<T> records;
auto lines = FileIO::readAllLines(m_filePath);
bool isHeader = true;
for (const auto& record : lines)
{
if (isHeader)
{
isHeader = false;
continue;
}
auto object = T::deserialize(record);
if (!object)
{
throw std::runtime_error("Failed to deserialize record");
}
records[object->getId()] = object;
}
return records;
@@ -32,7 +43,7 @@ template <typename T>
void FileManager<T>::save(const objects<T>& records)
{
std::vector<std::string> lines;
lines.push_back(T::getHeaders());
for (const auto& recordPair : records)
{
lines.push_back(recordPair.second->serialize());
@@ -50,4 +50,11 @@ Employees ZenvyController::getEmployees()
void ZenvyController::loadStates()
{
m_employeeManagementService->loadEmployees();
m_payslipManagementService->loadPayrolls();
}
void ZenvyController::persistStates()
{
m_employeeManagementService->saveEmployees();
m_payslipManagementService->savePayrolls();
}
@@ -56,4 +56,5 @@ public:
//File Management
void loadStates();
void persistStates();
};
@@ -27,4 +27,7 @@ employeeMap& DataStore::getEmployees()
return m_employees;
}
payrollMap& DataStore::getPayrolls()
{
return m_payrolls;
}
@@ -18,8 +18,10 @@
#include "Notification.h"
#include "Announcement.h"
#include "Faq.h"
#include "Payroll.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
using payrollMap = std::map<std::string, std::shared_ptr<Payroll>>;
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>;
class DataStore
@@ -27,6 +29,7 @@ class DataStore
private:
std::shared_ptr<Employee> m_authenticatedEmployee;
employeeMap m_employees;
payrollMap m_payrolls;
logMap m_logs;
DataStore() = default;
public:
@@ -36,6 +39,7 @@ public:
DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees();
payrollMap& getPayrolls();
logMap& getLogs();
std::shared_ptr<Employee>& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
@@ -1,6 +1,6 @@
#include "Announcement.h"
int Announcement::m_anid = 0;
int Announcement::m_uid = 0;
const std::string& Announcement::getAnnouncementId() const
{
@@ -5,14 +5,14 @@
class Announcement
{
private:
static int m_anid;
static int m_uid;
std::string m_id;
util::Timestamp m_timestamp;
std::string m_message;
public:
Announcement() : m_id("AN" + std::to_string(++m_anid)), m_timestamp(), m_message("") {}
Announcement() : m_id("AN" + std::to_string(++m_uid)), m_timestamp(), m_message("") {}
Announcement(const std::string& message)
: m_id("AN" + std::to_string(++m_anid)), m_message(message) {}
: m_id("AN" + std::to_string(++m_uid)), m_message(message) {}
const std::string& getAnnouncementId() const;
const util::Timestamp& getAnnouncementTimestamp() const;
const std::string& getAnnouncementMessage() const;
@@ -1,6 +1,6 @@
#include "Attendance.h"
int Attendance::m_aid = 0;
int Attendance::m_uid = 0;
const std::string& Attendance::getAttendanceId() const
{
@@ -5,15 +5,15 @@
class Attendance
{
private:
static int m_aid;
static int m_uid;
std::string m_id;
util::Timestamp m_loginTime;
util::Timestamp m_logoutTime;
public:
Attendance() : m_id("AD" + std::to_string(++m_aid)), m_loginTime(), m_logoutTime() {}
Attendance() : m_id("AD" + std::to_string(++m_uid)), m_loginTime(), m_logoutTime() {}
Attendance(const util::Timestamp& loginTime,
const util::Timestamp& logoutTime)
: m_id("AD" + std::to_string(++m_aid)), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
: m_id("AD" + std::to_string(++m_uid)), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
const std::string& getAttendanceId() const;
const util::Timestamp& getLoginTime() const;
const util::Timestamp& getLogoutTime() const;
@@ -1,6 +1,6 @@
#include "Booking.h"
int Booking::m_bid = 0;
int Booking::m_uid = 0;
const std::string& Booking::getBookingId() const
{
+3 -3
View File
@@ -7,19 +7,19 @@
class Booking
{
private:
static int m_bid;
static int m_uid;
std::string m_id;
util::Timestamp m_startTime;
util::Timestamp m_endTime;
std::string m_employeeId;
std::shared_ptr<Team> m_team;
public:
Booking() : m_id("BK" + std::to_string(++m_bid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
Booking() : m_id("BK" + std::to_string(++m_uid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
Booking(const util::Timestamp& startTime,
const util::Timestamp& endTime,
const std::string& employeeId,
std::shared_ptr<Team> team)
: m_id("BK" + std::to_string(++m_bid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
: m_id("BK" + std::to_string(++m_uid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
const std::string& getBookingId() const;
const util::Timestamp& getStartTime() const;
const util::Timestamp& getEndTime() const;
@@ -1,6 +1,6 @@
#include "Candidate.h"
int Candidate::m_cid = 0;
int Candidate::m_uid = 0;
const std::string& Candidate::getCandidateId() const
{
@@ -5,19 +5,19 @@
class Candidate
{
private:
static int m_cid;
static int m_uid;
std::string m_id;
std::string m_name;
long int m_phone;
std::string m_qualification;
Enums::CandidateStatus m_status;
public:
Candidate() : m_id("CD" + std::to_string(++m_cid)), 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(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
Candidate(const std::string& name,
long int phone,
const std::string& qualification,
Enums::CandidateStatus status)
: m_id("CD" + std::to_string(++m_cid)), m_name(name), m_phone(phone), m_qualification(qualification), m_status(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;
@@ -246,6 +246,17 @@ std::shared_ptr<Employee> Employee::deserialize(const std::string& record)
teamStatus,
accountStatus
);
case Enums::EmployeeType::TALENT_ACQUISITION:
return Factory::getObject<TalentExecutive>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::ADMIN:
return Factory::getObject<Admin>(
id,
@@ -263,3 +274,8 @@ std::shared_ptr<Employee> Employee::deserialize(const std::string& record)
return nullptr;
}
}
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
@@ -90,5 +90,6 @@ public:
Enums::EmployeeType getEmployeeType() const;
virtual std::string serialize() const;
static std::shared_ptr<Employee> deserialize(const std::string&);
static std::string getHeaders();
virtual ~Employee() = default;
};
@@ -59,3 +59,8 @@ std::shared_ptr<GeneralEmployee> GeneralEmployee::deserialize(const std::string&
accountStatus
);
}
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
@@ -43,5 +43,6 @@ public:
void setDesignation(Enums::EmployeeDesignation designation);
std::string serialize() const override;
static std::shared_ptr<GeneralEmployee> deserialize(const std::string&);
static std::string getHeaders();
~GeneralEmployee() = default;
};
@@ -1,6 +1,6 @@
#include "JobListing.h"
int JobListing::m_jid = 0;
int JobListing::m_uid = 0;
const std::string& JobListing::getJobId() const
{
@@ -9,7 +9,7 @@ using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>;
class JobListing
{
private:
static int m_jid;
static int m_uid;
std::string m_id;
std::string m_name;
std::string m_description;
@@ -17,13 +17,13 @@ private:
int m_numberOfVacancies;
candidateMap m_candidates;
public:
JobListing() : m_id("JL" + std::to_string(++m_jid)), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
JobListing() : m_id("JL" + std::to_string(++m_uid)), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
JobListing(const std::string& name,
const std::string& description,
Enums::JobListingStatus status,
int numberOfVacancies,
const candidateMap& candidates)
: m_id("JL" + std::to_string(++m_jid)), m_name(name), m_description(description), m_status(status), m_numberOfVacancies(numberOfVacancies), m_candidates(candidates) {}
: m_id("JL" + std::to_string(++m_uid)), m_name(name), m_description(description), m_status(status), m_numberOfVacancies(numberOfVacancies), m_candidates(candidates) {}
const std::string& getJobId() const;
const std::string& getJobName() const;
const std::string& getJobDescription() const;
+1 -1
View File
@@ -1,6 +1,6 @@
#include "Leave.h"
int Leave::m_lid = 0;
int Leave::m_uid = 0;
const std::string& Leave::getLeaveId() const
{
+3 -3
View File
@@ -6,7 +6,7 @@
class Leave
{
private:
static int m_lid;
static int m_uid;
std::string m_id;
std::string m_employeeId;
util::Timestamp m_timestamp;
@@ -16,12 +16,12 @@ private:
static int m_numberOfMedicalLeave;
Enums::LeaveType m_leaveType;
public:
Leave() : m_id("LV" + std::to_string(++m_lid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
Leave() : m_id("LV" + std::to_string(++m_uid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
Leave(const std::string& employeeId,
const util::Timestamp& timestamp,
const std::string& reason,
Enums::LeaveType leaveType)
: m_id("LV" + std::to_string(++m_lid)), m_employeeId(employeeId), m_timestamp(timestamp), m_reason(reason), m_leaveType(leaveType) {}
: m_id("LV" + std::to_string(++m_uid)), m_employeeId(employeeId), m_timestamp(timestamp), m_reason(reason), m_leaveType(leaveType) {}
const std::string& getLeaveId() const;
const std::string& getEmployeeId() const;
const util::Timestamp& getTimestamp() const;
@@ -1,6 +1,6 @@
#include "Notification.h"
int Notification::m_nid = 0;
int Notification::m_uid = 0;
const std::string& Notification::getNotificationId() const
{
@@ -6,18 +6,18 @@
class Notification
{
private:
static int m_nid;
static int m_uid;
std::string m_id;
std::string m_employeeId;
std::string m_message;
util::Timestamp m_timestamp;
Enums::NotificationStatus m_notificationStatus;
public:
Notification() : m_id("NF" + std::to_string(++m_nid)), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
Notification() : m_id("NF" + std::to_string(++m_uid)), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
Notification(const std::string& employeeId,
const std::string& message,
Enums::NotificationStatus notificationStatus)
: m_id("NF" + std::to_string(++m_nid)), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
: m_id("NF" + std::to_string(++m_uid)), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
const std::string& getNotificationId() const;
const std::string& getEmployeeId() const;
const std::string& getNotificationMessage() const;
+92 -2
View File
@@ -1,12 +1,48 @@
#include <sstream>
#include <stdexcept>
#include "Payroll.h"
#include "StringHelper.h"
#include "Factory.h"
int Payroll::m_prid = 0;
int Payroll::m_uid = 0;
const std::string& Payroll::getPayrollId() const
Payroll::Payroll(const std::string& id,
const std::string& employeeId,
double basicSalary,
double houseRentAllowance,
double foodAllowance,
double employeePFContribution,
double employerPFContribution)
: m_id(id),
m_employeeId(employeeId),
m_basicSalary(basicSalary),
m_houseRentAllowance(houseRentAllowance),
m_foodAllowance(foodAllowance),
m_employeePFContribution(employeePFContribution),
m_employerPFContribution(employerPFContribution)
{
int idNumber = util::extractNumber(m_id);
if (idNumber > m_uid)
{
m_uid = idNumber;
}
}
const std::string& Payroll::getId() const
{
return m_id;
}
const std::string& Payroll::getEmployeeId() const
{
return m_employeeId;
}
void Payroll::setEmployeeId(const std::string& employeeId)
{
m_employeeId = employeeId;
}
double Payroll::getBasicSalary() const
{
return m_basicSalary;
@@ -56,3 +92,57 @@ void Payroll::setEmployerPFContribution(double value)
{
m_employerPFContribution = value;
}
std::string Payroll::serialize() const
{
std::ostringstream serializedPayroll;
serializedPayroll << m_id << ','
<< m_employeeId << ','
<< m_basicSalary << ','
<< m_houseRentAllowance << ','
<< m_foodAllowance << ','
<< m_employeePFContribution << ','
<< m_employerPFContribution;
return serializedPayroll.str();
}
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
{
std::string id, employeeId;
std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
std::istringstream serializedPayroll(record);
std::getline(serializedPayroll, id, ',');
std::getline(serializedPayroll, employeeId, ',');
std::getline(serializedPayroll, basicSalaryString, ',');
std::getline(serializedPayroll, houseRentAllowanceString, ',');
std::getline(serializedPayroll, foodAllowanceString, ',');
std::getline(serializedPayroll, employeePFString, ',');
std::getline(serializedPayroll, employerPFString, ',');
try
{
double basicSalary = std::stod(basicSalaryString);
double houseRentAllowance = std::stod(houseRentAllowanceString);
double foodAllowance = std::stod(foodAllowanceString);
double employeePFContribution = std::stod(employeePFString);
double employerPFContribution = std::stod(employerPFString);
return Factory::getObject<Payroll>(
id,
employeeId,
basicSalary,
houseRentAllowance,
foodAllowance,
employeePFContribution,
employerPFContribution
);
}
catch (...)
{
throw std::runtime_error("Failed to deserialize Payroll object");
}
}
std::string Payroll::getHeaders()
{
return "PayrollId,EmployeeId,BasicSalary,HouseRentAllowance,FoodAllowance,EmployeePFContribution,EmployerPFContribution";
}
+29 -4
View File
@@ -1,25 +1,47 @@
#pragma once
#include <string>
#include <memory>
class Payroll
{
private:
static int m_prid;
static int m_uid;
std::string m_id;
std::string m_employeeId;
double m_basicSalary;
double m_houseRentAllowance;
double m_foodAllowance;
double m_employeePFContribution;
double m_employerPFContribution;
public:
Payroll() : m_id("PR" + std::to_string(++m_prid)), m_basicSalary(0.0), m_houseRentAllowance(0.0), m_foodAllowance(0.0), m_employeePFContribution(0.0), m_employerPFContribution(0.0) {}
Payroll()
: m_id("PR" + std::to_string(++m_uid)),
m_basicSalary(0.0),
m_houseRentAllowance(0.0),
m_foodAllowance(0.0),
m_employeePFContribution(0.0),
m_employerPFContribution(0.0) {}
Payroll(double basicSalary,
double houseRentAllowance,
double foodAllowance,
double employeePFContribution,
double employerPFContribution)
: m_id("PR" + std::to_string(++m_prid)), m_basicSalary(basicSalary), m_houseRentAllowance(houseRentAllowance), m_foodAllowance(foodAllowance), m_employeePFContribution(employeePFContribution), m_employerPFContribution(employerPFContribution) {}
const std::string& getPayrollId() const;
: m_id("PR" + std::to_string(++m_uid)),
m_basicSalary(basicSalary),
m_houseRentAllowance(houseRentAllowance),
m_foodAllowance(foodAllowance),
m_employeePFContribution(employeePFContribution),
m_employerPFContribution(employerPFContribution) {}
Payroll(const std::string& id,
const std::string& employeeId,
double basicSalary,
double houseRentAllowance,
double foodAllowance,
double employeePFContribution,
double employerPFContribution);
const std::string& getId() const;
const std::string& getEmployeeId() const;
void setEmployeeId(const std::string&);
double getBasicSalary() const;
double getHouseRentAllowance() const;
double getFoodAllowance() const;
@@ -30,4 +52,7 @@ public:
void setFoodAllowance(double);
void setEmployeePFContribution(double);
void setEmployerPFContribution(double);
virtual std::string serialize() const;
static std::shared_ptr<Payroll> deserialize(const std::string&);
static std::string getHeaders();
};
@@ -1,6 +1,6 @@
#include "Payslip.h"
int Payslip::m_pid = 0;
int Payslip::m_uid = 0;
const std::string& Payslip::getPayslipId() const
{
+3 -3
View File
@@ -4,12 +4,12 @@
class Payslip
{
private:
static int m_pid;
static int m_uid;
std::string m_id;
double m_salary;
public:
Payslip() : m_id("PS" + std::to_string(++m_pid)), m_salary(0.0) {}
Payslip(const double salary) : m_id("PS" + std::to_string(++m_pid)), m_salary(salary) {}
Payslip() : m_id("PS" + std::to_string(++m_uid)), m_salary(0.0) {}
Payslip(const double salary) : m_id("PS" + std::to_string(++m_uid)), m_salary(salary) {}
const std::string& getPayslipId() const;
double getSalary() const;
void setPayslipId(const std::string& id);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "Room.h"
int Room::m_rid = 0;
int Room::m_uid = 0;
const std::string& Room::getRoomId() const
{
+3 -3
View File
@@ -8,13 +8,13 @@ using bookingMap = std::map<std::string, std::shared_ptr<Booking>>;
class Room
{
private:
static int m_rid;
static int m_uid;
std::string m_id;
std::string m_name;
bookingMap m_bookings;
public:
Room() : m_id("RM" + std::to_string(++m_rid)), m_name("") {}
Room(const std::string& name) : m_id("RM" + std::to_string(++m_rid)), m_name(name) {}
Room() : m_id("RM" + std::to_string(++m_uid)), m_name("") {}
Room(const std::string& name) : m_id("RM" + std::to_string(++m_uid)), m_name(name) {}
const std::string& getRoomId() const;
const std::string& getRoomName() const;
const bookingMap& getBookings() const;
@@ -10,7 +10,25 @@ public:
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::TAG, payroll) {};
) :Employee(name, phone, email, Enums::EmployeeType::TALENT_ACQUISITION, payroll) {};
TalentExecutive(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::TALENT_ACQUISITION,
accountStatus) {
}
~TalentExecutive() = default;
};
+1 -1
View File
@@ -1,6 +1,6 @@
#include "Team.h"
int Team::m_tmid = 0;
int Team::m_uid = 0;
const std::string& Team::getTeamId() const
{
+3 -3
View File
@@ -8,19 +8,19 @@ using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
class Team
{
private:
static int m_tmid;
static int m_uid;
std::string m_id;
std::string m_name;
std::shared_ptr<Employee> m_lead;
employeeMap m_employees;
int m_maximumNumberOfEmployees;
public:
Team() : m_id("TM" + std::to_string(++m_tmid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team() : m_id("TM" + std::to_string(++m_uid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team(
const std::string& name,
std::shared_ptr<Employee> lead,
int maximumNumberOfEmployees)
: m_id("TM" + std::to_string(++m_tmid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
: m_id("TM" + std::to_string(++m_uid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
}
const std::string& getTeamId() const;
const std::string& getTeamName() const;
@@ -1,6 +1,6 @@
#include "Ticket.h"
int Ticket::m_tid = 0;
int Ticket::m_uid = 0;
const std::string& Ticket::getTicketId() const
{
+3 -3
View File
@@ -5,20 +5,20 @@
class Ticket
{
private:
static int m_tid;
static int m_uid;
std::string m_id;
Enums::TicketType m_type;
std::string m_description;
Enums::TicketStatus m_status;
std::string m_employeeId;
public:
Ticket() : m_id("TKT" + std::to_string(++m_tid)), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
Ticket() : m_id("TKT" + std::to_string(++m_uid)), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
Ticket(
Enums::TicketType type,
const std::string& description,
const std::string& employeeId,
Enums::TicketStatus status)
: m_id("TKT" + std::to_string(++m_tid)), m_type(type), m_description(description), m_status(status), m_employeeId(employeeId) {}
: m_id("TKT" + std::to_string(++m_uid)), m_type(type), m_description(description), m_status(status), m_employeeId(employeeId) {}
const std::string& getTicketId() const;
Enums::TicketType getTicketType() const;
const std::string& getDescription() const;
@@ -9,31 +9,32 @@ namespace Config
namespace Payroll
{
constexpr double SENIOR_BASIC_SALARY = 0.0;
constexpr double SENIOR_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double SENIOR_FOOD_ALLOWANCE = 0.0;
constexpr double SENIOR_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double SENIOR_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double JUNIOR_BASIC_SALARY = 0.0;
constexpr double JUNIOR_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double JUNIOR_FOOD_ALLOWANCE = 0.0;
constexpr double JUNIOR_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double JUNIOR_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double HR_MANAGER_BASIC_SALARY = 0.0;
constexpr double HR_MANAGER_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double HR_MANAGER_FOOD_ALLOWANCE = 0.0;
constexpr double HR_MANAGER_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double HR_MANAGER_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double EXECUTIVE_BASIC_SALARY = 0.0;
constexpr double EXECUTIVE_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double EXECUTIVE_FOOD_ALLOWANCE = 0.0;
constexpr double EXECUTIVE_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double EXECUTIVE_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double SENIOR_BASIC_SALARY = 80000.0;
constexpr double SENIOR_HOUSE_RENT_ALLOWANCE = 32000.0;
constexpr double SENIOR_FOOD_ALLOWANCE = 3000.0;
constexpr double SENIOR_EMPLOYEE_PF_CONTRIBUTION = 9600.0;
constexpr double SENIOR_EMPLOYER_PF_CONTRIBUTION = 9600.0;
constexpr double JUNIOR_BASIC_SALARY = 25000.0;
constexpr double JUNIOR_HOUSE_RENT_ALLOWANCE = 10000.0;
constexpr double JUNIOR_FOOD_ALLOWANCE = 1500.0;
constexpr double JUNIOR_EMPLOYEE_PF_CONTRIBUTION = 3000.0;
constexpr double JUNIOR_EMPLOYER_PF_CONTRIBUTION = 3000.0;
constexpr double HR_MANAGER_BASIC_SALARY = 60000.0;
constexpr double HR_MANAGER_HOUSE_RENT_ALLOWANCE = 24000.0;
constexpr double HR_MANAGER_FOOD_ALLOWANCE = 2500.0;
constexpr double HR_MANAGER_EMPLOYEE_PF_CONTRIBUTION = 7200.0;
constexpr double HR_MANAGER_EMPLOYER_PF_CONTRIBUTION = 7200.0;
constexpr double EXECUTIVE_BASIC_SALARY = 45000.0;
constexpr double EXECUTIVE_HOUSE_RENT_ALLOWANCE = 18000.0;
constexpr double EXECUTIVE_FOOD_ALLOWANCE = 2000.0;
constexpr double EXECUTIVE_EMPLOYEE_PF_CONTRIBUTION = 5400.0;
constexpr double EXECUTIVE_EMPLOYER_PF_CONTRIBUTION = 5400.0;
}
namespace File
{
constexpr const char* EMPLOYEES_FILE = "files/Employee.csv";
constexpr const char* GENERAL_EMPLOYEES_FILE = "files/GeneralEmployee.csv";
constexpr const char* PAYROLL_FILE = "files/Payroll.csv";
}
}
@@ -1,3 +1,4 @@
#include <map>
#include <stdexcept>
#include "EmployeeManagementService.h"
#include "Factory.h"
@@ -13,45 +14,6 @@
#include "FileManager.h"
#include "ApplicationConfig.h"
static bool hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeType() == employeeType && employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
return true;
}
}
return false;
}
static bool isEmailDuplicate(const std::string& email, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeEmail() == email)
{
return true;
}
}
return false;
}
static bool isPhoneDuplicate(const std::string& phone, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeePhone() == phone)
{
return true;
}
}
return false;
}
void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone)
{
auto& employees = m_dataStore.getEmployees();
@@ -63,7 +25,7 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
Enums::EmployeeType authenticatedEmployeeType = authenticatedEmployee->getEmployeeType();
std::shared_ptr<Employee> employee;
std::shared_ptr<Payroll> payroll;
if (employeeType != Enums::EmployeeType::GENERAL && hasActiveEmployeeOfType(employeeType, employees))
if (employeeType != Enums::EmployeeType::GENERAL && util::hasActiveEmployeeOfType(employeeType, employees))
{
throw std::runtime_error("Cannot create more than one employee of type " + Enums::getEmployeeTypeString(employeeType));
}
@@ -75,11 +37,11 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
{
throw std::runtime_error("Invalid Phone");
}
if (isEmailDuplicate(email, employees))
if (util::isEmailDuplicate(email, employees))
{
throw std::runtime_error("Duplicate Email");
}
if (isPhoneDuplicate(phone, employees))
if (util::isPhoneDuplicate(phone, employees))
{
throw std::runtime_error("Duplicate Phone Number!");
}
@@ -97,7 +59,7 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
case Enums::EmployeeType::IT:
case Enums::EmployeeType::FINANCE:
case Enums::EmployeeType::TEAM:
case Enums::EmployeeType::TAG:
case Enums::EmployeeType::TALENT_ACQUISITION:
util::enforceAuthorization(authenticatedEmployeeType, Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
payroll = Factory::getObject<Payroll>(Config::Payroll::EXECUTIVE_BASIC_SALARY,
Config::Payroll::EXECUTIVE_HOUSE_RENT_ALLOWANCE,
@@ -115,7 +77,7 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
case Enums::EmployeeType::TEAM:
employee = Factory::getObject<TeamExecutive>(name, phone, email, payroll);
break;
case Enums::EmployeeType::TAG:
case Enums::EmployeeType::TALENT_ACQUISITION:
employee = Factory::getObject <TalentExecutive> (name, phone, email, payroll);
break;
}
@@ -146,6 +108,8 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
default:
throw std::runtime_error("Invalid Employee Type");
}
payroll->setEmployeeId(employee->getId());
m_dataStore.getPayrolls().emplace(std::make_pair(payroll->getId(), payroll));
m_dataStore.getEmployees().emplace(std::make_pair(employee->getId(), employee));
}
@@ -221,3 +185,25 @@ void EmployeeManagementService::loadEmployees()
employees.emplace(std::make_pair(admin->getId(), admin));
}
}
void EmployeeManagementService::saveEmployees()
{
FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE);
FileManager<GeneralEmployee> generalEmployeeFileManager(Config::File::GENERAL_EMPLOYEES_FILE);
const auto& allEmployees = m_dataStore.getEmployees();
employeeMap employees;
std::map<std::string, std::shared_ptr<GeneralEmployee>> generalEmployees;
for (auto& employeePair : allEmployees)
{
if (employeePair.second->getEmployeeType() == Enums::EmployeeType::GENERAL)
{
generalEmployees.emplace(employeePair.first, std::static_pointer_cast<GeneralEmployee>(employeePair.second));
}
else
{
employees.emplace(employeePair);
}
}
employeeFileManager.save(employees);
generalEmployeeFileManager.save(generalEmployees);
}
@@ -18,4 +18,5 @@ public:
void updateProfile(const std::string&,const std::string&);
std::shared_ptr<const Employee> getCurrentEmployee();
void loadEmployees();
void saveEmployees();
};
@@ -1,6 +1,9 @@
#include <stdexcept>
#include "PayslipManagementService.h"
#include "ApplicationConfig.h"
#include "AuthorizationHelper.h"
#include "Enums.h"
#include "FileManager.h"
void PayslipManagementService::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
{
@@ -8,14 +11,40 @@ void PayslipManagementService::updateSalary(const std::string& employeeId, doubl
auto employee = m_dataStore.getEmployees().find(employeeId);
if (employee != m_dataStore.getEmployees().end() && employee->second->getEmployeeType() != Enums::EmployeeType::ADMIN)
{
(employee->second)->getPayroll()->setBasicSalary(basicSalary);
(employee->second)->getPayroll()->setHouseRentAllowance(houseRentAllowance);
(employee->second)->getPayroll()->setFoodAllowance(foodAllowance);
(employee->second)->getPayroll()->setEmployeePFContribution(employeePFContribution);
(employee->second)->getPayroll()->setEmployerPFContribution(employerPFContribution);
auto payroll = employee->second->getPayroll();
payroll->setBasicSalary(basicSalary);
payroll->setHouseRentAllowance(houseRentAllowance);
payroll->setFoodAllowance(foodAllowance);
payroll->setEmployeePFContribution(employeePFContribution);
payroll->setEmployerPFContribution(employerPFContribution);
}
else
{
throw std::runtime_error("Employee not found, unable to update the salary");
}
}
void PayslipManagementService::loadPayrolls()
{
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
auto& payrolls = m_dataStore.getPayrolls();
auto& employees = m_dataStore.getEmployees();
auto payrollObjects = payrollFileManager.load();
for (const auto& payrollPair : payrollObjects)
{
auto employeeIterator = employees.find(payrollPair.second->getEmployeeId());
if (employeeIterator == employees.end())
{
throw std::runtime_error("Payroll Object not associated with an existing employee");
}
employeeIterator->second->setEmployeePayroll(payrollPair.second);
}
payrolls.insert(payrollObjects.begin(), payrollObjects.end());
}
void PayslipManagementService::savePayrolls()
{
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
auto& payrolls = m_dataStore.getPayrolls();
payrollFileManager.save(payrolls);
}
@@ -10,4 +10,6 @@ private:
public:
PayslipManagementService() : m_dataStore(DataStore::getInstance()) {};
void updateSalary(const std::string&, double, double, double, double, double);
void loadPayrolls();
void savePayrolls();
};
+33 -5
View File
@@ -76,7 +76,7 @@ namespace Enums {
GENERAL,
IT,
FINANCE,
TAG,
TALENT_ACQUISITION,
HR,
TEAM,
ADMIN,
@@ -114,8 +114,8 @@ namespace Enums {
return "IT";
case EmployeeType::FINANCE:
return "FINANCE";
case EmployeeType::TAG:
return "TAG";
case EmployeeType::TALENT_ACQUISITION:
return "TALENT_ACQUISITION";
case EmployeeType::HR:
return "HR";
case EmployeeType::TEAM:
@@ -162,48 +162,76 @@ namespace Enums {
inline AccountStatus getAccountStatus(const std::string& input)
{
if (input == "ACTIVE")
{
return AccountStatus::ACTIVE;
}
if (input == "INACTIVE")
{
return AccountStatus::INACTIVE;
}
return AccountStatus::INACTIVE;
}
inline EmployeeType getEmployeeType(const std::string& input)
{
if (input == "GENERAL")
{
return EmployeeType::GENERAL;
}
if (input == "IT")
{
return EmployeeType::IT;
}
if (input == "FINANCE")
{
return EmployeeType::FINANCE;
if (input == "TAG")
return EmployeeType::TAG;
}
if (input == "TALENT_ACQUISITION")
{
return EmployeeType::TALENT_ACQUISITION;
}
if (input == "HR")
{
return EmployeeType::HR;
}
if (input == "TEAM")
{
return EmployeeType::TEAM;
}
if (input == "ADMIN")
{
return EmployeeType::ADMIN;
}
return EmployeeType::INVALID;
}
inline TeamStatus getTeamStatus(const std::string& str)
{
if (str == "IN_TEAM")
{
return TeamStatus::IN_TEAM;
}
if (str == "NOT_IN_TEAM")
{
return TeamStatus::NOT_IN_TEAM;
}
return TeamStatus::NOT_IN_TEAM;
}
inline EmployeeDesignation getEmployeeDesignation(const std::string& input)
{
if (input == "JUNIOR")
{
return EmployeeDesignation::JUNIOR;
}
if (input == "SENIOR")
{
return EmployeeDesignation::SENIOR;
}
if (input == "TEAM_LEAD")
{
return EmployeeDesignation::TEAM_LEAD;
}
return EmployeeDesignation::INVALID;
}
}
@@ -1,6 +1,6 @@
#include <string>
#include <cctype>
#include "Validator.h"
#include "Employee.h"
#include "ApplicationConfig.h"
bool util::isPhoneNumberValid(const std::string& phoneNumber) {
@@ -18,7 +18,10 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) {
bool util::isEmailValid(const std::string& email) {
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)
{
return false;
@@ -69,3 +72,54 @@ bool util::isPasswordValid(const std::string& password)
}
return hasUpper && hasLower && hasDigit && hasSpecial;
}
bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map<std::string, std::shared_ptr<Employee>> & employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeType() == employeeType && employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
return true;
}
}
return false;
}
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, std::shared_ptr<Employee>>& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeEmail() == email)
{
return true;
}
}
return false;
}
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, std::shared_ptr<Employee>>& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeePhone() == phone)
{
return true;
}
}
return false;
}
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<std::shared_ptr<const Employee>>& employees)
{
for (const auto& employee : employees)
{
if (employee->getEmployeePhone() == phone)
{
return true;
}
}
return false;
}
@@ -1,11 +1,21 @@
#pragma once
#include<string>
#include<map>
#include<memory>
#include<vector>
#include<algorithm>
#include<cctype>
#include "Enums.h"
class Employee;
namespace util
{
bool isPhoneNumberValid(const std::string&);
bool isEmailValid(const std::string&);
bool isPasswordValid(const std::string&);
bool hasActiveEmployeeOfType(Enums::EmployeeType, const std::map<std::string, std::shared_ptr<Employee>>&);
bool isEmailDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&);
bool isPhoneDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&);
bool isPhoneDuplicate(const std::string&, const std::vector<std::shared_ptr<const Employee>>&);
}
@@ -13,7 +13,7 @@ void AdminMenu::run()
{
int choice;
util::clear();
std::cout << "Admin Menu\n1. Create User\n2. View Employee\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. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
@@ -35,9 +35,9 @@ bool AdminMenu::handleOperation(int choice)
case 1:
createEmployee(m_zenvyController);
break;
/*case 2:
m_zenvyController.viewEmployee();
break;*/
case 2:
viewEmployees(m_zenvyController);
break;
case 3:
deactivateEmployee(m_zenvyController);
break;
@@ -1,4 +1,5 @@
#include <iostream>
#include<iomanip>
#include "EmployeeMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
@@ -13,7 +14,7 @@ void EmployeeMenu::run()
{
int choice;
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);
if (!handleOperation(choice))
{
@@ -50,11 +51,11 @@ bool EmployeeMenu::handleOperation(int choice)
break;
case 6:
m_zenvyController.viewTicketHistory();
break;
break;*/
case 7:
viewEmployees();
viewEmployees(m_zenvyController);
break;
case 8:
/*case 8:
m_zenvyController.searchEmployee();
break;
case 9:
@@ -83,6 +84,3 @@ bool EmployeeMenu::handleOperation(int choice)
}
return true;
}
@@ -28,49 +28,12 @@ void FinanceExecutiveMenu::run()
}
}
std::string FinanceExecutiveMenu::getSelectedUserId()
{
int choice;
std::map<int, std::shared_ptr<const Employee>> employeeList;
int index = 0;
auto allEmployees = m_zenvyController->getEmployees();
for (auto& currentEmployee : allEmployees)
{
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
{
continue;
}
employeeList[++index] = currentEmployee;
}
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(15) << "Employee Id"
<< std::setw(25) << "Name" << std::endl;
for (const auto& employee : employeeList)
{
std::cout << std::left << std::setw(6) << employee.first
<< std::setw(15) << employee.second->getId()
<< std::setw(25) << employee.second->getEmployeeName()
<< std::endl;
}
std::cout << "Enter the Index: ";
util::read(choice);
auto employeeIterator = employeeList.find(choice);
if (employeeIterator != employeeList.end())
{
return (employeeIterator->second->getId());
}
else
{
throw std::runtime_error("Invalid Index");
}
}
void FinanceExecutiveMenu::updatePayroll()
{
std::string employeeId;
double basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution;
employeeId = getSelectedUserId();
employeeId = selectEmployeeId(m_zenvyController->getEmployees());
util::clear();
if (employeeId != "") {
std::cout << "Enter the New Basic Salary: ";
util::read(basicSalary);
@@ -80,9 +43,11 @@ void FinanceExecutiveMenu::updatePayroll()
util::read(foodAllowance);
std::cout << "Enter the New EmployeePFContribution: ";
util::read(employeePFContribution);
std::cout << "Enter the New EmplyerPFContribution: ";
std::cout << "Enter the New EmployerPFContribution: ";
util::read(employerPFContribution);
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
std::cout << "Payroll Updated";
util::pressEnter();
}
else {
throw std::runtime_error("Unexpected error occured");
@@ -102,9 +67,9 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
case 4:
viewEmployees(m_zenvyController);
break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
@@ -134,5 +99,3 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
}
return true;
}
@@ -13,7 +13,6 @@ public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
std::string getSelectedUserId();
void updatePayroll();
};
@@ -32,44 +32,45 @@ bool HRManagerMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
//case 1:
// m_zenvyController.applyLeave();
// break;
//case 2:
// m_zenvyController.viewPayslip();
// break;
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
case 4:
m_zenvyController.viewEmployees();
viewEmployees(m_zenvyController);
break;
case 5:
m_zenvyController.searchEmployee();
break;
case 6:
m_zenvyController.viewNotifications();
break;
case 7:
m_zenvyController.viewAnnouncements();
break;*/
//case 5:
// m_zenvyController.searchEmployee();
// break;
//case 6:
// m_zenvyController.viewNotifications();
// break;
//case 7:
// m_zenvyController.viewAnnouncements();
// break;
case 8:
createEmployee(m_zenvyController);
break;
/*case 9:
m_zenvyController.regularizeAttenance();
break;
case 10:
m_zenvyController.updateLeaveRequest();
break;
case 11:
m_zenvyController.registercandidateAsEmployee();
break;*/
//case 9:
// m_zenvyController.regularizeAttenance();
// break;
//case 10:
// m_zenvyController.updateLeaveRequest();
// break;
//case 11:
// m_zenvyController.registercandidateAsEmployee();
// break;
case 12:
updateProfile(m_zenvyController);
break;
case 13:
deactivateEmployee(m_zenvyController);
break;
case 14:
return false;
default:
@@ -40,11 +40,11 @@ bool ITExecutiveMenu::handleOperation(int choice)
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
break;*/
case 4:
m_zenvyController.viewEmployees();
viewEmployees(m_zenvyController);
break;
case 5:
/*case 5:
m_zenvyController.searchEmployee();
break;
case 6:
@@ -11,14 +11,14 @@ static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
Enums::EmployeeType::IT,
Enums::EmployeeType::TEAM,
Enums::EmployeeType::FINANCE,
Enums::EmployeeType::TAG,
Enums::EmployeeType::TALENT_ACQUISITION,
Enums::EmployeeType::GENERAL
}},
{ Enums::EmployeeType::HR, {
Enums::EmployeeType::IT,
Enums::EmployeeType::TEAM,
Enums::EmployeeType::FINANCE,
Enums::EmployeeType::TAG,
Enums::EmployeeType::TALENT_ACQUISITION,
Enums::EmployeeType::GENERAL
}}
};
@@ -27,7 +27,7 @@ static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
{ Enums::EmployeeType::IT, "IT Executive" },
{ Enums::EmployeeType::TEAM, "Team Executive" },
{ Enums::EmployeeType::FINANCE, "Finance Executive" },
{ Enums::EmployeeType::TAG, "Talent Executive" },
{ Enums::EmployeeType::TALENT_ACQUISITION, "Talent Executive" },
{ Enums::EmployeeType::GENERAL, "General Employee" }
};
auto it = employeeTypeOptions.find(employeeType);
@@ -100,4 +100,5 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
util::read(phone);
controller->createEmployee(employeeType, employeeDesignation, email, name, phone);
std::cout << "\nCreated Employee Successfully.";
util::pressEnter();
}
+81 -37
View File
@@ -9,6 +9,7 @@
#include "MenuHelper.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "Validator.h"
#include "Enums.h"
void createEmployee(std::shared_ptr<ZenvyController> controller);
@@ -35,12 +36,25 @@ inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
util::read(name);
m_zenvyController->updateProfile(name, phone);
std::cout << "Profile Updated Successfully\n";
util::pressEnter();
break;
case 2:
std::cout << "Enter your updated phone Number: ";
util::read(phone);
if (!util::isPhoneNumberValid(phone))
{
std::cout << "Error: Invalid Phone Number";
util::pressEnter();
}
if (util::isPhoneDuplicate(phone, m_zenvyController->getEmployees()))
{
std::cout << "Error: Duplicate Phone Number!";
util::pressEnter();
return;
}
m_zenvyController->updateProfile(name, phone);
std::cout << "Profile Updated Successfully\n";
util::pressEnter();
break;
case 3:
return;
@@ -51,60 +65,90 @@ inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
}
}
inline std::map<int, std::shared_ptr<const Employee>> listEmployees(const std::shared_ptr<ZenvyController>& controller)
inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>> allEmployees)
{
auto employees = controller->getEmployees();
int choice;
std::map<int, std::shared_ptr<const Employee>> employeeList;
std::cout << std::left
<< std::setw(5) << "Index"
<< std::setw(15) << "ID"
<< std::setw(25) << "Name"
<< "\n";
int index = 1;
for (auto& activeEmployees : employees)
int index = 0;
util::clear();
std::cout << "Select the Employee\n";
for (auto& currentEmployee : allEmployees)
{
std::cout << std::left
<< std::setw(5) << index
<< std::setw(15) << activeEmployees->getId()
<< std::setw(25) << activeEmployees->getEmployeeName()
<< "\n";
employeeList[index] = activeEmployees;
++index;
}
if (employeeList.empty())
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
{
std::cout << "No active employees available.\n";
continue;
}
employeeList[++index] = currentEmployee;
}
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Employee ID"
<< std::setw(20) << "Name"
<< std::setw(20) << "Employee Type" << std::endl;
for (const auto& employee : employeeList)
{
std::cout << std::left << std::setw(10) << employee.first
<< std::setw(15) << employee.second->getId()
<< std::setw(20) << employee.second->getEmployeeName()
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
<< std::endl;
}
std::cout << "Enter the Index: ";
util::read(choice);
auto employeeIterator = employeeList.find(choice);
if (employeeIterator != employeeList.end())
{
return (employeeIterator->second->getId());
}
else
{
throw std::runtime_error("Invalid Index");
}
return employeeList;
}
inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller)
{
auto employeeList = listEmployees(controller);
if (employeeList.empty())
{
return;
}
int choice;
util::clear();
std::cout << "\nEnter the index of the employee to deactivate: ";
util::read(choice);
auto iterator = employeeList.find(choice);
if (iterator != employeeList.end())
{
std::string id = iterator->second->getId();
bool success = controller->deactivateEmployee(id);
if (success)
if(controller->deactivateEmployee(selectEmployeeId(controller->getEmployees())))
{
std::cout << "Employee deactivated successfully\n";
util::pressEnter();
}
else
{
std::cout << "Employee not found\n";
util::pressEnter();
}
}
else
inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
{
std::cout << "Invalid index.\n";
util::clear();
std::cout << "Employee List\n";
auto employees = m_zenvyController->getEmployees();
if (employees.empty())
{
std::cout << "No employees found\n";
util::pressEnter();
return;
}
std::cout << std::left
<< std::setw(15) << "Employee ID"
<< std::setw(25) << "Name"
<< std::setw(25) << "Role"
<< std::setw(25) << "Email"
<< std::setw(15) << "Phone"
<< std::setw(10) << "TeamId"
<< std::endl;
for (const auto& iterator : employees)
{
std::cout << std::left
<< std::setw(15) << iterator->getId()
<< std::setw(25) << iterator->getEmployeeName()
<< std::setw(25) << Enums::getEmployeeTypeString(iterator->getEmployeeType())
<< std::setw(25) << iterator->getEmployeeEmail()
<< std::setw(15) << iterator->getEmployeePhone()
<< std::setw(10) << iterator->getEmployeeTeamId()
<< std::endl;
}
util::pressEnter();
}
@@ -41,9 +41,9 @@ bool TalentExecutiveMenu::handleOperation(int choice)
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
case 4:
viewEmployees(m_zenvyController);
break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
@@ -41,9 +41,9 @@ bool TeamExecutiveMenu::handleOperation(int choice)
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
case 4:
viewEmployees(m_zenvyController);
break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
@@ -49,11 +49,11 @@ bool TeamLeadMenu::handleOperation(int choice)
break;
case 6:
m_zenvyController.viewTicketHistory();
break;
break;*/
case 7:
m_zenvyController.viewEmployees();
viewEmployees(m_zenvyController);
break;
case 8:
/*case 8:
m_zenvyController.searchEmployee();
break;
case 9:
@@ -47,6 +47,15 @@ void UserInterface::run()
util::pressEnter();
}
}
try
{
m_controller->persistStates();
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
return;
}
}
bool UserInterface::handleOperation(int choice)
@@ -142,7 +151,7 @@ void UserInterface::login()
menu.run();
break;
}
case Enums::EmployeeType::TAG:
case Enums::EmployeeType::TALENT_ACQUISITION:
{
TalentExecutiveMenu menu;
menu.run();