Files
Training-Team2-Zenvy-Jan26/Trenser.Zenvy/Trenser.Zenvy/views/FinanceExecutiveMenu.cpp
T
2026-04-17 12:29:54 +05:30

122 lines
3.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* File: FinanceExecutiveMenu.cpp
* Description: Implements the FinanceExecutiveMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream>
#include "FinanceExecutiveMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "MenuHelper.h"
#include "Timestamp.h"
/*
* Function: FinanceExecutiveMenu::run
* Description: Starts the finance executive menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void FinanceExecutiveMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Finance Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notifications\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslips\n10. Update Payroll\n11. Update Profile\n12. View Profile \n13. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
void FinanceExecutiveMenu::updatePayroll()
{
std::string employeeId;
double basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution;
employeeId = selectEmployeeId(m_zenvyController->getEmployees());
util::clear();
if (employeeId != "") {
std::cout << "Enter the New Basic Salary: ";
util::read(basicSalary);
std::cout << "Enter the New House Rent Allowance: ";
util::read(houseRentAllowance);
std::cout << "Enter the New Food Allowance: ";
util::read(foodAllowance);
std::cout << "Enter the New EmployeePFContribution: ";
util::read(employeePFContribution);
std::cout << "Enter the New EmployerPFContribution: ";
util::read(employerPFContribution);
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
std::cout << "Payroll Updated";
util::pressEnter();
}
}
void FinanceExecutiveMenu::generatePayslips()
{
util::Timestamp currentTimestamp;
util::clear();
m_zenvyController->generatePayslips();
std::cout << "Generated payslips for the month of " << currentTimestamp.getMonth() << "-" << currentTimestamp.getYear() << " successfully.";
util::pressEnter();
}
/*
* Function: FinanceExecutiveMenu::handleOperation
* Description: Handles the finance executives menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the finance executive chooses to logout
*/
bool FinanceExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
case 4:
viewEmployees(m_zenvyController);
break;
case 5:
searchEmployee(m_zenvyController);
break;
case 9:
generatePayslips();
break;
case 10:
updatePayroll();
break;
case 11:
updateProfile(m_zenvyController);
break;
case 12:
viewProfile(m_zenvyController);
break;
case 13:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
util::pressEnter();
}
return true;
}