refactor: change memory management and fix related code
- Switched shared_ptr to raw pointers - Added cleanup logic in DataStore - Fixed Factory object creation - Updated function signatures to match changes - Small refactors and formatting fixes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <stdexcept>
|
||||
#include "FileIO.h"
|
||||
|
||||
template <typename T> using objects = std::map<std::string, std::shared_ptr<T>>;
|
||||
template <typename T> using objects = std::map<std::string, T*>;
|
||||
|
||||
template <typename T>
|
||||
class FileManager
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
* password - password of the employee
|
||||
* Returns:
|
||||
* Tuple - login status, employee type, employee designation
|
||||
* login status - success or failed
|
||||
* login status - success or failed
|
||||
* employee type - type of the employee logged in
|
||||
* employee designation - designation if employee type is GENERAL.
|
||||
*/
|
||||
|
||||
AuthenticationDTO ZenvyController::login(const std::string& email, const std::string& password)
|
||||
{
|
||||
return m_authenticationManagementService->login(email, password);
|
||||
return m_authenticationManagementService->login(email, password);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -36,7 +35,7 @@ AuthenticationDTO ZenvyController::login(const std::string& email, const std::st
|
||||
|
||||
void ZenvyController::logout()
|
||||
{
|
||||
m_authenticationManagementService->logout();
|
||||
m_authenticationManagementService->logout();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -50,73 +49,73 @@ void ZenvyController::logout()
|
||||
|
||||
void ZenvyController::changePassword(const std::string& password)
|
||||
{
|
||||
m_authenticationManagementService->changePassword(password);
|
||||
m_authenticationManagementService->changePassword(password);
|
||||
}
|
||||
|
||||
//Employee Management
|
||||
void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone)
|
||||
void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone) const
|
||||
{
|
||||
m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone);
|
||||
m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone);
|
||||
}
|
||||
|
||||
bool ZenvyController::deactivateEmployee(const std::string& id)
|
||||
bool ZenvyController::deactivateEmployee(const std::string& id) const
|
||||
{
|
||||
return m_employeeManagementService->deactivateEmployee(id);
|
||||
return m_employeeManagementService->deactivateEmployee(id);
|
||||
}
|
||||
|
||||
void ZenvyController::updateProfile(const std::string& name, const std::string& phone)
|
||||
{
|
||||
m_employeeManagementService->updateProfile(name,phone);
|
||||
m_employeeManagementService->updateProfile(name, phone);
|
||||
}
|
||||
|
||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> ZenvyController::searchEmployee(const std::string& name)
|
||||
std::pair<Enums::EmployeeType, std::vector<const Employee*>> ZenvyController::searchEmployee(const std::string& name)
|
||||
{
|
||||
return m_employeeManagementService->searchEmployee(name);
|
||||
return m_employeeManagementService->searchEmployee(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<const Employee> ZenvyController::getCurrentEmployee()
|
||||
const Employee* ZenvyController::getCurrentEmployee() const
|
||||
{
|
||||
return m_employeeManagementService->getCurrentEmployee();
|
||||
return m_employeeManagementService->getCurrentEmployee();
|
||||
}
|
||||
|
||||
bool ZenvyController::updateDesignation(const std::string& id,Enums::EmployeeDesignation designation)
|
||||
bool ZenvyController::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation)
|
||||
{
|
||||
return m_employeeManagementService->updateDesignation(id,designation);
|
||||
return m_employeeManagementService->updateDesignation(id, designation);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Candidate>> ZenvyController::getShorlistedCandidates()
|
||||
std::vector<Candidate*> ZenvyController::getShorlistedCandidates() const
|
||||
{
|
||||
return m_employeeManagementService->getShorlistedCandidates();
|
||||
return m_employeeManagementService->getShorlistedCandidates();
|
||||
}
|
||||
|
||||
//Payslip Management
|
||||
void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
|
||||
{
|
||||
m_payslipManagementService->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
||||
m_payslipManagementService->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
||||
}
|
||||
|
||||
void ZenvyController::generatePayslips()
|
||||
{
|
||||
m_payslipManagementService->generatePayslips();
|
||||
m_payslipManagementService->generatePayslips();
|
||||
}
|
||||
|
||||
void ZenvyController::loadStates()
|
||||
{
|
||||
m_employeeManagementService->loadEmployees();
|
||||
m_payslipManagementService->loadPayrolls();
|
||||
m_payslipManagementService->loadPayslips();
|
||||
m_employeeManagementService->loadEmployees();
|
||||
m_payslipManagementService->loadPayrolls();
|
||||
m_payslipManagementService->loadPayslips();
|
||||
}
|
||||
|
||||
void ZenvyController::persistStates()
|
||||
{
|
||||
m_employeeManagementService->saveEmployees();
|
||||
m_payslipManagementService->savePayrolls();
|
||||
m_payslipManagementService->savePayslips();
|
||||
m_employeeManagementService->saveEmployees();
|
||||
m_payslipManagementService->savePayrolls();
|
||||
m_payslipManagementService->savePayslips();
|
||||
}
|
||||
|
||||
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>> ZenvyController::getPayslipForMonth(const std::string& employeeId, int year, int month)
|
||||
std::pair<Payroll*, Payslip*> ZenvyController::getPayslipForMonth(const std::string& employeeId, int year, int month)
|
||||
{
|
||||
return m_payslipManagementService->getPayslipForMonth(employeeId, year, month);
|
||||
return m_payslipManagementService->getPayslipForMonth(employeeId, year, month);
|
||||
}
|
||||
|
||||
ZenvyController::~ZenvyController()
|
||||
@@ -131,4 +130,4 @@ ZenvyController::~ZenvyController()
|
||||
delete m_talentAcquisitionManagementService;
|
||||
delete m_teamManagementService;
|
||||
delete m_ticketManagementService;
|
||||
}
|
||||
}
|
||||
@@ -22,55 +22,56 @@
|
||||
class ZenvyController
|
||||
{
|
||||
private:
|
||||
AuthenticationManagementService* m_authenticationManagementService;
|
||||
AttendanceManagementService* m_attendanceManagementService;
|
||||
BookingManagementService* m_bookingManagementService;
|
||||
EmployeeManagementService* m_employeeManagementService;
|
||||
LeaveManagementService* m_leaveManagementService;
|
||||
NotificationManagementService* m_notificationManagementService;
|
||||
PayslipManagementService* m_payslipManagementService;
|
||||
TalentAcquisitionManagementService* m_talentAcquisitionManagementService;
|
||||
TeamManagementService* m_teamManagementService;
|
||||
TicketManagementService* m_ticketManagementService;
|
||||
AuthenticationManagementService* m_authenticationManagementService;
|
||||
AttendanceManagementService* m_attendanceManagementService;
|
||||
BookingManagementService* m_bookingManagementService;
|
||||
EmployeeManagementService* m_employeeManagementService;
|
||||
LeaveManagementService* m_leaveManagementService;
|
||||
NotificationManagementService* m_notificationManagementService;
|
||||
PayslipManagementService* m_payslipManagementService;
|
||||
TalentAcquisitionManagementService* m_talentAcquisitionManagementService;
|
||||
TeamManagementService* m_teamManagementService;
|
||||
TicketManagementService* m_ticketManagementService;
|
||||
public:
|
||||
ZenvyController() :
|
||||
m_authenticationManagementService(new AuthenticationManagementService()),
|
||||
m_attendanceManagementService(new AttendanceManagementService()),
|
||||
m_bookingManagementService(new BookingManagementService()),
|
||||
m_employeeManagementService(new EmployeeManagementService()),
|
||||
m_leaveManagementService(new LeaveManagementService()),
|
||||
m_notificationManagementService(new NotificationManagementService()),
|
||||
m_payslipManagementService(new PayslipManagementService()),
|
||||
m_talentAcquisitionManagementService(new TalentAcquisitionManagementService()),
|
||||
m_teamManagementService(new TeamManagementService()),
|
||||
m_ticketManagementService(new TicketManagementService()) {};
|
||||
|
||||
//Authentication
|
||||
AuthenticationDTO login(const std::string& email, const std::string& password);
|
||||
void logout();
|
||||
void changePassword(const std::string&);
|
||||
ZenvyController() :
|
||||
m_authenticationManagementService(new AuthenticationManagementService()),
|
||||
m_attendanceManagementService(new AttendanceManagementService()),
|
||||
m_bookingManagementService(new BookingManagementService()),
|
||||
m_employeeManagementService(new EmployeeManagementService()),
|
||||
m_leaveManagementService(new LeaveManagementService()),
|
||||
m_notificationManagementService(new NotificationManagementService()),
|
||||
m_payslipManagementService(new PayslipManagementService()),
|
||||
m_talentAcquisitionManagementService(new TalentAcquisitionManagementService()),
|
||||
m_teamManagementService(new TeamManagementService()),
|
||||
m_ticketManagementService(new TicketManagementService()) {};
|
||||
~ZenvyController();
|
||||
|
||||
//Employee Management
|
||||
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
|
||||
bool deactivateEmployee(const std::string&);
|
||||
std::shared_ptr<const Employee> getCurrentEmployee();
|
||||
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();
|
||||
//Authentication
|
||||
AuthenticationDTO login(const std::string& email, const std::string& password);
|
||||
void logout();
|
||||
void changePassword(const std::string&);
|
||||
|
||||
template <typename ...Types>
|
||||
Employees getEmployees(Types ...types)
|
||||
{
|
||||
return m_employeeManagementService->getEmployees(types...);
|
||||
}
|
||||
//Employee Management
|
||||
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&) const;
|
||||
bool deactivateEmployee(const std::string&) const;
|
||||
const Employee* getCurrentEmployee() const;
|
||||
void updateProfile(const std::string&, const std::string&);
|
||||
std::pair<Enums::EmployeeType, std::vector<const Employee*>> searchEmployee(const std::string&);
|
||||
bool updateDesignation(const std::string&, Enums::EmployeeDesignation);
|
||||
std::vector<Candidate*> getShorlistedCandidates() const;
|
||||
|
||||
//Payslip management
|
||||
void updateSalary(const std::string&, double, double, double, double, double);
|
||||
void generatePayslips();
|
||||
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>>getPayslipForMonth(const std::string&, int, int);
|
||||
template <typename ...Types>
|
||||
Employees getEmployees(Types ...types) const
|
||||
{
|
||||
return m_employeeManagementService->getEmployees(types...);
|
||||
}
|
||||
|
||||
//File Management
|
||||
void loadStates();
|
||||
void persistStates();
|
||||
};
|
||||
//Payslip management
|
||||
void updateSalary(const std::string&, double, double, double, double, double);
|
||||
void generatePayslips();
|
||||
std::pair<Payroll*, Payslip*>getPayslipForMonth(const std::string&, int, int);
|
||||
|
||||
//File Management
|
||||
void loadStates();
|
||||
void persistStates();
|
||||
};
|
||||
@@ -8,19 +8,19 @@
|
||||
#include "DataStore.h"
|
||||
#include "EmployeeManagementService.h"
|
||||
|
||||
/*
|
||||
* Function: getInstance
|
||||
* Description: provides a singleton instance of the DataStore.
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* DataStore& - reference to the single DataStore object.
|
||||
*/
|
||||
/*
|
||||
* Function: getInstance
|
||||
* Description: provides a singleton instance of the DataStore.
|
||||
* Parameters:
|
||||
* None
|
||||
* Returns:
|
||||
* DataStore& - reference to the single DataStore object.
|
||||
*/
|
||||
|
||||
DataStore& DataStore::getInstance()
|
||||
{
|
||||
static DataStore dataStore;
|
||||
return dataStore;
|
||||
static DataStore dataStore;
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -34,7 +34,7 @@ DataStore& DataStore::getInstance()
|
||||
|
||||
logMap& DataStore::getLogs()
|
||||
{
|
||||
return m_logs;
|
||||
return m_logs;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -48,7 +48,7 @@ logMap& DataStore::getLogs()
|
||||
|
||||
Employee*& DataStore::getAuthenticatedEmployee()
|
||||
{
|
||||
return m_authenticatedEmployee;
|
||||
return m_authenticatedEmployee;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -62,7 +62,7 @@ Employee*& DataStore::getAuthenticatedEmployee()
|
||||
|
||||
void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee)
|
||||
{
|
||||
m_authenticatedEmployee = authenticatedEmployee;
|
||||
m_authenticatedEmployee = authenticatedEmployee;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -76,12 +76,22 @@ void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee)
|
||||
|
||||
employeeMap& DataStore::getEmployees()
|
||||
{
|
||||
return m_employees;
|
||||
return m_employees;
|
||||
}
|
||||
|
||||
payrollMap& DataStore::getPayrolls()
|
||||
{
|
||||
return m_payrolls;
|
||||
return m_payrolls;
|
||||
}
|
||||
|
||||
payslipMap& DataStore::getPayslips()
|
||||
{
|
||||
return m_payslips;
|
||||
}
|
||||
|
||||
candidateMap& DataStore::getCandidates()
|
||||
{
|
||||
return m_candidates;
|
||||
}
|
||||
|
||||
DataStore::~DataStore()
|
||||
@@ -91,19 +101,25 @@ DataStore::~DataStore()
|
||||
delete pair.second;
|
||||
}
|
||||
m_employees.clear();
|
||||
for (auto& pair : m_payrolls)
|
||||
{
|
||||
delete pair.second;
|
||||
}
|
||||
m_payrolls.clear();
|
||||
for (auto& pair : m_payslips)
|
||||
{
|
||||
delete pair.second;
|
||||
}
|
||||
m_payslips.clear();
|
||||
for (auto& pair : m_logs)
|
||||
{
|
||||
delete pair.second;
|
||||
}
|
||||
m_logs.clear();
|
||||
if (m_authenticatedEmployee)
|
||||
for (auto& pair : m_candidates)
|
||||
{
|
||||
delete m_authenticatedEmployee;
|
||||
m_authenticatedEmployee = nullptr;
|
||||
delete pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
payslipMap& DataStore::getPayslips()
|
||||
{
|
||||
return m_payslips;
|
||||
m_candidates.clear();
|
||||
m_authenticatedEmployee = nullptr;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
DataStore& operator=(const DataStore&) = delete;
|
||||
DataStore(DataStore&&) = delete;
|
||||
DataStore& operator=(DataStore&&) = delete;
|
||||
employeeMap& getEmployees();
|
||||
employeeMap& getEmployees();
|
||||
payrollMap& getPayrolls();
|
||||
payslipMap& getPayslips();
|
||||
logMap& getLogs();
|
||||
|
||||
@@ -20,11 +20,10 @@ public:
|
||||
* Args - constructor arguments forwarded to T's constructor
|
||||
* Returns:
|
||||
* std::shared_ptr<T> - a shared pointer managing the newly created object
|
||||
*/
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static T* getObject(Args&&... args)
|
||||
{
|
||||
return T*(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
*/;
|
||||
template<typename T, typename... Args>
|
||||
static T* getObject(Args&&... args)
|
||||
{
|
||||
return new T(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
m_accountStatus(Enums::AccountStatus::ACTIVE),
|
||||
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
|
||||
m_teamId(""),
|
||||
m_payroll(nullptr),
|
||||
m_employeeType(Enums::EmployeeType::GENERAL) {}
|
||||
Employee(const std::string& name,
|
||||
const std::string& phone,
|
||||
|
||||
@@ -7,7 +7,6 @@ File: JobListing.h
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "Candidate.h"
|
||||
#include "Enums.h"
|
||||
using candidateMap = std::map<std::string, Candidate*>;
|
||||
|
||||
@@ -4,6 +4,7 @@ File: Payroll.cpp
|
||||
* Author : Trenser
|
||||
* Created : 31-Mar-2026
|
||||
*/
|
||||
#include <sstream>
|
||||
#include "Payroll.h"
|
||||
#include "StringHelper.h"
|
||||
#include "Factory.h"
|
||||
|
||||
@@ -6,7 +6,6 @@ File: Payroll.h
|
||||
*/
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "Timestamp.h"
|
||||
|
||||
class Payroll
|
||||
|
||||
@@ -5,7 +5,6 @@ File: Payslip.h
|
||||
* Created : 31-Mar-2026
|
||||
*/
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Timestamp.h"
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ File: Room.h
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "Booking.h"
|
||||
using bookingMap = std::map<std::string, Booking*>;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ File: Team.h
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "Employee.h"
|
||||
using employeeMap = std::map<std::string, Employee*>;
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
|
||||
throw std::runtime_error("No authenticated user");
|
||||
}
|
||||
Enums::EmployeeType authenticatedEmployeeType = authenticatedEmployee->getEmployeeType();
|
||||
Employee* employee;
|
||||
Payroll* payroll;
|
||||
Employee* employee = nullptr;
|
||||
Payroll* payroll = nullptr;
|
||||
if (employeeType != Enums::EmployeeType::GENERAL && util::hasActiveEmployeeOfType(employeeType, employees))
|
||||
{
|
||||
throw std::runtime_error("Cannot create more than one employee of type " + Enums::getEmployeeTypeString(employeeType));
|
||||
|
||||
@@ -7,23 +7,23 @@
|
||||
#include "Enums.h"
|
||||
#include "StringHelper.h"
|
||||
|
||||
using Employees = std::vector<std::shared_ptr<const Employee>>;
|
||||
using Employees = std::vector<const Employee*>;
|
||||
|
||||
class EmployeeManagementService
|
||||
{
|
||||
private:
|
||||
DataStore& m_dataStore;
|
||||
DataStore& m_dataStore;
|
||||
public:
|
||||
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
|
||||
bool deactivateEmployee(const std::string&);
|
||||
bool updateDesignation(const std::string&,Enums::EmployeeDesignation);
|
||||
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();
|
||||
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
|
||||
bool deactivateEmployee(const std::string&);
|
||||
bool updateDesignation(const std::string&, Enums::EmployeeDesignation);
|
||||
void updateProfile(const std::string&, const std::string&);
|
||||
std::pair<Enums::EmployeeType, std::vector<const Employee*>> searchEmployee(const std::string&);
|
||||
const Employee* getCurrentEmployee();
|
||||
std::vector<Candidate*> getShorlistedCandidates();
|
||||
void loadEmployees();
|
||||
void saveEmployees();
|
||||
|
||||
template<typename... Types>
|
||||
Employees getEmployees(Types... types)
|
||||
@@ -52,8 +52,8 @@ public:
|
||||
std::sort(
|
||||
filteredEmployees.begin(),
|
||||
filteredEmployees.end(),
|
||||
[](const std::shared_ptr<const Employee>& employeeOne,
|
||||
const std::shared_ptr<const Employee>& employeeTwo)
|
||||
[](const Employee* employeeOne,
|
||||
const Employee* employeeTwo)
|
||||
{
|
||||
return util::extractNumber(employeeOne->getId()) <
|
||||
util::extractNumber(employeeTwo->getId());
|
||||
@@ -61,4 +61,4 @@ public:
|
||||
);
|
||||
return filteredEmployees;
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -112,7 +112,7 @@ 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)
|
||||
bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map<std::string, Employee*> & employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, std::shared_ptr<Employee>>& employees)
|
||||
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, Employee*>& employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ bool util::isEmailDuplicate(const std::string& email, const std::map<std::string
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, std::shared_ptr<Employee>>& employees)
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, Employee*>& employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<std::shared_ptr<const Employee>>& employees)
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<const Employee*>& employees)
|
||||
{
|
||||
for (const auto& employee : employees)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* Author: Trenser
|
||||
* Created: 01-Apr-2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include<string>
|
||||
#include<map>
|
||||
@@ -21,8 +20,8 @@ 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>>&);
|
||||
bool hasActiveEmployeeOfType(Enums::EmployeeType, const std::map<std::string, Employee*>&);
|
||||
bool isEmailDuplicate(const std::string&, const std::map<std::string, Employee*>&);
|
||||
bool isPhoneDuplicate(const std::string&, const std::map<std::string, Employee*>&);
|
||||
bool isPhoneDuplicate(const std::string&, const std::vector<const Employee*>&);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -22,7 +21,7 @@ void addShortlistedCandidateAsEmployee(const ZenvyController* m_zenvyController)
|
||||
|
||||
inline void viewPayslipHistory(ZenvyController* m_zenvyController)
|
||||
{
|
||||
auto employeePayslips = m_zenvyController->getCurrentEmployee()->getEmployeePayslips();
|
||||
auto& employeePayslips = m_zenvyController->getCurrentEmployee()->getEmployeePayslips();
|
||||
util::clear();
|
||||
if (employeePayslips.empty())
|
||||
{
|
||||
@@ -147,7 +146,7 @@ inline void updateProfile(ZenvyController* m_zenvyController)
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string selectEmployeeId(std::vector<const Employee*>& allEmployees)
|
||||
inline std::string selectEmployeeId(const std::vector<const Employee*>& allEmployees)
|
||||
{
|
||||
int choice;
|
||||
std::map<int, const Employee*> employeeList;
|
||||
@@ -353,7 +352,7 @@ inline void viewPayslip(ZenvyController* m_zenvyController)
|
||||
if (payroll && payslip)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Payslip for " << employee->getEmployeeName() << " (" << year << "-" << std::setw(2) << std::setfill('0') << month << ")\n\n";
|
||||
std::cout << "Payslip for " << employee->getEmployeeName() << " (" << year << "-" << std::setw(2) << month << ")\n\n";
|
||||
std::cout << "Basic Salary : " << payroll->getBasicSalary() << "\n";
|
||||
std::cout << "House Rent Allowance : " << payroll->getHouseRentAllowance() << "\n";
|
||||
std::cout << "Food Allowance : " << payroll->getFoodAllowance() << "\n";
|
||||
|
||||
Reference in New Issue
Block a user