1820 lines
78 KiB
C#
1820 lines
78 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Dynamic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net.Http.Headers;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using AutoMapper.Configuration;
|
|
using Ease.Core;
|
|
using HRM.BO;
|
|
using HRM.DA;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.StaticFiles;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Payroll.BO;
|
|
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
|
|
|
|
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
namespace HRM.UI.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/finalsettlement")]
|
|
[Authorize]
|
|
public class FinalSettlementController : Controller
|
|
{
|
|
#region Declerations
|
|
|
|
private readonly IClaimBasicService _claimBasicService;
|
|
private readonly IClaimBasicItemService _claimBasicItemService;
|
|
private readonly IClaimRuleService _claimRuleService;
|
|
private readonly IConfiguration _config;
|
|
private readonly IEmployeeService _employeeService;
|
|
private readonly IClaimRequisitionService _claimRequisitionService;
|
|
private readonly IFSHeadService _ifsHeadService;
|
|
private readonly IWFMovementTranService _wfMovementTranService;
|
|
private readonly IResignationRequestService _resignationRequestService;
|
|
private readonly ISearchEmployeeService _serachManager;
|
|
private readonly IFSTranDetailService _fsTranDetailService;
|
|
private readonly IFSTranService _fsTranService;
|
|
private readonly IADParameterService _adpParameterService;
|
|
private readonly IADParameterEmployeeService _adpParameterEmployeeService;
|
|
private readonly IAllowanceDeductionService _allowanceDeductionService;
|
|
private readonly ILoanService _loanService;
|
|
private readonly ILoanIssueService _loanIssueService;
|
|
private readonly ILoanScheduleService _loanScheduleService;
|
|
private readonly IUserService _userService;
|
|
private readonly ILeaveProcessService _leaveService;
|
|
private readonly IFinalSettlementService _finalSettlementService;
|
|
private readonly ISettlementClearanceService _settlementClearanceService;
|
|
private readonly ISettlementAdvanceService _settlementAdviceService;
|
|
|
|
List<ProportionateSalaryFill> fracSalaryFillList = new List<ProportionateSalaryFill>();
|
|
List<GrossSalaryList> grossSalaryFillList = new List<GrossSalaryList>();
|
|
|
|
private int _resignationReqId=0;
|
|
|
|
//SendEma sendEmailNotification = null;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public FinalSettlementController(IConfiguration config,
|
|
IClaimBasicService claimBasicService,
|
|
IClaimBasicItemService claimBasicItemService,
|
|
IClaimRuleService claimRuleService,
|
|
IEmployeeService employeeService,
|
|
IClaimRequisitionService claimRequisitionService,
|
|
IWFMovementTranService wfMovementTranService,
|
|
IFSHeadService ifsHeadService,
|
|
IResignationRequestService resignationRequestService,
|
|
ISearchEmployeeService searchManager,
|
|
IFSTranDetailService fsTranDetailService,
|
|
IFSTranService fsTranService,
|
|
IADParameterService adpParameterService,
|
|
IADParameterEmployeeService adpParameterEmployeeService,
|
|
IAllowanceDeductionService allowanceDeductionService,
|
|
ILoanService loanService,
|
|
ILoanIssueService loanIssueService,
|
|
ILoanScheduleService loanScheduleService,
|
|
IUserService userService,
|
|
ILeaveProcessService leaveProcessService,
|
|
IFinalSettlementService finalSettlementService,
|
|
ISettlementClearanceService settlementClearanceService,
|
|
ISettlementAdvanceService settlementAdvanceService)
|
|
{
|
|
_config = config;
|
|
_claimBasicService = claimBasicService;
|
|
_claimBasicItemService = claimBasicItemService;
|
|
_claimRuleService = claimRuleService;
|
|
_employeeService = employeeService;
|
|
_claimRequisitionService = claimRequisitionService;
|
|
_wfMovementTranService = wfMovementTranService;
|
|
_ifsHeadService = ifsHeadService;
|
|
_resignationRequestService = resignationRequestService;
|
|
_serachManager = searchManager;
|
|
_fsTranDetailService = fsTranDetailService;
|
|
_fsTranService = fsTranService;
|
|
_adpParameterService = adpParameterService;
|
|
_adpParameterEmployeeService = adpParameterEmployeeService;
|
|
_allowanceDeductionService = allowanceDeductionService;
|
|
_loanService = loanService;
|
|
_loanIssueService = loanIssueService;
|
|
_loanScheduleService = loanScheduleService;
|
|
_userService = userService;
|
|
_leaveService = leaveProcessService;
|
|
_finalSettlementService = finalSettlementService;
|
|
_settlementClearanceService = settlementClearanceService;
|
|
_settlementAdviceService = settlementAdvanceService;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Functions
|
|
[HttpPost]
|
|
[Route("savefinalsettementhead")]
|
|
public ActionResult SaveFinalSettlementHead(FSHead item)
|
|
{
|
|
int ans;
|
|
var isNew = item.ID <= 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if (isNew)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
//item.PayrollTypeID = (int)currentUser.PayrollTypeID;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (item.EmpID == 0)
|
|
item.EmpID = null;
|
|
|
|
if (item.EmpIDTwo == 0)
|
|
item.EmpIDTwo = null;
|
|
|
|
ans = _ifsHeadService.Save(item);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getFSHeads")]
|
|
public ActionResult GetFSHeads()
|
|
{
|
|
List<FSHead> obs = new List<FSHead>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
obs = _ifsHeadService.Get();
|
|
if (obs.Count > 0)
|
|
{
|
|
foreach (FSHead item in obs)
|
|
{
|
|
item.TypeString = EnumDescription.GetEnumDescription(item.Type);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(obs);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteFsHead")]
|
|
public ActionResult DeleteFsHead(FSHead item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
|
|
_ifsHeadService.Delete(item.ID);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("updateResignationRequestStatus")]
|
|
public ActionResult updateResignationRequestStatus(EmpResignationRequest item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
try
|
|
{
|
|
this._resignationRequestService.updateStatus(item.ID, item.WFStatus);
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[Route("saveResignationRequest")]
|
|
public ActionResult SaveResignationRequest(EmpResignationRequest item)
|
|
{
|
|
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
|
|
int ans;
|
|
var isNew = item.ID <= 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
item.ConnectionString = connectionString;
|
|
if (isNew)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
// item.EmployeeID = (int)currentUser.EmployeeID;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
if (item.EmpResgAttachmentList != null && item.EmpResgAttachmentList.Count > 0)
|
|
{
|
|
foreach (var tempItem in item.EmpResgAttachmentList)
|
|
{
|
|
if (tempItem.ID <= 0 && tempItem.TempFileTobase64 != null)
|
|
{
|
|
string[] items = tempItem.TempFileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None);
|
|
byte[] newBytes = Convert.FromBase64String(items[1]);
|
|
tempItem.FileAsByteArray = newBytes;
|
|
}
|
|
}
|
|
}
|
|
|
|
ans = _resignationRequestService.Save(item);
|
|
//if (ans > 0)
|
|
//{
|
|
// // _resignationRequestService.InitiateResignationRequestWorkFlow(item, (int)currentUser.EmployeeID, item.CreatedBy);
|
|
// _resignationRequestService.InitiateResignationRequestWorkFlow(item, (int)item.EmployeeID, item.CreatedBy);
|
|
//}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getResignationRequestByEmp/{employeeId}")]
|
|
public ActionResult getResignationRequestByEmp(int employeeId)
|
|
{
|
|
EmpResignationRequest item = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
item = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getResignationRequest/{id}/{employeeId}")]
|
|
public ActionResult GetResignationRequest(int id, int employeeId)
|
|
{
|
|
EmpResignationRequest item = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<Designation> designations =
|
|
new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
List<Department> departments =
|
|
new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
try
|
|
{
|
|
item = _resignationRequestService.Get(id);
|
|
if (item.JoiningDate == DateTime.MinValue)
|
|
{
|
|
item.JoiningDate = null;
|
|
}
|
|
if (item != null)
|
|
{
|
|
Employee employee = new Employee();
|
|
employee = _employeeService.Get(employeeId);
|
|
item.EmpNo = employee.EmployeeNo;
|
|
item.EmpName = employee.Name;
|
|
var designation = designations?.FirstOrDefault(d => d.ID == employee.DesignationID);
|
|
if (designation != null) item.EmpDeg = designation.Name;
|
|
|
|
var department = departments.FirstOrDefault(d => d.ID == employee.DepartmentID);
|
|
if (department != null) item.EmpDept = department.Name;
|
|
item.EmpResgAttachmentList = new List<EmpResignationAttachment>();
|
|
item.EmpResgAttachmentList = _resignationRequestService.GetResignationAttachments(item.ID);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getPrevReg/{employeeId}")]
|
|
public ActionResult GetPrevReg(int employeeId)
|
|
{
|
|
EmpResignationRequest item = null;
|
|
try
|
|
{
|
|
if(employeeId == 0)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
employeeId = (int)currentUser.EmployeeID;
|
|
}
|
|
|
|
|
|
item = _resignationRequestService.GetByEmpIDForSettlement(employeeId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getResignationRequestByStatus/{status}")]
|
|
public ActionResult getResignationRequestByStatus(EnumResignStatus status)
|
|
{
|
|
List<EmpResignationRequest> items = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
items = _resignationRequestService.Get(status);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpPost("approveResignationRequest")]
|
|
public ActionResult ApproveResignationRequest(dynamic data)
|
|
{
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
WFMovementTran otran = (WFMovementTran)items["wfTran"].ToObject<WFMovementTran>();
|
|
DateTime LastWorkingDate = (DateTime)items["lastWorkingDate"].ToObject<DateTime>();
|
|
string Remarks = (string)items["remarks"].ToObject<string>();
|
|
string ResignationReason = (string)items["resignationReason"].ToObject<string>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
otran.FromEmployeeID = (int)currentUser.EmployeeID;
|
|
otran.UserID = (int)currentUser.UserID;
|
|
try
|
|
{
|
|
_resignationRequestService.ApproveResignationRequest(otran, LastWorkingDate, Remarks, ResignationReason);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("rejectResignationRequest")]
|
|
public ActionResult RejectResignationRequest(WFMovementTran otran)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
otran.FromEmployeeID = (int)currentUser.EmployeeID;
|
|
|
|
try
|
|
{
|
|
_resignationRequestService.ResignationRequestReject(otran);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getEmpInfoResignation")]
|
|
public ActionResult GetEmpInfoResignation()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<Employee> employees = new List<Employee>();
|
|
List<Department> departments = new List<Department>();
|
|
List<Designation> designations = new List<Designation>();
|
|
List<Category> categories = new List<Category>();
|
|
Employee employee = new Employee();
|
|
try
|
|
{
|
|
employees = _employeeService.GetAllEmps();
|
|
departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
categories = new CategoryService().GetAll();
|
|
employee = _employeeService.Get((int)currentUser.EmployeeID);
|
|
var designation = designations?.FirstOrDefault(d => d.ID == employee.DesignationID);
|
|
if (designation != null)
|
|
employee.DesignationName = designation.Name;
|
|
var department = departments?.FirstOrDefault(d => d.ID == employee.DepartmentID);
|
|
if (department != null)
|
|
employee.DepartmentName = department.Name;
|
|
var lineManager = employees?.Find(x => x.ID == employee.LineManagerID);
|
|
employee.LineManager = lineManager == null ? "" : lineManager.Name;
|
|
var LMdesignation = designations?.FirstOrDefault(d => d.ID == lineManager.DesignationID);
|
|
if (LMdesignation != null)
|
|
employee.LineManagerDeg = LMdesignation.Name;
|
|
var category = categories?.FirstOrDefault(d => d.ID == employee.CategoryID);
|
|
if (category != null)
|
|
employee.CategoryName = category.Name;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(employee);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getResignationEmployeeInfo/{employeeId}")]
|
|
public ActionResult getResignationEmployeeInfo(int employeeId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
Employee employee = new Employee();
|
|
List<Department> departments = new List<Department>();
|
|
List<Designation> designations = new List<Designation>();
|
|
List<Category> categories = new List<Category>();
|
|
EmpResignationRequest empReg = new EmpResignationRequest();
|
|
try
|
|
{
|
|
departments = new DepartmentService().Get(EnumStatus.Regardless, (int)employee.PayrollTypeID);
|
|
designations = new DesignationService().Get(EnumStatus.Regardless, (int)employee.PayrollTypeID);
|
|
categories = new CategoryService().GetAll();
|
|
employee = _employeeService.Get(employeeId);
|
|
var designation = designations?.FirstOrDefault(d => d.ID == employee.DesignationID);
|
|
if (designation != null)
|
|
employee.DesignationName = designation.Name;
|
|
var department = departments?.FirstOrDefault(d => d.ID == employee.DepartmentID);
|
|
if (department != null)
|
|
employee.DepartmentName = department.Name;
|
|
var category = categories?.FirstOrDefault(d => d.ID == employee.CategoryID);
|
|
if (category != null)
|
|
employee.CategoryName = category.Name;
|
|
empReg = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
if (empReg != null)
|
|
{
|
|
employee.DiscontinueDate = empReg.DiscontinueDate;
|
|
employee.LastWorkingDate = empReg.LastWorkingDate;
|
|
employee.ResignationDate = empReg.ResignationDate;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(employee);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getResignationRequests/{fromDate}/{toDate}")]
|
|
public ActionResult GetResignationRequests(string fromDate, string toDate)
|
|
{
|
|
DateTime dfromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime dtoDate = GlobalFunctions.GetApiDefaultDateData(toDate);
|
|
List<EmpResignationRequest> items = new List<EmpResignationRequest>();
|
|
try
|
|
{
|
|
items = _resignationRequestService.Get(dfromDate, dtoDate);
|
|
if (items != null)
|
|
{
|
|
//foreach (var item in items)
|
|
//{
|
|
// item.StatusString = EnumDescription.GetEnumDescription(item.WFStatus);
|
|
// item.ClearanceStatusString = item.ClearanceStatus == null ? null : EnumDescription.GetEnumDescription(item.ClearanceStatus);
|
|
//}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getEssFinalSettlementData/{fromDate}/{toDate}/{employeeId}")]
|
|
public ActionResult getEssFinalSettlementData(string fromDate, string toDate,int? employeeId)
|
|
{
|
|
DateTime dfromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime dtoDate = GlobalFunctions.GetApiDefaultDateData(toDate);
|
|
List<FSHead> obs = new List<FSHead>();
|
|
//List<EmpResignationRequest> resignations = new List<EmpResignationRequest>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<FSHeadResignationPermission> resignationPermissions = new List<FSHeadResignationPermission>();
|
|
List<FSHeadResignationPermission> finalList = new List<FSHeadResignationPermission>();
|
|
EmpResignationRequest speccificEmployee = new EmpResignationRequest();
|
|
List<EmpResignationRequest> requests = null;
|
|
|
|
List<FSTran> otrans = null;
|
|
if (employeeId > 0)
|
|
{
|
|
otrans = this._fsTranService.GetByEmpIdForRegEmployee((int)employeeId);
|
|
speccificEmployee = this._resignationRequestService.GetByEmpIDForSettlement((int)employeeId);
|
|
}
|
|
else
|
|
{
|
|
otrans = this._fsTranService.Get(dfromDate, dtoDate, true);
|
|
requests = this._resignationRequestService.Get(dfromDate, dtoDate);
|
|
}
|
|
|
|
try
|
|
{
|
|
obs = _ifsHeadService.GetByEmpId((int)currentUser.EmployeeID);
|
|
// resignationPermissions = _resignationRequestService.GetFsHeadRegPermission();
|
|
foreach(FSTran tran in otrans)
|
|
{
|
|
FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
newitem.EmployeeNo = tran.EmployeeNo;
|
|
newitem.EmployeeName = tran.EmployeeName;
|
|
newitem.EmployeeId = tran.EmployeeID;
|
|
newitem.ResignationDate = tran.DiscontinueDate;
|
|
newitem.StatusString = "Completed";
|
|
finalList.Add(newitem);
|
|
foreach (FSTranDetail detail in tran.Details)
|
|
{
|
|
if(detail.CreatedBy == currentUser.UserID)
|
|
{
|
|
if (detail.ItemCode == EnumFSItemCode.LeaveEncashment)
|
|
newitem.LeaveEncashmentAmount = newitem.LeaveEncashmentAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.OT)
|
|
newitem.OTAmount = newitem.OTAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Loan)
|
|
newitem.LoanAmount = newitem.LoanAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Other)
|
|
newitem.OtherAmount = newitem.OtherAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Bonus)
|
|
newitem.BonusAmount = newitem.BonusAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Gross)
|
|
newitem.GrossAmount = newitem.GrossAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.FractionateSalary)
|
|
newitem.SalaryAdjustmentAmount = newitem.SalaryAdjustmentAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.NoticePay)
|
|
newitem.NoticeAmount = newitem.NoticeAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.PF || detail.ItemCode == EnumFSItemCode.CPF || detail.ItemCode == EnumFSItemCode.WPPF
|
|
|| detail.ItemCode == EnumFSItemCode.WPPFTax || detail.ItemCode == EnumFSItemCode.PFLoan || detail.ItemCode == EnumFSItemCode.PFLoanInterest
|
|
|| detail.ItemCode == EnumFSItemCode.PFLapsAndForfeiture)
|
|
newitem.PFAmount = newitem.PFAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Gratuity)
|
|
newitem.GratuityAmount = newitem.GratuityAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Basic)
|
|
newitem.BasicAmount = newitem.BasicAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Asset)
|
|
newitem.AssetAmount = newitem.AssetAmount + detail.ChangedValue;
|
|
else if (detail.ItemCode == EnumFSItemCode.Claim)
|
|
newitem.ClaimAmount = newitem.ClaimAmount + detail.ChangedValue;
|
|
|
|
// }
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if(employeeId > 0)
|
|
{
|
|
if (speccificEmployee != null)
|
|
{
|
|
if (speccificEmployee.WFStatus == EnumResignStatus.Clearance_initiated)
|
|
{
|
|
var temp = finalList.Find(x => x.EmployeeId == speccificEmployee.EmployeeID);
|
|
finalList = new List<FSHeadResignationPermission>();
|
|
if (temp != null)
|
|
{
|
|
FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
newitem = temp;
|
|
finalList.Add(newitem);
|
|
}
|
|
else{
|
|
FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
newitem.EmployeeNo = speccificEmployee.EmpNo;
|
|
newitem.EmployeeName = speccificEmployee.EmpName;
|
|
newitem.StatusString = "working";
|
|
newitem.joiningDate = (DateTime)speccificEmployee.JoiningDate;
|
|
newitem.EmployeeId = speccificEmployee.EmployeeID;
|
|
newitem.ResignationDate =(DateTime) speccificEmployee.ResignationDate;
|
|
finalList.Add(newitem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (EmpResignationRequest item in requests)
|
|
{
|
|
if (item.WFStatus == EnumResignStatus.Clearance_initiated && finalList.FindIndex(x => x.EmployeeId == item.EmployeeID) == -1)
|
|
{
|
|
FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
newitem.EmployeeNo = item.EmpNo;
|
|
newitem.EmployeeName = item.EmpName;
|
|
newitem.EmployeeId = item.EmployeeID;
|
|
finalList.Add(newitem);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(finalList);
|
|
}
|
|
|
|
|
|
[HttpGet("getMySettlmentHeads")]
|
|
public ActionResult getMySettlmentHeads()
|
|
{
|
|
List<FSHead> obs = new List<FSHead>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
obs = _ifsHeadService.GetByEmpId((int)currentUser.EmployeeID);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(obs);
|
|
}
|
|
|
|
[HttpGet("getTypeByEmployeeForAdmin/{employeeId}")]
|
|
public ActionResult getTypeByEmployeeForAdmin(int employeeId)
|
|
{
|
|
List<FSHead> obs = new List<FSHead>();
|
|
try
|
|
{
|
|
obs = _ifsHeadService.GetByEmpId(employeeId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(obs);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getCurrentEmployeeInfo")]
|
|
public ActionResult getCurrentEmployeeInfo()
|
|
{
|
|
Employee olist = new Employee();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
olist = _employeeService.Get((int)currentUser.EmployeeID);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(olist);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveFStran")]
|
|
public ActionResult saveFStran(FSTran item)
|
|
{
|
|
bool isSubmit = item.IsSubmit;
|
|
_resignationReqId = item.ResignationReqId;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<SettlementClearance> tempSc = new List<SettlementClearance>();
|
|
int ans = 0;
|
|
if(item.IsNew)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
foreach(FSTranDetail detail in item.Details)
|
|
{
|
|
if(detail.CreatedBy == 0 || detail.CreatedBy <0)
|
|
{
|
|
detail.CreatedBy = currentUser.UserID;
|
|
detail.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
detail.ModifiedBy = currentUser.UserID;
|
|
detail.ModifiedDate = DateTime.Today;
|
|
|
|
}
|
|
}
|
|
//item.EmployeeID = currentUser.EmployeeID == null ? 0 : (int)currentUser.EmployeeID;
|
|
//FSTran fstran = null;
|
|
try
|
|
{
|
|
_fsTranService.Save(item);
|
|
//fstran = _fsTranService.GetByEmpdId(item.EmployeeID);
|
|
//if (fstran == null) fstran = new FSTran();
|
|
//fstran.IsSubmit = isSubmit;
|
|
//fstran.CurrentEmployee = (int)currentUser.EmployeeID;
|
|
//fstran.EmployeeID = (int)currentUser.EmployeeID;
|
|
//if (fstran != null && fstran.ID > 0)
|
|
//{
|
|
// _fsTranDetailService.DeleteByUserId(fstran.ID, currentUser.UserID);
|
|
// fstran.Details = new List<FSTranDetail>();
|
|
// foreach (var tempitem in item.Details)
|
|
// {
|
|
// var childItem = new FSTranDetail();
|
|
// childItem = tempitem;
|
|
// fstran.Details.Add(childItem);
|
|
// }
|
|
// ans = _fsTranService.Save(fstran);
|
|
//}
|
|
//else
|
|
//{
|
|
//item.CreatedBy = currentUser.UserID;
|
|
//item.CreatedDate = DateTime.Today;
|
|
//item.LastSalaryPaidMonth = DateTime.Now;
|
|
//item.DiscontinueDate = DateTime.Now;
|
|
//ans = _fsTranService.Save(item);
|
|
//}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
|
|
[HttpGet("getFStranDetail/{employeeId}")]
|
|
public ActionResult GetFStranDetail(int employeeId)
|
|
{
|
|
FSTran fstran = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
fstran = _fsTranService.GetByEmpdId(employeeId);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(fstran);
|
|
}
|
|
|
|
[HttpGet("getGrossAmount/{nNumber}/{code}/{employeeId}")]
|
|
public ActionResult GetGrossAmount(int nNumber, EnumFSItemCode code, int employeeId)
|
|
{
|
|
FSTran fstran = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
Employee _oEmployee = null;
|
|
try
|
|
{
|
|
#region Allowance
|
|
List<ADParameter> adParams = null;
|
|
List<ADParameterEmployee> adParamEmps = null;
|
|
EmployeeGradeSalary oEmpGSalary = new EmployeeGradeSalary();
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
int totalDaysInLastMonth = 30;
|
|
//if (_oEmployee.EndOfContractDate != null)
|
|
//{
|
|
// totalDaysInLastMonth = ((DateTime)_oEmployee.EndOfContractDate).TotalDaysInMonth();
|
|
//}
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
FillGrid("Basic", ((_oEmployee.BasicSalary / totalDaysInLastMonth) * nNumber).ToString(), code, EnumAllowOrDeduct.Allowance, ((int)EnumSalaryItemCode.Basic_Salary).ToString());
|
|
else
|
|
FillGrid("Basic", (_oEmployee.BasicSalary * nNumber).ToString(), code, EnumAllowOrDeduct.Allowance, ((int)EnumSalaryItemCode.Basic_Salary).ToString());
|
|
|
|
adParams = new List<ADParameter>();
|
|
adParams = _adpParameterService.Get((int)_oEmployee.GradeID, EnumEntitleType.Grade, EnumAllowOrDeduct.Allowance, (int)currentUser.PayrollTypeID);
|
|
if (adParams != null)
|
|
{
|
|
foreach (ADParameter adParam in adParams)
|
|
{
|
|
adParam.AllowanceDeduction = new AllowanceDeduction();
|
|
adParam.AllowanceDeduction = _allowanceDeductionService.Get(adParam.AllowDeductID);
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
{
|
|
FillGrid(adParam.AllowanceDeduction.Name,
|
|
((_adpParameterService.GetGradeDefinedAmount(_oEmployee, _oEmployee.BasicSalary, _oEmployee.GrossSalary, new EmployeeGradeSalary(), adParam) / totalDaysInLastMonth) * nNumber).ToString(),
|
|
code, EnumAllowOrDeduct.Allowance, adParam.AllowanceDeduction.ID.ToString());
|
|
}
|
|
else
|
|
{
|
|
FillGrid(adParam.AllowanceDeduction.Name,
|
|
(_adpParameterService.GetGradeDefinedAmount(_oEmployee, _oEmployee.BasicSalary, _oEmployee.GrossSalary, new EmployeeGradeSalary(), adParam) * nNumber).ToString(),
|
|
code, EnumAllowOrDeduct.Allowance, adParam.AllowanceDeduction.ID.ToString());
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
adParamEmps = _adpParameterEmployeeService.GetByEmployee(_oEmployee.ID, EnumAllowOrDeduct.Allowance, EnumADEmpType.AppliedToIndividual, (int)currentUser.PayrollTypeID, (DateTime)currentUser.NextPayProcessDate);
|
|
|
|
//adParamEmps = new ObjectsTemplate<ADParameterEmployee>();
|
|
if (adParamEmps != null)
|
|
{
|
|
foreach (ADParameterEmployee adEmp in adParamEmps)
|
|
{
|
|
if (adEmp.AllowDeduct == null)
|
|
{
|
|
adEmp.AllowDeduct = new AllowanceDeduction();
|
|
adEmp.AllowDeduct = _allowanceDeductionService.Get(adEmp.AllowDeductID);
|
|
}
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
FillGrid(adEmp.AllowDeduct.Name, ((adEmp.MonthlyAmount / totalDaysInLastMonth) * nNumber).ToString(), code, EnumAllowOrDeduct.Allowance, adEmp.AllowDeduct.ID.ToString());
|
|
else
|
|
FillGrid(adEmp.AllowDeduct.Name, (adEmp.MonthlyAmount * nNumber).ToString(), code, EnumAllowOrDeduct.Allowance, adEmp.AllowDeduct.ID.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Deduction
|
|
adParams = new List<ADParameter>();
|
|
adParamEmps = new List<ADParameterEmployee>();
|
|
adParams = new List<ADParameter>();
|
|
adParams = _adpParameterService.Get((int)_oEmployee.GradeID, EnumEntitleType.Grade, EnumAllowOrDeduct.Deduction, (int)currentUser.PayrollTypeID);
|
|
if (adParams != null)
|
|
{
|
|
foreach (ADParameter adParam in adParams)
|
|
{
|
|
adParam.AllowanceDeduction = new AllowanceDeduction();
|
|
adParam.AllowanceDeduction = _allowanceDeductionService.Get(adParam.AllowDeductID);
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
{
|
|
FillGrid(adParam.AllowanceDeduction.Name, ((_adpParameterService.GetGradeDefinedAmount(_oEmployee,
|
|
_oEmployee.BasicSalary,
|
|
_oEmployee.GrossSalary, new EmployeeGradeSalary(), adParam) / 30) * nNumber).ToString(), code, EnumAllowOrDeduct.Deduction, adParam.AllowanceDeduction.ID.ToString());
|
|
}
|
|
else
|
|
{
|
|
FillGrid(adParam.AllowanceDeduction.Name, (_adpParameterService.GetGradeDefinedAmount(_oEmployee,
|
|
_oEmployee.BasicSalary,
|
|
_oEmployee.GrossSalary, new EmployeeGradeSalary(), adParam) * nNumber).ToString(), code, EnumAllowOrDeduct.Deduction, adParam.AllowanceDeduction.ID.ToString());
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
adParamEmps = _adpParameterEmployeeService.GetByEmployee(_oEmployee.ID, EnumAllowOrDeduct.Deduction, EnumADEmpType.AppliedToIndividual, (int)currentUser.PayrollTypeID, (DateTime)currentUser.NextPayProcessDate);
|
|
|
|
if (adParamEmps != null)
|
|
{
|
|
foreach (ADParameterEmployee adEmp in adParamEmps)
|
|
{
|
|
if (adEmp.AllowDeduct == null)
|
|
{
|
|
adEmp.AllowDeduct = new AllowanceDeduction();
|
|
adEmp.AllowDeduct = _allowanceDeductionService.Get(adEmp.AllowDeductID);
|
|
}
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
FillGrid(adEmp.AllowDeduct.Name, ((adEmp.MonthlyAmount / 30) * nNumber).ToString(), code, EnumAllowOrDeduct.Deduction, adEmp.AllowDeduct.ID.ToString());
|
|
else
|
|
FillGrid(adEmp.AllowDeduct.Name, (adEmp.MonthlyAmount * nNumber).ToString(), code, EnumAllowOrDeduct.Deduction, adEmp.AllowDeduct.ID.ToString());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
if (code == EnumFSItemCode.FractionateSalary)
|
|
return Ok(fracSalaryFillList);
|
|
else
|
|
return Ok(grossSalaryFillList);
|
|
}
|
|
|
|
private void FillGrid(string nName, string sAmount, EnumFSItemCode nItemCode, EnumAllowOrDeduct nType, string nItemID)
|
|
{
|
|
if (nItemCode == EnumFSItemCode.Gross)
|
|
{
|
|
if (nType == EnumAllowOrDeduct.Allowance)
|
|
{
|
|
var temp = new GrossSalaryList();
|
|
temp.AllowanceItemID = nItemID;
|
|
temp.AllowanceName = nName;
|
|
temp.AllowanceGrossValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
temp.ActualGrossValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
this.grossSalaryFillList.Add(temp);
|
|
}
|
|
else
|
|
{
|
|
var temp = new GrossSalaryList();
|
|
temp.DeductItemID = nItemID;
|
|
temp.DeductName = nName;
|
|
temp.DeductGrossValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
temp.ActualGrossDeductValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nType == EnumAllowOrDeduct.Allowance)
|
|
{
|
|
var temp = new ProportionateSalaryFill();
|
|
temp.AllowanceItemID = nItemID;
|
|
temp.AllowanceName = nName;
|
|
temp.AllowanceFracValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
temp.AllowanceActualFracValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
this.fracSalaryFillList.Add(temp);
|
|
}
|
|
else
|
|
{
|
|
var temp = new ProportionateSalaryFill();
|
|
temp.DeductItemID = nItemID;
|
|
temp.DeductName = nName;
|
|
temp.FracDeductValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
temp.ActualFracDeductValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
//this.fracSalaryFillList.Add(temp);
|
|
bool newItem = true;
|
|
foreach (var item in this.fracSalaryFillList)
|
|
{
|
|
if (item.DeductItemID == null || item.DeductItemID == "")
|
|
{
|
|
item.DeductItemID = nItemID;
|
|
item.DeductName = nName;
|
|
item.FracDeductValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
item.ActualFracDeductValue = GlobalFunctions.Round(Convert.ToDouble(sAmount));
|
|
newItem = false;
|
|
break;
|
|
}
|
|
}
|
|
if (newItem == true)
|
|
{
|
|
this.fracSalaryFillList.Add(temp);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
[HttpGet("IsClearanceEmp/{empid}")]
|
|
public ActionResult IsClearanceEmp(int empid)
|
|
{
|
|
bool item = false;
|
|
try
|
|
{
|
|
item = this._settlementClearanceService.IsClearanceEmp(empid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("GetClearanceEmployee")]
|
|
public ActionResult GetClearanceEmployee()
|
|
{
|
|
DataTable items = null;
|
|
try
|
|
{
|
|
items = this._settlementClearanceService.GetClearanceEmployee();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[Route("getNoticeDaysAndAmout/{employeeId}")]
|
|
public ActionResult getNoticeDaysAndAmout(int employeeId)
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
int nNoticeShortFallDays = 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
FSTranDetail noticeDays = new FSTranDetail();
|
|
List<FSTranDetail> items = null;
|
|
try
|
|
{
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
if (_oEmployee.IsConfirmed == true)
|
|
{
|
|
Grade oGrade = new Grade();
|
|
oGrade = new GradeService().Get((int)_oEmployee.GradeID);
|
|
// int nNoticeDays = oGrade != null ? oGrade.RequiredDays : 30;
|
|
int nNoticeDays = 30;
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
int dDateDiff = resignationByEmployee.ResignationDate.Value.Date < resignationByEmployee.LastWorkingDate.Value.Date ? ((resignationByEmployee.LastWorkingDate.Value.Date - resignationByEmployee.ResignationDate.Value.Date).Days + 1) : 0;
|
|
//int dDateDiff = resignationByEmployee.ResignationDate.Value.Date < resignationByEmployee.LastWorkingDate.Value.Date ? (resignationByEmployee.LastWorkingDate.Value.Date - resignationByEmployee.ResignationDate.Value.Date).Days : 0;
|
|
nNoticeShortFallDays = nNoticeDays > dDateDiff ? (nNoticeDays - dDateDiff) : 0;
|
|
}
|
|
if (nNoticeShortFallDays > 0)
|
|
{
|
|
items = new List<FSTranDetail>();
|
|
noticeDays.Amount = nNoticeShortFallDays;
|
|
noticeDays.AmountType = EnumValueType.Other;
|
|
noticeDays.Description = "Notice Pay Days";
|
|
noticeDays.IncomeTaxItemType = enumIncomeTaxItemType.None;
|
|
noticeDays.ItemCode = EnumFSItemCode.NoticePay;
|
|
noticeDays.ItemID = null;
|
|
noticeDays.ReferenceItemID = null;
|
|
items.Add(noticeDays);
|
|
|
|
FSTranDetail noticeAmount = new FSTranDetail();
|
|
|
|
noticeAmount.Amount = (_oEmployee.BasicSalary / GlobalFunctions.GetDaysInMonth((DateTime)
|
|
resignationByEmployee.LastWorkingDate)) * nNoticeShortFallDays;
|
|
noticeAmount.Amount = Math.Round(noticeAmount.Amount);
|
|
noticeAmount.AmountType = EnumValueType.Amount;
|
|
noticeAmount.Description = "Notice Pay Amount";
|
|
noticeAmount.IncomeTaxItemType = enumIncomeTaxItemType.NoticePay;
|
|
noticeAmount.ItemCode = EnumFSItemCode.NoticePay;
|
|
noticeAmount.ItemID = null;
|
|
noticeAmount.ReferenceItemID = null;
|
|
items.Add(noticeAmount);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getBasicAmout/{employeeId}/{days}")]
|
|
public ActionResult getBasicDaysAndAmout(int employeeId,int days)
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
double basicAmount = 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
//List<FSTranDetail> items = null;
|
|
try
|
|
{
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
basicAmount = (_oEmployee.BasicSalary / GlobalFunctions.GetDaysInMonth((DateTime)
|
|
resignationByEmployee.LastWorkingDate)) * days;
|
|
basicAmount = Math.Round(basicAmount);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(basicAmount);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("getEarnedLeaveDaysAndAmout/{employeeId}")]
|
|
public ActionResult getEarnedLeaveDaysAndAmout(int employeeId)
|
|
{
|
|
double EarnedLeaveDays = 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
FSTranDetail itemone = new FSTranDetail();
|
|
List<FSTranDetail> items = null;
|
|
try
|
|
{
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
Employee _oEmployee = this._employeeService.Get(employeeId);
|
|
|
|
EarnedLeaveDays = this._leaveService.GetSettlementEarnLeaveBalance(_oEmployee,
|
|
(DateTime)resignationByEmployee.LastWorkingDate);
|
|
|
|
if (EarnedLeaveDays > 0)
|
|
{
|
|
items = new List<FSTranDetail>();
|
|
itemone.Amount = EarnedLeaveDays;
|
|
itemone.AmountType = EnumValueType.Other;
|
|
itemone.Description = "Earned Leave Days";
|
|
itemone.IncomeTaxItemType = enumIncomeTaxItemType.None;
|
|
itemone.ItemCode = EnumFSItemCode.LeaveEncashment;
|
|
itemone.ItemID = null;
|
|
itemone.ReferenceItemID = null;
|
|
items.Add(itemone);
|
|
|
|
|
|
FSTranDetail tiemtwo = new FSTranDetail();
|
|
|
|
|
|
tiemtwo.Amount = _oEmployee.GrossSalary / 30 * EarnedLeaveDays;
|
|
tiemtwo.Amount = Math.Round(tiemtwo.Amount);
|
|
tiemtwo.AmountType = EnumValueType.Amount;
|
|
tiemtwo.Description = "Leave Encashment Amount";
|
|
tiemtwo.IncomeTaxItemType = enumIncomeTaxItemType.Earned_Leave;
|
|
tiemtwo.ItemCode = EnumFSItemCode.LeaveEncashment;
|
|
tiemtwo.ItemID = null;
|
|
tiemtwo.ReferenceItemID = null;
|
|
items.Add(tiemtwo);
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getAllowancesDeductions")]
|
|
public ActionResult GetAllowancesDeductions()
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
|
|
try
|
|
{
|
|
var tempList = _allowanceDeductionService.Get(EnumStatus.Active);
|
|
allowanceDeductions = tempList.Where(x => x.payrolltypeid == currentUser.PayrollTypeID).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(allowanceDeductions);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getGratuityAmount/{employeeId}")]
|
|
public ActionResult getGratuityAmount(int employeeId)
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
GratuityCount _gratuityCount = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<AllowanceDeduction> allowanceDeductions = new List<AllowanceDeduction>();
|
|
double _nGratuityAmount = 0.0;
|
|
string gratuityAmount;
|
|
string _serviceLength = null;
|
|
try
|
|
{
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
|
|
if (_oEmployee.Status != EnumEmployeeStatus.Live)
|
|
{
|
|
if (_oEmployee.EndOfContractDate != null && _oEmployee.EndOfContractDate != DateTime.MinValue)
|
|
{
|
|
_nGratuityAmount = GlobalFunctions.Round(CalculatedGratuityAmount(resignationByEmployee.LastWorkingDate.Value.Date, _oEmployee));//reg date
|
|
_serviceLength = GlobalFunctions.AgeCalculate(_oEmployee.JoiningDate, resignationByEmployee.LastWorkingDate.Value.Date);
|
|
}
|
|
}
|
|
gratuityAmount = GlobalFunctions.TakaFormat(_nGratuityAmount);
|
|
|
|
_gratuityCount = new GratuityCount
|
|
{
|
|
GratuityAmount = gratuityAmount,
|
|
ServiceLength = _serviceLength
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(_gratuityCount);
|
|
}
|
|
|
|
[Route("getAgeCalculation/{employeeId}")]
|
|
public ActionResult GetAgeCalculation(int employeeId)
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
string _serviceLength = null;
|
|
try
|
|
{
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
|
|
if (_oEmployee.Status != EnumEmployeeStatus.Live)
|
|
{
|
|
if (_oEmployee.EndOfContractDate != null && _oEmployee.EndOfContractDate != DateTime.MinValue)
|
|
{
|
|
_serviceLength = GlobalFunctions.AgeCalculate(_oEmployee.JoiningDate, resignationByEmployee.LastWorkingDate.Value.Date);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(_serviceLength);
|
|
}
|
|
|
|
private double CalculatedGratuityAmount(DateTime dt, Employee _oEmployee)
|
|
{
|
|
double nAmount;
|
|
double nServiceLength;
|
|
double basicCount = 0;
|
|
double yearCount = 0;
|
|
//double nDiff;
|
|
nServiceLength = 0;
|
|
nAmount = 0.0;
|
|
|
|
if (dt <= new DateTime(2021, 1, 1))
|
|
{
|
|
nServiceLength = ServiceYears(dt, _oEmployee);
|
|
// Non-Management
|
|
if (IsNonManagement(_oEmployee))
|
|
{
|
|
if (nServiceLength < 0.5)
|
|
nAmount = 0.0;
|
|
else if (nServiceLength >= 10)
|
|
nAmount = _oEmployee.BasicSalary * Math.Round(nServiceLength) * 1.5;
|
|
else
|
|
nAmount = _oEmployee.BasicSalary * Math.Round(nServiceLength);
|
|
}
|
|
// Management
|
|
else
|
|
{
|
|
|
|
if (nServiceLength < 5)
|
|
nAmount = 0.0;
|
|
else if (dt >= new DateTime(2021, 1, 2) && nServiceLength >= 10)
|
|
{
|
|
nAmount = _oEmployee.BasicSalary * nServiceLength * 1.5;
|
|
}
|
|
else
|
|
nAmount = _oEmployee.BasicSalary * nServiceLength;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
nServiceLength = ServiceYearsForNewRules(dt, _oEmployee);
|
|
|
|
if (nServiceLength <= 0.5)
|
|
nAmount = 0.0;
|
|
else if (nServiceLength > .5 && nServiceLength <= 1.5)
|
|
nAmount = _oEmployee.BasicSalary * 1;
|
|
else if (nServiceLength > 1.5 && nServiceLength <= 2.5)
|
|
nAmount = _oEmployee.BasicSalary * 2;
|
|
else if (nServiceLength > 2.5 && nServiceLength <= 3.5)
|
|
nAmount = _oEmployee.BasicSalary * 3;
|
|
else if (nServiceLength > 3.5 && nServiceLength <= 4.5)
|
|
nAmount = _oEmployee.BasicSalary * 4;
|
|
else if (nServiceLength > 4.5 && nServiceLength <= 5.5)
|
|
nAmount = _oEmployee.BasicSalary * 5;
|
|
else if (nServiceLength > 5.5 && nServiceLength <= 6.5)
|
|
nAmount = _oEmployee.BasicSalary * 6;
|
|
else if (nServiceLength > 6.5 && nServiceLength <= 7.5)
|
|
nAmount = _oEmployee.BasicSalary * 7;
|
|
else if (nServiceLength > 7.5 && nServiceLength <= 8.5)
|
|
nAmount = _oEmployee.BasicSalary * 8;
|
|
else if (nServiceLength > 8.5 && nServiceLength <= 9.5)
|
|
nAmount = _oEmployee.BasicSalary * 9;
|
|
else if (nServiceLength > 9.5 && nServiceLength <= 10)
|
|
nAmount = _oEmployee.BasicSalary * 10;
|
|
else if (nServiceLength > 10 && nServiceLength <= 10.5)
|
|
nAmount = _oEmployee.BasicSalary * 10 * 1.5;
|
|
else if (nServiceLength > 10.5 && nServiceLength <= 11.5)
|
|
nAmount = _oEmployee.BasicSalary * 11 * 1.5;
|
|
else
|
|
{
|
|
yearCount = Math.Round(nServiceLength);
|
|
if (yearCount > 11)
|
|
{
|
|
nAmount = 1.5 * yearCount * _oEmployee.BasicSalary;
|
|
}
|
|
}
|
|
}
|
|
nAmount = Math.Round(nAmount);
|
|
return nAmount;
|
|
}
|
|
|
|
private double ServiceYears(DateTime discontinueDate, Employee _oEmployee)
|
|
{
|
|
double n = discontinueDate.Subtract(_oEmployee.JoiningDate).TotalDays + 1;
|
|
double serviceYears = 0;
|
|
// Non Management
|
|
if (IsNonManagement(_oEmployee))
|
|
{
|
|
serviceYears = Math.Round(n / 365);
|
|
}
|
|
// Management
|
|
else
|
|
{
|
|
serviceYears = Math.Floor(n / 365);
|
|
}
|
|
|
|
return serviceYears;
|
|
}
|
|
|
|
private bool IsNonManagement(Employee _oEmployee)
|
|
{
|
|
List<Grade> _Grades = new List<Grade>();
|
|
List<GradeSegment> _GradeSegments = new List<GradeSegment>();
|
|
GradeSegment _nonManaghementGS = null;
|
|
|
|
_Grades = new GradeService().Get(EnumStatus.Active);
|
|
_GradeSegments = new GradeSegmentService().Get(EnumStatus.Active);
|
|
_nonManaghementGS = _GradeSegments.FirstOrDefault(x => x.Code.Trim().ToUpper() == "002");
|
|
//Non Management
|
|
if (_nonManaghementGS != null && _Grades.Any(x => x.ID == _oEmployee.GradeID && x.GradeSegmentID == _nonManaghementGS.ID))
|
|
{
|
|
return true;
|
|
}
|
|
// Management
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private double ServiceYearsForNewRules(DateTime discontinueDate, Employee _oEmployee)
|
|
{
|
|
|
|
double n = discontinueDate.Subtract(_oEmployee.JoiningDate).TotalDays;
|
|
|
|
double serviceYears = 0;
|
|
serviceYears = n / 365;
|
|
|
|
return serviceYears;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getPFAmount/{employeeId}")]
|
|
public ActionResult getPFAmount(int employeeId)
|
|
{
|
|
Employee _oEmployee = new Employee();
|
|
PFCount _pfCount = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
string PFAmountText;
|
|
string CPFAmountText;
|
|
string PFLoanText = null;
|
|
string PFLoanInterestText = null;
|
|
string PFLapsText;
|
|
string WPPFAmountText;
|
|
string WPPFTaxAmountText;
|
|
List<Loan> _oLoans = null;
|
|
try
|
|
{
|
|
_oEmployee = _employeeService.Get(employeeId);
|
|
|
|
double _nPFAmount = 0.0;
|
|
//_nPFAmount = FSTran.GetPFAmount(_oEmployee.EmployeeNo);
|
|
PFAmountText = GlobalFunctions.TakaFormat(_nPFAmount);
|
|
|
|
double _nCPFAmount = 0.0;
|
|
_nCPFAmount = _nPFAmount;
|
|
CPFAmountText = GlobalFunctions.TakaFormat(0);
|
|
|
|
double _nPFLapsAmount = 0.0;
|
|
PFLapsText = GlobalFunctions.TakaFormat(_nPFLapsAmount);
|
|
|
|
double _nWPPFAmount = 0.0;
|
|
WPPFAmountText = GlobalFunctions.TakaFormat(_nWPPFAmount);
|
|
|
|
double _nWPPFTaxAmount = 0.0;
|
|
WPPFTaxAmountText = GlobalFunctions.TakaFormat(_nWPPFTaxAmount);
|
|
|
|
double _nLoanTotal = 0.0;
|
|
_oLoans = new List<Loan>();
|
|
DataSet oLoanIDs = new DataSet();
|
|
Loan oLoan = new Loan();
|
|
//lvwLoan.Items.Clear();
|
|
//ListViewItem li;
|
|
_oLoans = _loanService.Get(EnumStatus.Active);
|
|
List<LoanIssue> issuedLoans = _loanIssueService.GetExistingLoan(_oEmployee.ID);
|
|
DateTime dtDis = _oEmployee.EndOfContractDate == DateTime.MinValue ? DateTime.Now : (DateTime)_oEmployee.EndOfContractDate;
|
|
dtDis = dtDis.AddMonths(-1);
|
|
foreach (LoanIssue lis in issuedLoans)
|
|
{
|
|
DataSet oItems = _loanScheduleService.GetByEmpIDANDLoanID(_oEmployee.ID, lis.LoanID);
|
|
foreach (DataRow odRow in oItems.Tables[0].Rows)
|
|
{
|
|
oLoan = _oLoans.Find(delegate (Loan t) { return t.ID == lis.LoanID; });
|
|
if (lis.LoanID == 1)
|
|
{
|
|
PFLoanText = GlobalFunctions.TakaFormat(Convert.ToDouble(odRow[1]));
|
|
PFLoanInterestText = GlobalFunctions.TakaFormat(Convert.ToDouble(odRow[2]));
|
|
}
|
|
else // loan tab
|
|
{
|
|
//li = new ListViewItem();
|
|
//li.Text = oLoan.Name;
|
|
//li.SubItems.Add(GlobalFunctions.TakaFormat(Convert.ToDouble(odRow[1])));
|
|
//lvwLoan.Items.Add(li);
|
|
//_nLoanTotal += Convert.ToDouble(odRow[1]);
|
|
}
|
|
|
|
}
|
|
}
|
|
_pfCount = new PFCount
|
|
{
|
|
PFAmount = PFAmountText,
|
|
CPFAmount = CPFAmountText,
|
|
PFLoan = PFLoanText == null ? "0.0" : PFLoanText,
|
|
PFLoanInterest = PFLoanInterestText == null ? "0.0" : PFLoanInterestText,
|
|
PFLaps = PFLapsText,
|
|
WPPFAmount = WPPFTaxAmountText,
|
|
WPPFTaxAmount = WPPFTaxAmountText
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(_pfCount);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getClearanceNotifications/{empregId}")]
|
|
public ActionResult GetClearanceNotifications(int empregId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
EmpResignationRequest rg = this._resignationRequestService.Get(empregId);
|
|
List<FinalSettlementClerance> items = null;
|
|
try
|
|
{
|
|
items = _finalSettlementService.GetClearanceNotifications(rg.EmployeeID);
|
|
if (items != null)
|
|
{
|
|
foreach (var item in items)
|
|
{
|
|
if (item.SendDate == DateTime.MinValue)
|
|
{
|
|
item.SendDate = null;
|
|
}
|
|
if (item.ClearanceDate == DateTime.MinValue)
|
|
{
|
|
item.ClearanceDate = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("checkSettlementClearanceStatus/{empResignationID}/{employeeid}")]
|
|
public ActionResult checkSettlementClearanceStatus(int empResignationID ,int employeeid)
|
|
{
|
|
bool isallCompleted = false;
|
|
List<SettlementClearance> oSettlementClearance = new List<SettlementClearance>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
oSettlementClearance = _settlementClearanceService.GetByRegEmp(empResignationID, employeeid);
|
|
if(oSettlementClearance != null && oSettlementClearance.Count > 0)
|
|
{
|
|
if(oSettlementClearance[0].SettlementClearanceStatus == EnumSettlementClearanceStatus.Completed)
|
|
isallCompleted = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(isallCompleted);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("sendMailNotification/{employeeIds}/{empresignationId}")]
|
|
public ActionResult SendMailNotification(string employeeIds, int empresignationId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int id = 0;
|
|
try
|
|
{
|
|
_settlementClearanceService.SaveAll(employeeIds, currentUser, empresignationId);
|
|
//List<int> empIds = employeeIds.Split(',').Select(int.Parse).ToList();
|
|
//empIds = empIds.Distinct().ToList();
|
|
|
|
//List<Employee> emps = new EmployeeService().GetByEmpIDs(employeeIds,(int) currentUser.PayrollTypeID);
|
|
|
|
//EmpResignationRequest rg = this._resignationRequestService.Get(empresignationId);
|
|
//Employee emp = this._employeeService.Get(rg.EmployeeID);
|
|
//if (empIds != null && empIds.Count > 0)
|
|
//{
|
|
// foreach (var item in empIds)
|
|
// {
|
|
// SettlementClearance sc = new SettlementClearance();
|
|
// sc.NotificationEmployee = emps.FirstOrDefault(x => x.ID == item);
|
|
// sc.EmployeeID = item;
|
|
// sc.UserID = currentUser.UserID;
|
|
// sc.EmpClearanceID = emp.ID;
|
|
// sc.SentDate = DateTime.Today;
|
|
// sc.ClearanceDate = null;
|
|
// sc.CreatedDate = DateTime.Today;
|
|
// sc.ResignationEmployee = emp;
|
|
// sc.CreatedBy = currentUser.UserID;
|
|
// sc.SettlementClearanceStatus = EnumSettlementClearanceStatus.Initiated;
|
|
// sc.ResignationEmployee = emp;
|
|
// sc.ResignationRequestID = empresignationId;
|
|
// id = _settlementClearanceService.Save(sc);
|
|
|
|
// }
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(id);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("saveSettlementAdvice")]
|
|
public ActionResult saveSettlementAdvice(SettlmentAdvice item)
|
|
{
|
|
int id = 0;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if (item.IsNew)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
try
|
|
{
|
|
id= _settlementAdviceService.Save(item);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(id);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("CalulateSettlementTax")]
|
|
public ActionResult CalulateSettlementTax(FSTran item)
|
|
{
|
|
List<IncomeTax> taxes = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if (item.IsNew)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
try
|
|
{
|
|
taxes = new FSTranService().CalculateTax(item, currentUser.UserID,(int) currentUser.PayrollTypeID);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(taxes);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetSettlementAdvices/{fromDate}/{toDate}")]
|
|
public ActionResult GetSettlementAdvices(string fromDate, string toDate)
|
|
{
|
|
DateTime dfromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime dtoDate = GlobalFunctions.GetApiDefaultDateData(toDate);
|
|
List<SettlmentAdvice> items = new List<SettlmentAdvice>();
|
|
try
|
|
{
|
|
items = _settlementAdviceService.Get(dfromDate, dtoDate);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("checkSettlementClearanceStatus/{resignationReqId}")]
|
|
public ActionResult checkSettlementClearanceStatus(int resignationReqId)
|
|
{
|
|
bool isNotAllCompleted = true;
|
|
List<SettlementClearance> oSettlementClearance = new List<SettlementClearance>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
oSettlementClearance = _settlementClearanceService.GetByResignationId(resignationReqId);
|
|
if(oSettlementClearance != null && oSettlementClearance.Count > 0)
|
|
{
|
|
isNotAllCompleted = oSettlementClearance.Where(x => x.ResignationRequestID == resignationReqId && x.SettlementClearanceStatus != EnumSettlementClearanceStatus.Completed).Any();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(isNotAllCompleted);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("getMySettlementClearanceStatus/{resignationReqId}")]
|
|
public ActionResult getMySettlementClearanceStatus(int resignationReqId)
|
|
{
|
|
|
|
List<SettlementClearance> oSettlementClearance = new List<SettlementClearance>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
oSettlementClearance = _settlementClearanceService.GetByResignationId(resignationReqId);
|
|
SettlementClearance item = oSettlementClearance.FirstOrDefault(x => x.EmployeeID == (int)currentUser.EmployeeID);
|
|
if (item == null)
|
|
return Ok(false);
|
|
else
|
|
{
|
|
if (item.SettlementClearanceStatus == EnumSettlementClearanceStatus.Completed)
|
|
return Ok(true);
|
|
else return Ok(false);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
[HttpGet("getFinalSettlementData/{employeeId}")]
|
|
public ActionResult getFinalSettlementData(int employeeId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<FSHeadResignationPermission> resignationPermissions = new List<FSHeadResignationPermission>();
|
|
List<FSHeadResignationPermission> finalList = new List<FSHeadResignationPermission>();
|
|
//List<EmpResignationRequest> requests = this._resignationRequestService.Get(dfromDate, dtoDate);
|
|
try
|
|
{
|
|
FSTran otran = _fsTranService.GetByEmpdId(employeeId);
|
|
//obs = _ifsHeadService.GetByEmpId((int)currentUser.EmployeeID);
|
|
// resignationPermissions = _resignationRequestService.GetFsHeadRegPermission();
|
|
|
|
if (otran != null)
|
|
{
|
|
int fractionnateSalaryCount = 0;
|
|
//foreach (FSTranDetail tran in otran.Details)
|
|
//{
|
|
// if(tran.ItemID == EnumFSItemCode.)
|
|
|
|
//}
|
|
}
|
|
//foreach (FSTran tran in otrans)
|
|
//{
|
|
// FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
// newitem.EmployeeNo = tran.EmployeeNo;
|
|
// newitem.EmployeeName = tran.EmployeeName;
|
|
// newitem.EmployeeId = tran.EmployeeID;
|
|
// finalList.Add(newitem);
|
|
// foreach (FSTranDetail detail in tran.Details)
|
|
// {
|
|
// if (detail.CreatedBy == currentUser.UserID)
|
|
// {
|
|
|
|
// if (detail.ItemCode == EnumFSItemCode.LeaveEncashment)
|
|
// newitem.LeaveEncashmentAmount = newitem.LeaveEncashmentAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.OT)
|
|
// newitem.OTAmount = newitem.OTAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.Loan)
|
|
// newitem.LoanAmount = newitem.LoanAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.Other)
|
|
// newitem.OtherAmount = newitem.OtherAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.Bonus)
|
|
// newitem.BonusAmount = newitem.BonusAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.Gross)
|
|
// newitem.GrossAmount = newitem.GrossAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.FractionateSalary)
|
|
// newitem.SalaryAdjustmentAmount = newitem.SalaryAdjustmentAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.NoticePay)
|
|
// newitem.NoticeAmount = newitem.NoticeAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.PF || detail.ItemCode == EnumFSItemCode.CPF || detail.ItemCode == EnumFSItemCode.WPPF
|
|
// || detail.ItemCode == EnumFSItemCode.WPPFTax || detail.ItemCode == EnumFSItemCode.PFLoan || detail.ItemCode == EnumFSItemCode.PFLoanInterest
|
|
// || detail.ItemCode == EnumFSItemCode.PFLapsAndForfeiture)
|
|
// newitem.PFAmount = newitem.PFAmount + detail.ChangedValue;
|
|
// else if (detail.ItemCode == EnumFSItemCode.Gratuity)
|
|
// newitem.GratuityAmount = newitem.GratuityAmount + detail.ChangedValue;
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
//}
|
|
|
|
//foreach (EmpResignationRequest item in requests)
|
|
//{
|
|
// if (item.WFStatus == EnumResignStatus.Clearance_initiated && finalList.FindIndex(x => x.EmployeeId == item.EmployeeID) == -1)
|
|
// {
|
|
// FSHeadResignationPermission newitem = new FSHeadResignationPermission();
|
|
// newitem.EmployeeNo = item.EmpNo;
|
|
// newitem.EmployeeName = item.EmpName;
|
|
// newitem.EmployeeId = item.EmployeeID;
|
|
// finalList.Add(newitem);
|
|
// }
|
|
//}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(finalList);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getFractionateSalaryDays/{employeeId}")]
|
|
public ActionResult getFractionateSalaryDays(int employeeId)
|
|
{
|
|
int dDateDiff = 0;
|
|
try
|
|
{
|
|
var resignationByEmployee = new EmpResignationRequest();
|
|
resignationByEmployee = _resignationRequestService.GetByEmployeeId(employeeId);
|
|
Employee _oEmployee = this._employeeService.Get(employeeId);
|
|
DateTime? dLastSalaryMonth = new SalaryMonthlyService().GetLastPaidSalaryMonth(employeeId);
|
|
if (dLastSalaryMonth != null)
|
|
dDateDiff = (resignationByEmployee.LastWorkingDate.Value.Date - dLastSalaryMonth.Value.Date).Days;
|
|
else
|
|
dDateDiff = resignationByEmployee.LastWorkingDate.Value.Date > _oEmployee.JoiningDate.Date ? (resignationByEmployee.LastWorkingDate.Value.Date - _oEmployee.JoiningDate.Date).Days : 0;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dDateDiff);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |