Implement View Payslip History
<UserStory> EMP011 : View Payslip History </UserStory> <Changes> - Implemented Enums::Month enum and helper functions getMonth() and getMonthString() for month formatting. - Created viewPayslipHistory() helper in MenuHelper.h to display payslip history in aligned tabular format. - Integrated viewPayslipHistory() option into EmployeeMenu, FinanceExecutiveMenu, HRManagerMenu, ITExecutiveMenu, TalentExecutiveMenu, TeamExecutiveMenu, and TeamLeadMenu. </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -53,6 +53,11 @@ void ZenvyController::generatePayslips()
|
||||
m_payslipManagementService->generatePayslips();
|
||||
}
|
||||
|
||||
payslipMap& ZenvyController::getPayslips()
|
||||
{
|
||||
return m_payslipManagementService->getPayslips();
|
||||
}
|
||||
|
||||
void ZenvyController::loadStates()
|
||||
{
|
||||
m_employeeManagementService->loadEmployees();
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
//Payslip management
|
||||
void updateSalary(const std::string&, double, double, double, double, double);
|
||||
void generatePayslips();
|
||||
payslipMap& getPayslips();
|
||||
|
||||
//File Management
|
||||
void loadStates();
|
||||
|
||||
@@ -26,6 +26,10 @@ void PayslipManagementService::updateSalary(const std::string& employeeId, doubl
|
||||
}
|
||||
}
|
||||
|
||||
payslipMap& PayslipManagementService::getPayslips() {
|
||||
return m_dataStore.getPayslips();
|
||||
}
|
||||
|
||||
void PayslipManagementService::generatePayslips()
|
||||
{
|
||||
util::enforceAuthorization(m_dataStore.getAuthenticatedEmployee()->getEmployeeType(), Enums::EmployeeType::FINANCE);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include<stdexcept>
|
||||
#include"DataStore.h"
|
||||
|
||||
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>;
|
||||
|
||||
class PayslipManagementService
|
||||
{
|
||||
private:
|
||||
@@ -10,6 +12,7 @@ private:
|
||||
public:
|
||||
PayslipManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||
void updateSalary(const std::string&, double, double, double, double, double);
|
||||
payslipMap& getPayslips();
|
||||
void generatePayslips();
|
||||
void loadPayrolls();
|
||||
void savePayrolls();
|
||||
|
||||
@@ -91,6 +91,23 @@ namespace Enums {
|
||||
INVALID_PASSWORD
|
||||
};
|
||||
|
||||
enum class Month
|
||||
{
|
||||
JANUARY,
|
||||
FEBRUARY,
|
||||
MARCH,
|
||||
APRIL,
|
||||
MAY,
|
||||
JUNE,
|
||||
JULY,
|
||||
AUGUST,
|
||||
SEPTEMBER,
|
||||
OCTOBER,
|
||||
NOVEMBER,
|
||||
DECEMBER,
|
||||
INVALID
|
||||
};
|
||||
|
||||
inline std::string getAccountStatusString(AccountStatus status)
|
||||
{
|
||||
switch (status)
|
||||
@@ -170,6 +187,27 @@ namespace Enums {
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string getMonthString(Month month)
|
||||
{
|
||||
switch (month)
|
||||
{
|
||||
case Month::JANUARY : return "January";
|
||||
case Month::FEBRUARY: return "February";
|
||||
case Month::MARCH: return "March";
|
||||
case Month::APRIL: return "April";
|
||||
case Month::MAY: return "May";
|
||||
case Month::JUNE: return "June";
|
||||
case Month::JULY: return "July";
|
||||
case Month::AUGUST: return "August";
|
||||
case Month::SEPTEMBER: return "September";
|
||||
case Month::OCTOBER: return "October";
|
||||
case Month::NOVEMBER: return "November";
|
||||
case Month::DECEMBER: return "December";
|
||||
case Month::INVALID: return "Invalid Month";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
inline AccountStatus getAccountStatus(const std::string& input)
|
||||
{
|
||||
if (input == "ACTIVE")
|
||||
@@ -245,4 +283,26 @@ namespace Enums {
|
||||
}
|
||||
return EmployeeDesignation::INVALID;
|
||||
}
|
||||
|
||||
inline Month getMonth(const int inputMonth)
|
||||
{
|
||||
switch (inputMonth)
|
||||
{
|
||||
case 1: return Month::JANUARY;
|
||||
case 2: return Month::FEBRUARY;
|
||||
case 3: return Month::MARCH;
|
||||
case 4: return Month::APRIL;
|
||||
case 5: return Month::MAY;
|
||||
case 6: return Month::JUNE;
|
||||
case 7: return Month::JULY;
|
||||
case 8: return Month::AUGUST;
|
||||
case 9: return Month::SEPTEMBER;
|
||||
case 10: return Month::OCTOBER;
|
||||
case 11: return Month::NOVEMBER;
|
||||
case 12: return Month::DECEMBER;
|
||||
default: return Month::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,17 +33,16 @@ bool EmployeeMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
/*
|
||||
case 1:
|
||||
/*case 1:
|
||||
m_zenvyController.applyLeave();
|
||||
break;
|
||||
case 2:
|
||||
m_zenvyController.viewPayslip();
|
||||
break;
|
||||
break;*/
|
||||
case 3:
|
||||
m_zenvyController.viewPayslipHistory();
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4 :
|
||||
/*case 4 :
|
||||
m_zenvyController.raiseTicket();
|
||||
break;
|
||||
case 5 :
|
||||
|
||||
@@ -65,6 +65,9 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,9 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,9 @@ bool ITExecutiveMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <utility>
|
||||
#include "Enums.h"
|
||||
@@ -15,6 +17,33 @@
|
||||
|
||||
void createEmployee(std::shared_ptr<ZenvyController> controller);
|
||||
|
||||
inline void viewPayslipHistory(std::shared_ptr<ZenvyController> controller)
|
||||
{
|
||||
auto employeePayslips = controller->getCurrentEmployee()->getEmployeePayslips();
|
||||
util::clear();
|
||||
std::cout << "Payslips\n" << std::endl;
|
||||
std::cout << std::left
|
||||
<< std::setw(15) << "Date"
|
||||
<< std::setw(15) << "Payslip ID"
|
||||
<< std::setw(15) << "Employee ID"
|
||||
<< std::setw(12) << "Salary"
|
||||
<< std::setw(25) << "TimeStamp"
|
||||
<< std::endl;
|
||||
for (const auto& payslip : employeePayslips)
|
||||
{
|
||||
std::ostringstream dateStream;
|
||||
dateStream << payslip.second->getTimestamp().getYear() << " - " << Enums::getMonthString(Enums::getMonth(payslip.second->getTimestamp().getMonth()));
|
||||
std::cout << std::left
|
||||
<< std::setw(15) << dateStream.str()
|
||||
<< std::setw(15) << payslip.first
|
||||
<< std::setw(15) << payslip.second->getEmployeeId()
|
||||
<< std::setw(12) << payslip.second->getSalary()
|
||||
<< std::setw(25) << payslip.second->getTimestamp().toString()
|
||||
<< std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
inline void viewProfile(std::shared_ptr<ZenvyController> controller)
|
||||
{
|
||||
util::clear();
|
||||
|
||||
@@ -32,6 +32,9 @@ bool TalentExecutiveMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,9 @@ bool TeamExecutiveMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,9 @@ bool TeamLeadMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 3:
|
||||
viewPayslipHistory(m_zenvyController);
|
||||
break;
|
||||
case 7:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user