922 lines
31 KiB
C#
922 lines
31 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using HRM.BO;
|
|
using HRM.DA;
|
|
|
|
namespace HRM.UI.Controllers.Payroll
|
|
{
|
|
[Route("api/opi")]
|
|
[ApiController]
|
|
public class OpiController : ControllerBase
|
|
{
|
|
private readonly IOpiParameterService _opiParameterService;
|
|
private readonly IOpiParameterIndividualService _opiParameterIndividualService;
|
|
private readonly IOPIPaymentService _opiPaymentService;
|
|
private readonly IOPIProcessService _opiProcessService;
|
|
private readonly IOpiItemService _opiItemService;
|
|
|
|
public OpiController(IOpiParameterService opiParameterService,
|
|
IOpiParameterIndividualService opiParameterIndividualService,
|
|
IOPIPaymentService opiPaymentService,
|
|
IOPIProcessService opiProcessService,
|
|
IOpiItemService itemService)
|
|
{
|
|
this._opiParameterService = opiParameterService;
|
|
this._opiParameterIndividualService = opiParameterIndividualService;
|
|
this._opiPaymentService = opiPaymentService;
|
|
this._opiProcessService = opiProcessService;
|
|
this._opiItemService = itemService;
|
|
}
|
|
|
|
// OpiParameter
|
|
[HttpGet("getOpiParameterById/{id}")]
|
|
public ActionResult GetOpiParameterById(int id)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
OpiParameter item = new OpiParameter();
|
|
try
|
|
{
|
|
item = _opiParameterService.Get(id, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterList")]
|
|
public ActionResult GetOpiParameterList()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameter> items = new List<OpiParameter>();
|
|
try
|
|
{
|
|
items = _opiParameterService.Get(payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getGradesListByopiParameterId/{opiParameterId}")]
|
|
public ActionResult GetGradesListByopiParameterId(int opiParameterId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameterGrade> items = new List<OpiParameterGrade>();
|
|
try
|
|
{
|
|
items = _opiParameterService.GetGrades(opiParameterId, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getGradesList")]
|
|
public ActionResult GetGradesList()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameterGrade> items = new List<OpiParameterGrade>();
|
|
try
|
|
{
|
|
items = _opiParameterService.GetGrades(payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("GetUsedGrades/{itemid}")]
|
|
public ActionResult GetUsedGrades(int itemid)
|
|
{
|
|
List<OpiParameterGrade> items = new List<OpiParameterGrade>();
|
|
try
|
|
{
|
|
items = _opiParameterService.GetUsedGrades(itemid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getOpiParameterByStatus/{status}")]
|
|
public ActionResult GetOpiParameterByStatus(EnumStatus status)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameter> items = new List<OpiParameter>();
|
|
try
|
|
{
|
|
items = _opiParameterService.Get(status, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterByStatusAndType/{status}/{type}")]
|
|
public ActionResult GetOpiParameterByStatusAndType(EnumStatus status, EnumOpiType type)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameter> items = new List<OpiParameter>();
|
|
try
|
|
{
|
|
items = _opiParameterService.Get(status, type, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterByStatusAndTypeAndEntitleType/{status}/{type}/{entitleType}")]
|
|
public ActionResult GetOpiParameterByStatusAndTypeAndEntitleType(EnumStatus status, EnumOpiType type,
|
|
EnumEntitleType entitleType)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameter> items = new List<OpiParameter>();
|
|
try
|
|
{
|
|
items = _opiParameterService.Get(status, type, entitleType, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getOpiParameterByStatusAndEntitleType/{status}/{entitleType}")]
|
|
public ActionResult GetOpiParameterByStatusAndEntitleType(EnumStatus status, EnumEntitleType entitleType)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OpiParameter> items = new List<OpiParameter>();
|
|
try
|
|
{
|
|
items = _opiParameterService.Get(status, entitleType, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveOpiParameter")]
|
|
public ActionResult SaveOpiParameter(OpiParameter item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if(item.IsNew == true)
|
|
{
|
|
item.Status = EnumStatus.Active;
|
|
item.IsActive = true;
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
item.PayrollTypeID = (int)currentUser.PayrollTypeID;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
|
|
}
|
|
item.OpiParameterGrades.ForEach(x =>
|
|
{
|
|
|
|
x.OpiItemId = item.OpiItemID;
|
|
x.CreatedBy = item.CreatedBy;
|
|
x.CreatedDate = item.CreatedDate;
|
|
x.PayrollTypeID = item.PayrollTypeID;
|
|
});
|
|
item.OpiParameterIndividuals.ForEach(x =>
|
|
{
|
|
|
|
x.OpiItemId = item.OpiItemID;
|
|
x.CreatedBy = item.CreatedBy;
|
|
x.CreatedDate = item.CreatedDate;
|
|
x.PayrollTypeID = item.PayrollTypeID;
|
|
});
|
|
try
|
|
{
|
|
_opiParameterService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost]
|
|
[Route("changeStatus")]
|
|
public ActionResult changeStatus(OpiParameter oitem)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
oitem.ModifiedBy = currentUser.UserID;
|
|
oitem.ModifiedDate = DateTime.Now;
|
|
EnumStatus sts = EnumStatus.Active;
|
|
if (oitem.IsActive == false)
|
|
{
|
|
sts = EnumStatus.Inactive;
|
|
}
|
|
try
|
|
{
|
|
|
|
this._opiParameterService.ChangeStatus(oitem.ID, sts);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteOpiParameter")]
|
|
public ActionResult DeleteOpiParameter(OpiParameter param)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
_opiParameterService.Delete(param.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// OpiParameterIndividual
|
|
|
|
[HttpGet("getOpiParameterIndividualById/{id}")]
|
|
public ActionResult GetOpiParameterIndividualById(int id)
|
|
{
|
|
OpiParameterIndividual item = new OpiParameterIndividual();
|
|
try
|
|
{
|
|
item = _opiParameterIndividualService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getAllOpiParameterIndividual")]
|
|
public ActionResult GetAllOpiParameterIndividual()
|
|
{
|
|
List<OpiParameterIndividual> items = new List<OpiParameterIndividual>();
|
|
try
|
|
{
|
|
items = _opiParameterIndividualService.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
// Category
|
|
[HttpGet("getAllOpiItem/{status}/{code}/{name}")]
|
|
public ActionResult getAllOpiItem(EnumStatus status, string code, string name)
|
|
{
|
|
code = GlobalFunctions.GetApiDefaultData(code);
|
|
name = GlobalFunctions.GetApiDefaultData(name);
|
|
List<OpiItem> items = new List<OpiItem>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = this._opiItemService.Get( status, payrollTypeId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterIndividualByDateRange/{fromDate}/{toDate}")]
|
|
public ActionResult GetOpiParameterIndividualByDateRange(DateTime fromDate, DateTime toDate)
|
|
{
|
|
List<OpiParameterIndividual> items = new List<OpiParameterIndividual>();
|
|
try
|
|
{
|
|
items = _opiParameterIndividualService.Get(fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterIndividualByParameterId/{parameterId}")]
|
|
public ActionResult GetOpiParameterIndividualByParameterId(int parameterId)
|
|
{
|
|
List<OpiParameterIndividual> items = new List<OpiParameterIndividual>();
|
|
try
|
|
{
|
|
items = _opiParameterIndividualService.GetByParameterID(parameterId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getIndividuals/{opiParamId}/{type}")]
|
|
public ActionResult GetIndividuals(int opiParamId, EnumOPIIndivdualType type)
|
|
{
|
|
List<OpiParameterIndividual> items = new List<OpiParameterIndividual>();
|
|
try
|
|
{
|
|
items = _opiParameterIndividualService.GetIndividuals(opiParamId, type);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOpiParameterIndividual/{opiParamId}/{employeeId}/{opiItemId}")]
|
|
public ActionResult GetOpiParameterIndividual(int opiParamId, int employeeId, int opiItemId)
|
|
{
|
|
OpiParameterIndividual item = new OpiParameterIndividual();
|
|
try
|
|
{
|
|
item = _opiParameterIndividualService.Get(opiParamId, employeeId, opiItemId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[Route("saveOpiParameterIndividual")]
|
|
public ActionResult SaveOpiParameterIndividual(OpiParameterIndividual item)
|
|
{
|
|
try
|
|
{
|
|
_opiParameterIndividualService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteOpiParameterIndividual")]
|
|
public ActionResult DeleteOpiParameterIndividual(int id)
|
|
{
|
|
try
|
|
{
|
|
_opiParameterIndividualService.Delete(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("bulkSaveOpiParameterIndividual")]
|
|
public ActionResult BulkSaveOpiParameterIndividual(List<OpiParameterIndividual> items)
|
|
{
|
|
try
|
|
{
|
|
_opiParameterIndividualService.BulkSave(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// OPIPayment
|
|
[HttpGet("getOPIPaymentById/{id}")]
|
|
public ActionResult GetOPIPaymentById(int id)
|
|
{
|
|
OPIPayment item = new OPIPayment();
|
|
try
|
|
{
|
|
item = _opiPaymentService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getAllOPIPayment")]
|
|
public ActionResult GetAllOPIPayment()
|
|
{
|
|
List<OPIPayment> items = new List<OPIPayment>();
|
|
try
|
|
{
|
|
items = _opiPaymentService.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveOPIPayment")]
|
|
public ActionResult SaveOPIPayment(OPIPayment item)
|
|
{
|
|
try
|
|
{
|
|
_opiPaymentService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveOPIPaymentList")]
|
|
public ActionResult SaveOPIPaymentList(List<OPIPayment> items)
|
|
{
|
|
try
|
|
{
|
|
_opiPaymentService.Save(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteOPIPayment")]
|
|
public ActionResult DeleteOPIPayment(int id)
|
|
{
|
|
try
|
|
{
|
|
_opiPaymentService.Delete(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// OPIProcess
|
|
[HttpGet("getOPIProcess/{id}")]
|
|
public ActionResult GetOPIProcess(int id)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
OPIProcess item = new OPIProcess();
|
|
try
|
|
{
|
|
item = _opiProcessService.Get(id, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getAllOPIProcess")]
|
|
public ActionResult GetAllOPIProcess()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcess> items = new List<OPIProcess>();
|
|
try
|
|
{
|
|
items = _opiProcessService.Get(payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOPIProcessListByOpiMonth/{opiMonth}")]
|
|
public ActionResult GetOPIProcessListByOpiMonth(DateTime opiMonth)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcess> items = new List<OPIProcess>();
|
|
try
|
|
{
|
|
items = _opiProcessService.Get(opiMonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
[HttpGet("getUnapprovedProcess/{opiMonth}")]
|
|
public ActionResult getUnapprovedProcess(string opiMonth)
|
|
{
|
|
DateTime dmonth = GlobalFunctions.GetApiDefaultDateData(opiMonth);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcess> items = new List<OPIProcess>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetUnApprovedProcess(dmonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getProcessDetailWithItems/{opiProcessId}")]
|
|
public ActionResult GetProcessDetailWithItems(int opiProcessId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetail> items = new List<OPIProcessDetail>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetProcessDetailWithItems(opiProcessId, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getProcessDetails/{opiProcessId}")]
|
|
public ActionResult GetProcessDetails(int opiProcessId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetail> items = new List<OPIProcessDetail>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetProcessDetails(opiProcessId, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getProcessDetailsByProcessMonth/{processMonth}")]
|
|
public ActionResult GetProcessDetailsByProcessMonth(DateTime processMonth)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetail> items = new List<OPIProcessDetail>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetProcessDetails(processMonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getProcessDetailItems/{processMonth}")]
|
|
public ActionResult GetProcessDetailItems(int processDetailId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetailItem> items = new List<OPIProcessDetailItem>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetProcessDetailItems(processDetailId, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDetail/{employeeId}/{opiMonth}")]
|
|
public ActionResult GetDetail(int employeeId, DateTime opiMonth)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
OPIProcessDetail item = new OPIProcessDetail();
|
|
try
|
|
{
|
|
item = _opiProcessService.GetDetail(employeeId, opiMonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getProvisionAmountByEmpID/{empId}")]
|
|
public ActionResult GetProvisionAmountByEmpID(int empId)
|
|
{
|
|
Double ans;
|
|
try
|
|
{
|
|
ans = _opiProcessService.GetProvisionAmountByEmpID(empId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getPrevMonthAmount/{empId}/{opiItemId}/{fromOpiMonth}/{toOpiMonth}")]
|
|
public ActionResult GetPrevMonthAmount(int empId, int opiItemId, DateTime fromOpiMonth, DateTime toOpDateTime)
|
|
{
|
|
Double ans;
|
|
try
|
|
{
|
|
ans = _opiProcessService.GetPrevMonthAmount(empId, opiItemId, fromOpiMonth, toOpDateTime);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getOPiProcessItems/{dateTime}")]
|
|
public ActionResult GetOPiProcessItems(DateTime dateTime)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetailItem> items = new List<OPIProcessDetailItem>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetOPiProcessItems(dateTime, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getLastMonthItems/{employeeId}")]
|
|
public ActionResult GetLastMonthItems(int employeeId)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
List<OPIProcessDetailItem> items = new List<OPIProcessDetailItem>();
|
|
try
|
|
{
|
|
items = _opiProcessService.GetLastMonthItems(employeeId, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
//[HttpPost]
|
|
//[Route("saveOPIProcess")]
|
|
//public ActionResult SaveOPIProcess(OPIProcess item)
|
|
//{
|
|
// try
|
|
// {
|
|
// _opiProcessService.Save(item);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
[HttpPost]
|
|
[Route("updateOnlyProcess")]
|
|
public ActionResult UpdateOnlyProcess(OPIProcess item)
|
|
{
|
|
try
|
|
{
|
|
_opiProcessService.UpdateOnlyProcess(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveOPIProcessList")]
|
|
public ActionResult SaveOPIProcessList(OPIProcess item)
|
|
{
|
|
List<OPIProcessDetail> opiProcessDetails = new List<OPIProcessDetail>();
|
|
try
|
|
{
|
|
_opiProcessService.Save(item, opiProcessDetails);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteOPIProcess")]
|
|
public ActionResult deleteOPIProcess(int id)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
_opiProcessService.Delete(id, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("OPIProcess")]
|
|
public ActionResult OPIProcess(dynamic processItems)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(processItems));
|
|
string empid = "";
|
|
foreach (var item in items)
|
|
{
|
|
empid = empid + (string)item["empid"].ToObject<string>() + ",";
|
|
}
|
|
if (empid.Length > 0)
|
|
{
|
|
empid = empid.Substring(0, empid.Length - 1);
|
|
}
|
|
List<OpiProcessStatus> errorOrSucess = new List<OpiProcessStatus>();
|
|
OpiCalculator ocal = new OpiCalculator();
|
|
try
|
|
{
|
|
|
|
List<Employee> employees = new EmployeeService().GetByEmpIDs(empid, (int)currentUser.PayrollTypeID);
|
|
|
|
ocal.Process(employees,
|
|
(DateTime) currentUser.NextPayProcessDate, (int)currentUser.PayrollTypeID, currentUser.UserID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ocal.ErrorList);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("undoOPIProcess")]
|
|
public ActionResult UndoOPIProcess(OPIProcess item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
_opiProcessService.Undo(item.OPIMonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpGet("GetMonthyIndividualAndOneOff/{status}")]
|
|
public ActionResult GetMonthyIndividualAndOneOff(EnumStatus status)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<OpiItem> returnItems = null;
|
|
try
|
|
{
|
|
returnItems = new OpiItemService().GetMonthyIndividualAndOneOff((int)currentUser.PayrollTypeID, EnumStatus.Active);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(returnItems);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("updateDetail")]
|
|
public ActionResult UpdateDetail(List<OPIProcessDetailItem> items)
|
|
{
|
|
try
|
|
{
|
|
_opiProcessService.UpdateDetail(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
} |