999 lines
47 KiB
C#
999 lines
47 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Data.SqlClient;
|
|
using HRM.BO;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Utility;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
[Serializable]
|
|
public class AttnMonthlyBenefitService : ServiceTemplate
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
public AttnMonthlyBenefitService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(AttnMonthlyBenefit aMonthlyBenefit, DataReader oReader)
|
|
{
|
|
base.SetObjectID(aMonthlyBenefit, oReader.GetInt32("AttnMonthlyBenefitID").Value);
|
|
aMonthlyBenefit.EmployeeID = oReader.GetInt32("EmployeeID").Value;
|
|
aMonthlyBenefit.SalaryMonth = oReader.GetDateTime("SalaryMonth").Value;
|
|
aMonthlyBenefit.Value1 = oReader.GetDouble("Value1") == null ? 0 : oReader.GetDouble("Value1").Value;
|
|
aMonthlyBenefit.Value2 = oReader.GetDouble("Value2") == null ? 0 : oReader.GetDouble("Value2").Value;
|
|
aMonthlyBenefit.Value3 = oReader.GetDouble("Value3") == null ? 0 : oReader.GetDouble("Value3").Value;
|
|
aMonthlyBenefit.Value4 = oReader.GetDouble("Value4") == null ? 0 : oReader.GetDouble("Value4").Value;
|
|
aMonthlyBenefit.Value5 = oReader.GetDouble("Value5") == null ? 0 : oReader.GetDouble("Value5").Value;
|
|
aMonthlyBenefit.Value6 = oReader.GetDouble("Value6") == null ? 0 : oReader.GetDouble("Value6").Value;
|
|
aMonthlyBenefit.Value7 = oReader.GetDouble("Value7") == null ? 0 : oReader.GetDouble("Value7").Value;
|
|
aMonthlyBenefit.Value8 = oReader.GetDouble("Value8") == null ? 0 : oReader.GetDouble("Value8").Value;
|
|
aMonthlyBenefit.Value9 = oReader.GetDouble("Value9") == null ? 0 : oReader.GetDouble("Value9").Value;
|
|
aMonthlyBenefit.Value10 = oReader.GetDouble("Value10") == null ? 0 : oReader.GetDouble("Value10").Value;
|
|
aMonthlyBenefit.Value11 = oReader.GetDouble("Value11") == null ? 0 : oReader.GetDouble("Value11").Value;
|
|
aMonthlyBenefit.Value12 = oReader.GetDouble("Value12") == null ? 0 : oReader.GetDouble("Value12").Value;
|
|
aMonthlyBenefit.Value13 = oReader.GetDouble("Value13") == null ? 0 : oReader.GetDouble("Value13").Value;
|
|
aMonthlyBenefit.Value14 = oReader.GetDouble("Value14") == null ? 0 : oReader.GetDouble("Value14").Value;
|
|
aMonthlyBenefit.Value15 = oReader.GetDouble("Value15") == null ? 0 : oReader.GetDouble("Value15").Value;
|
|
aMonthlyBenefit.Value16 = oReader.GetDouble("Value16") == null ? 0 : oReader.GetDouble("Value16").Value;
|
|
aMonthlyBenefit.Value17 = oReader.GetDouble("Value17") == null ? 0 : oReader.GetDouble("Value17").Value;
|
|
aMonthlyBenefit.Value18 = oReader.GetDouble("Value18") == null ? 0 : oReader.GetDouble("Value18").Value;
|
|
aMonthlyBenefit.Value19 = oReader.GetDouble("Value19") == null ? 0 : oReader.GetDouble("Value19").Value;
|
|
aMonthlyBenefit.Value20 = oReader.GetDouble("Value20") == null ? 0 : oReader.GetDouble("Value20").Value;
|
|
aMonthlyBenefit.Value21 = oReader.GetDouble("Value21") == null ? 0 : oReader.GetDouble("Value21").Value;
|
|
aMonthlyBenefit.Value22 = oReader.GetDouble("Value22") == null ? 0 : oReader.GetDouble("Value22").Value;
|
|
aMonthlyBenefit.Value23 = oReader.GetDouble("Value23") == null ? 0 : oReader.GetDouble("Value23").Value;
|
|
aMonthlyBenefit.Value24 = oReader.GetDouble("Value24") == null ? 0 : oReader.GetDouble("Value24").Value;
|
|
aMonthlyBenefit.Value25 = oReader.GetDouble("Value25") == null ? 0 : oReader.GetDouble("Value25").Value;
|
|
aMonthlyBenefit.Value26 = oReader.GetDouble("Value26") == null ? 0 : oReader.GetDouble("Value26").Value;
|
|
aMonthlyBenefit.Value27 = oReader.GetDouble("Value27") == null ? 0 : oReader.GetDouble("Value27").Value;
|
|
aMonthlyBenefit.Value28 = oReader.GetDouble("Value28") == null ? 0 : oReader.GetDouble("Value28").Value;
|
|
aMonthlyBenefit.Value29 = oReader.GetDouble("Value29") == null ? 0 : oReader.GetDouble("Value29").Value;
|
|
aMonthlyBenefit.Value30 = oReader.GetDouble("Value30") == null ? 0 : oReader.GetDouble("Value30").Value;
|
|
aMonthlyBenefit.Value31 = oReader.GetDouble("Value31") == null ? 0 : oReader.GetDouble("Value31").Value;
|
|
aMonthlyBenefit.Adjustment =
|
|
oReader.GetDouble("Adjustment") == null ? 0 : oReader.GetDouble("Adjustment").Value;
|
|
aMonthlyBenefit.IsEditable = oReader.GetBoolean("IsEditable").Value;
|
|
aMonthlyBenefit.IsValue1 = oReader.GetBoolean("IsVALUE1").Value;
|
|
aMonthlyBenefit.IsValue2 = oReader.GetBoolean("IsVALUE2").Value;
|
|
aMonthlyBenefit.IsValue3 = oReader.GetBoolean("IsVALUE3").Value;
|
|
aMonthlyBenefit.IsValue4 = oReader.GetBoolean("IsVALUE4").Value;
|
|
aMonthlyBenefit.IsValue5 = oReader.GetBoolean("IsVALUE5").Value;
|
|
aMonthlyBenefit.IsValue6 = oReader.GetBoolean("IsVALUE6").Value;
|
|
aMonthlyBenefit.IsValue7 = oReader.GetBoolean("IsVALUE7").Value;
|
|
aMonthlyBenefit.IsValue8 = oReader.GetBoolean("IsVALUE8").Value;
|
|
aMonthlyBenefit.IsValue9 = oReader.GetBoolean("IsVALUE9").Value;
|
|
aMonthlyBenefit.IsValue10 = oReader.GetBoolean("IsVALUE10").Value;
|
|
|
|
aMonthlyBenefit.IsValue11 = oReader.GetBoolean("IsVALUE11").Value;
|
|
aMonthlyBenefit.IsValue12 = oReader.GetBoolean("IsVALUE12").Value;
|
|
|
|
aMonthlyBenefit.IsValue13 = oReader.GetBoolean("IsVALUE13").Value;
|
|
aMonthlyBenefit.IsValue14 = oReader.GetBoolean("IsVALUE14").Value;
|
|
aMonthlyBenefit.IsValue15 = oReader.GetBoolean("IsVALUE15").Value;
|
|
aMonthlyBenefit.IsValue16 = oReader.GetBoolean("IsVALUE16").Value;
|
|
aMonthlyBenefit.IsValue17 = oReader.GetBoolean("IsVALUE17").Value;
|
|
aMonthlyBenefit.IsValue18 = oReader.GetBoolean("IsVALUE18").Value;
|
|
aMonthlyBenefit.IsValue19 = oReader.GetBoolean("IsVALUE19").Value;
|
|
aMonthlyBenefit.IsValue20 = oReader.GetBoolean("IsVALUE20").Value;
|
|
aMonthlyBenefit.IsValue21 = oReader.GetBoolean("IsVALUE21").Value;
|
|
aMonthlyBenefit.IsValue22 = oReader.GetBoolean("IsVALUE22").Value;
|
|
aMonthlyBenefit.IsValue23 = oReader.GetBoolean("IsVALUE23").Value;
|
|
aMonthlyBenefit.IsValue24 = oReader.GetBoolean("IsVALUE24").Value;
|
|
aMonthlyBenefit.IsValue25 = oReader.GetBoolean("IsVALUE25").Value;
|
|
aMonthlyBenefit.IsValue26 = oReader.GetBoolean("IsVALUE26").Value;
|
|
aMonthlyBenefit.IsValue27 = oReader.GetBoolean("IsVALUE27").Value;
|
|
aMonthlyBenefit.IsValue28 = oReader.GetBoolean("IsVALUE28").Value;
|
|
aMonthlyBenefit.IsValue29 = oReader.GetBoolean("IsVALUE29").Value;
|
|
aMonthlyBenefit.IsValue30 = oReader.GetBoolean("IsVALUE30").Value;
|
|
aMonthlyBenefit.IsValue31 = oReader.GetBoolean("IsVALUE31").Value;
|
|
aMonthlyBenefit.ItemType = (enumPayrollComponentType)oReader.GetInt32("ItemType").Value;
|
|
aMonthlyBenefit.ItemID = oReader.GetInt32("ItemID").Value;
|
|
aMonthlyBenefit.ItemName = oReader.GetString("ItemName");
|
|
aMonthlyBenefit.IsAddition = oReader.GetBoolean("IsAddition").Value;
|
|
aMonthlyBenefit.Total = oReader.GetDouble("Total") == null ? 0 : oReader.GetDouble("Total").Value;
|
|
this.SetObjectState(aMonthlyBenefit, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
AttnMonthlyBenefit aMonthlyBenefit = new AttnMonthlyBenefit();
|
|
MapObject(aMonthlyBenefit, oReader);
|
|
return aMonthlyBenefit as T;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
|
|
public void SaveNew(List<AttnMonthlyBenefit> aMonthlyBenefits, List<AttnBenefitAuditTrail> aTrails,
|
|
TransactionContext tc)
|
|
{
|
|
try
|
|
{
|
|
int id = tc.GenerateID("AttnMonthlyBenefit", "AttnMonthlyBenefitID");
|
|
|
|
if (aMonthlyBenefits != null)
|
|
{
|
|
foreach (AttnMonthlyBenefit mbenifit in aMonthlyBenefits)
|
|
{
|
|
if (mbenifit.IsNew)
|
|
{
|
|
if (AttnMonthlyBenefitDA.IsExist(tc, mbenifit.EmployeeID, mbenifit.SalaryMonth,
|
|
mbenifit.ItemType, mbenifit.ItemID))
|
|
{
|
|
AttnMonthlyBenefitDA.Delete(tc, mbenifit);
|
|
base.SetObjectID(mbenifit, id);
|
|
AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
}
|
|
else
|
|
{
|
|
base.SetObjectID(mbenifit, id);
|
|
AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AttnMonthlyBenefitDA.Update(tc, mbenifit);
|
|
}
|
|
|
|
id++;
|
|
}
|
|
}
|
|
|
|
id = tc.GenerateID("ATTNBENEFITAUDITTRAIL", "ATTNBENEFITAUDITTRAILID");
|
|
foreach (AttnBenefitAuditTrail item in aTrails)
|
|
{
|
|
base.SetObjectID(item, id);
|
|
AttnBenefitAuditTrailDA.Insert(tc, item);
|
|
id++;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(List<AttnMonthlyBenefit> aMonthlyBenefits, List<AttnBenefitAuditTrail> auditTrails)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SaveNew(aMonthlyBenefits, auditTrails, tc);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> GetWithPayrollType(int payrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.GetWithPayrollType(tc, payrollTypeID));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> Get(int empId)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.Get(tc, empId));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> GetWithSalaryMonth(DateTime sMonth, int payrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.GetWithSalaryMonth(tc, sMonth, payrollTypeID));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public List<AttnMonthlyBenefit> Get(int empId, DateTime sMonth)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.Get(tc, empId, sMonth));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> Get(int empId, DateTime fromMonth, DateTime toMonth)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.Get(tc, empId, fromMonth, toMonth));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> Get(string empIds, DateTime fromMonth, DateTime toMonth)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.Get(tc, empIds, fromMonth, toMonth));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> GetWithSalaryMonthRange(DateTime fromMonth, DateTime toMonth, int PayrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr =
|
|
new DataReader(AttnMonthlyBenefitDA.GetWithSalaryMonthRange(tc, fromMonth, toMonth, PayrollTypeID));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> Get(string empIds, DateTime sMonth)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.Get(tc, empIds, sMonth));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<AttnMonthlyBenefit> GetByDept(string deptId, DateTime sMonth, int PayrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnMonthlyBenefitDA.GetByDept(tc, deptId, sMonth, PayrollTypeID));
|
|
var aMonthlyBenefits = this.CreateObjects<AttnMonthlyBenefit>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return aMonthlyBenefits;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(List<AttnMonthlyBenefit> aMonthlyBenefits)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
Save(aMonthlyBenefits, tc);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void FixOverTimeData()
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
AttnMonthlyBenefitDA.FixOverTimeData(tc);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void UpdateOverTimeData(DateTime salaryMonth, enumPayrollComponentType itemType, string value,
|
|
string isValue, DateTime attnDate)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
AttnMonthlyBenefitDA.UpdateOverTimeData(tc, salaryMonth, itemType, value, isValue, attnDate);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void SaveAsBenifits(int payrolltypeid, List<ADParameterEmployee> adEmployee, List<EmployeeOverTime> empOverTimes,
|
|
List<EmployeeUnAuthorizeLeave> uleaves)
|
|
{
|
|
PayrollType opType = new PayrollTypeService().Get(payrolltypeid);
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
var ads = from r in adEmployee
|
|
group r by r.AllowDeductID into g
|
|
select g.Key;
|
|
foreach (var item in ads)
|
|
{
|
|
ADParameterEmployeeDA.DeleteByMonth(tc, (int)item, opType.NextPayProcessDate);
|
|
}
|
|
|
|
foreach (ADParameterEmployee item in adEmployee)
|
|
{
|
|
new ADParameterEmployeeService().Save(tc, item);
|
|
}
|
|
|
|
EmployeeOverTimeService termService = new EmployeeOverTimeService();
|
|
EmployeeOverTimeDA.DeleteByMonth(tc, opType.NextPayProcessDate);
|
|
termService.BulkSave(tc, empOverTimes);
|
|
|
|
EmployeeUnAuthorizeLeaveService ouservice = new EmployeeUnAuthorizeLeaveService();
|
|
EmployeeUnAuthorizeLeaveDA.Delete(tc, opType.NextPayProcessDate);
|
|
ouservice.bulkSave(tc, uleaves);
|
|
|
|
PayrollTypeDA.UpdateBenifits(tc, true, opType.ID);
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public DateTime GetAttandaceSalaryMonth(DateTime dDate)
|
|
{
|
|
if (dDate.Day >= 11)
|
|
return GlobalFunctions.LastDateOfMonth(dDate.AddMonths(1));
|
|
else return GlobalFunctions.LastDateOfMonth(dDate);
|
|
}
|
|
|
|
#region UnUsed Method
|
|
|
|
//public void BulkSave(List<AttnMonthlyBenefit> aMonthlyBenefits, TransactionContext tc)
|
|
//{
|
|
// DataTable amBenefitTable = new DataTable("AttnMonthlyBenefit");
|
|
// amBenefitTable.Columns.Add(new DataColumn("AttnMonthlyBenefitID", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("EmployeeID", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("SalaryMonth", typeof(DateTime)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("ItemType", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("ItemID", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsAddition", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value1", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value2", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value3", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value4", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value5", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value6", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value7", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value8", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value9", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value10", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value11", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value12", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value13", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value14", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value15", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value16", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value17", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value18", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value19", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value20", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value21", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value22", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value23", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value24", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value25", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value26", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value27", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value28", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value29", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value30", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Value31", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Adjustment", typeof(double)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsEditable", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue1", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue2", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue3", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue4", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue5", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue6", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue7", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue8", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue9", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue10", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue11", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue12", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue13", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue14", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue15", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue16", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue17", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue18", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue19", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue20", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue21", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue22", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue23", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue24", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue25", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue26", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue27", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue28", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue29", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue30", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("IsValue31", typeof(int)));
|
|
// amBenefitTable.Columns.Add(new DataColumn("Total", typeof(double)));
|
|
|
|
// try
|
|
// {
|
|
// int id = tc.GenerateID("AttnMonthlyBenefit", "AttnMonthlyBenefitID");
|
|
// string sConnectionName = tc.Connection.ConnectionString;
|
|
// foreach (AttnMonthlyBenefit item in aMonthlyBenefits)
|
|
// {
|
|
// if (AttnMonthlyBenefitDA.IsExist(tc, item.EmployeeID, item.SalaryMonth, item.ItemType, item.ItemID))
|
|
// AttnMonthlyBenefitDA.Delete(tc, item);
|
|
// amBenefitTable.Rows.Add(id,
|
|
// item.EmployeeID,
|
|
// item.SalaryMonth,
|
|
// item.ItemType,
|
|
// item.ItemID,
|
|
// Convert.ToInt16(item.IsAddition),
|
|
// item.Value1,
|
|
// item.Value2,
|
|
// item.Value3,
|
|
// item.Value4,
|
|
// item.Value5,
|
|
// item.Value6,
|
|
// item.Value7,
|
|
// item.Value8,
|
|
// item.Value9,
|
|
// item.Value10,
|
|
// item.Value11,
|
|
// item.Value12,
|
|
// item.Value13,
|
|
// item.Value14,
|
|
// item.Value15,
|
|
// item.Value16,
|
|
// item.Value17,
|
|
// item.Value18,
|
|
// item.Value19,
|
|
// item.Value20,
|
|
// item.Value21,
|
|
// item.Value22,
|
|
// item.Value23,
|
|
// item.Value24,
|
|
// item.Value25,
|
|
// item.Value26,
|
|
// item.Value27,
|
|
// item.Value28,
|
|
// item.Value29,
|
|
// item.Value30,
|
|
// item.Value31,
|
|
// item.Adjustment,
|
|
// Convert.ToInt16(item.IsEditable),
|
|
// Convert.ToInt16(item.IsValue1),
|
|
// Convert.ToInt16(item.IsValue2),
|
|
// Convert.ToInt16(item.IsValue3),
|
|
// Convert.ToInt16(item.IsValue4),
|
|
// Convert.ToInt16(item.IsValue5),
|
|
// Convert.ToInt16(item.IsValue6),
|
|
// Convert.ToInt16(item.IsValue7),
|
|
// Convert.ToInt16(item.IsValue8),
|
|
// Convert.ToInt16(item.IsValue9),
|
|
// Convert.ToInt16(item.IsValue10),
|
|
// Convert.ToInt16(item.IsValue11),
|
|
// Convert.ToInt16(item.IsValue12),
|
|
// Convert.ToInt16(item.IsValue13),
|
|
// Convert.ToInt16(item.IsValue14),
|
|
// Convert.ToInt16(item.IsValue15),
|
|
// Convert.ToInt16(item.IsValue16),
|
|
// Convert.ToInt16(item.IsValue17),
|
|
// Convert.ToInt16(item.IsValue18),
|
|
// Convert.ToInt16(item.IsValue19),
|
|
// Convert.ToInt16(item.IsValue20),
|
|
// Convert.ToInt16(item.IsValue21),
|
|
// Convert.ToInt16(item.IsValue22),
|
|
// Convert.ToInt16(item.IsValue23),
|
|
// Convert.ToInt16(item.IsValue24),
|
|
// Convert.ToInt16(item.IsValue25),
|
|
// Convert.ToInt16(item.IsValue26),
|
|
// Convert.ToInt16(item.IsValue27),
|
|
// Convert.ToInt16(item.IsValue28),
|
|
// Convert.ToInt16(item.IsValue29),
|
|
// Convert.ToInt16(item.IsValue30),
|
|
// Convert.ToInt16(item.IsValue31),
|
|
// item.Total);
|
|
// id++;
|
|
// }
|
|
// using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sConnectionName))
|
|
// {
|
|
// bulkCopy.BulkCopyTimeout = 600; // in seconds
|
|
// bulkCopy.DestinationTableName = "AttnMonthlyBenefit";
|
|
// bulkCopy.WriteToServer(amBenefitTable);
|
|
// }
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// }
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
public void Save(List<AttnMonthlyBenefit> aMonthlyBenefits, TransactionContext tc)
|
|
{
|
|
try
|
|
{
|
|
if (aMonthlyBenefits != null)
|
|
{
|
|
int id = tc.GenerateID("AttnMonthlyBenefit", "AttnMonthlyBenefitID");
|
|
|
|
foreach (AttnMonthlyBenefit mbenifit in aMonthlyBenefits)
|
|
{
|
|
if (mbenifit.IsNew)
|
|
{
|
|
if (AttnMonthlyBenefitDA.IsExist(tc, mbenifit.EmployeeID, mbenifit.SalaryMonth,
|
|
mbenifit.ItemType, mbenifit.ItemID))
|
|
{
|
|
AttnMonthlyBenefitDA.Delete(tc, mbenifit);
|
|
base.SetObjectID(mbenifit, id);
|
|
AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
}
|
|
else
|
|
{
|
|
base.SetObjectID(mbenifit, id);
|
|
AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AttnMonthlyBenefitDA.Update(tc, mbenifit);
|
|
}
|
|
|
|
//if (AttnMonthlyBenefitDA.IsExist(tc, mbenifit.EmployeeID, mbenifit.SalaryMonth, mbenifit.ItemType, mbenifit.ItemID))
|
|
//{
|
|
// AttnMonthlyBenefitDA.Delete(tc, mbenifit);
|
|
// base.SetObjectID(mbenifit, ID.FromInteger(id));
|
|
// AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
//}
|
|
//else
|
|
//{
|
|
// base.SetObjectID(mbenifit, ID.FromInteger(id));
|
|
// AttnMonthlyBenefitDA.Insert(tc, mbenifit);
|
|
//}
|
|
id++;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
internal double CalculateAllowanceValue(AttnWiseAllowance oAttnWiseAllowance, DailyAttnProcess dailyAttnProcess)
|
|
{
|
|
AttnWiseAllowanceService attnWiseAllowanceService = new AttnWiseAllowanceService();
|
|
double value = 0;
|
|
if (dailyAttnProcess.AttenType == EnumAttendanceType.Absent) return value;
|
|
|
|
if (oAttnWiseAllowance.OutTimeDependent == true && dailyAttnProcess.OutTime != null &&
|
|
dailyAttnProcess.OutTime > attnWiseAllowanceService.GetShiftOutTime(oAttnWiseAllowance, dailyAttnProcess.Shift, dailyAttnProcess))
|
|
{
|
|
value = oAttnWiseAllowance.Multiple;
|
|
}
|
|
else
|
|
{
|
|
value = oAttnWiseAllowance.Multiple;
|
|
|
|
}
|
|
return value;
|
|
}
|
|
|
|
internal double CalculateOvertimeValue(AttnWiseAllowance oAttnWiseAllowance,
|
|
DailyAttnProcess dailyAttnProcess, int payrollTypeID)
|
|
{
|
|
double value = 0;
|
|
Grade oGrade = new GradeService().Get((int)dailyAttnProcess.Employee.GradeID);
|
|
if (oGrade != null)
|
|
{
|
|
var termParameters = new TermParameterService().GetByPayrollTypeID(payrollTypeID)
|
|
.Where(x => x.TermID == oAttnWiseAllowance.ProvisionID);
|
|
TermParameter termParameter = null;
|
|
|
|
foreach (var item in termParameters)
|
|
{
|
|
var setupDetails = new SetupDetailService().GetParameters(EnumParameterSetup.OT, item.ID);
|
|
if (setupDetails.Any(x => x.TranID == oGrade.ID))
|
|
{
|
|
termParameter = item;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (termParameter != null)
|
|
{
|
|
switch (termParameter.Type)
|
|
{
|
|
case EnumOverTimeType.DailyFlatAmount:
|
|
case EnumOverTimeType.DailyBasicPercent:
|
|
case EnumOverTimeType.FixedAmount:
|
|
value = 1 * oAttnWiseAllowance.Multiple;
|
|
break;
|
|
case EnumOverTimeType.HourlyFlatAmount:
|
|
case EnumOverTimeType.HourlyBasicPercent:
|
|
value = dailyAttnProcess.OTHour * oAttnWiseAllowance.Multiple;
|
|
break;
|
|
case EnumOverTimeType.HoursOfMonth:
|
|
case EnumOverTimeType.Slab:
|
|
case EnumOverTimeType.AnyAmount:
|
|
case EnumOverTimeType.NONE:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
internal static double CalculateOvertimeAmount(AttnWiseAllowance oAttnWiseAllowance,
|
|
DailyAttnProcess dailyAttnProcess, double totalValue, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
Grade oGrade = new GradeService().Get((int)dailyAttnProcess.Employee.GradeID);
|
|
|
|
if (oGrade != null)
|
|
{
|
|
var termParameters = new TermParameterService().GetByPayrollTypeID(payrollTypeID)
|
|
.Where(x => x.TermID == oAttnWiseAllowance.ProvisionID);
|
|
TermParameter termParameter = null;
|
|
|
|
foreach (var item in termParameters)
|
|
{
|
|
var setupDetails = new SetupDetailService().GetParameters(EnumParameterSetup.OT, item.ID);
|
|
if (setupDetails.Any(x => x.TranID == oGrade.ID))
|
|
{
|
|
termParameter = item;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (termParameter != null)
|
|
{
|
|
switch (termParameter.Type)
|
|
{
|
|
case EnumOverTimeType.DailyFlatAmount:
|
|
case EnumOverTimeType.FixedAmount:
|
|
case EnumOverTimeType.HourlyFlatAmount:
|
|
amount = totalValue * termParameter.Amount;
|
|
break;
|
|
case EnumOverTimeType.DailyBasicPercent:
|
|
amount = (dailyAttnProcess.Employee.BasicSalary / Convert.ToDouble(
|
|
DateTime.DaysInMonth(dailyAttnProcess.AttnDate.Year,
|
|
dailyAttnProcess.AttnDate.Month)))
|
|
* totalValue * (termParameter.Amount / 100);
|
|
break;
|
|
case EnumOverTimeType.HourlyBasicPercent:
|
|
double hours = (double)ConfigurationManager.GetIntValue("overtime", "hoursonmonth",
|
|
EnumConfigurationType.Logic);
|
|
if (hours <= 0) hours = 180.0;
|
|
amount = (dailyAttnProcess.Employee.BasicSalary / hours) * totalValue *
|
|
(termParameter.Amount / 100);
|
|
break;
|
|
case EnumOverTimeType.HoursOfMonth:
|
|
case EnumOverTimeType.Slab:
|
|
case EnumOverTimeType.AnyAmount:
|
|
case EnumOverTimeType.NONE:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
public AttnMonthlyBenefit CalculateTotal(AttnMonthlyBenefit pAttnMonthlyBenefit)
|
|
{
|
|
pAttnMonthlyBenefit.Total = pAttnMonthlyBenefit.Value1 + pAttnMonthlyBenefit.Value2 + pAttnMonthlyBenefit.Value3 + pAttnMonthlyBenefit.Value4 + pAttnMonthlyBenefit.Value5 + pAttnMonthlyBenefit.Value6 + pAttnMonthlyBenefit.Value7 + pAttnMonthlyBenefit.Value8 + pAttnMonthlyBenefit.Value9 + pAttnMonthlyBenefit.Value10
|
|
+ pAttnMonthlyBenefit.Value11 + pAttnMonthlyBenefit.Value12 + pAttnMonthlyBenefit.Value13 + pAttnMonthlyBenefit.Value14 + pAttnMonthlyBenefit.Value15 + pAttnMonthlyBenefit.Value16 + pAttnMonthlyBenefit.Value17 + pAttnMonthlyBenefit.Value18 + pAttnMonthlyBenefit.Value19 + pAttnMonthlyBenefit.Value20
|
|
+ pAttnMonthlyBenefit.Value21 + pAttnMonthlyBenefit.Value22 + pAttnMonthlyBenefit.Value23 + pAttnMonthlyBenefit.Value24 + pAttnMonthlyBenefit.Value25 + pAttnMonthlyBenefit.Value26 + pAttnMonthlyBenefit.Value27 + pAttnMonthlyBenefit.Value28 + pAttnMonthlyBenefit.Value29 + pAttnMonthlyBenefit.Value30
|
|
+ pAttnMonthlyBenefit.Value31 + pAttnMonthlyBenefit.Adjustment;
|
|
|
|
return pAttnMonthlyBenefit;
|
|
}
|
|
private List<ADParameterEmployee> MakeADParameterEmployeeObj(ref List<ADParameterEmployee> AdparamEmployee, ref List<SalaryProcessStatus> ErrorList, Employee tempEmployee, List<ADParameter> oadParameters, PayrollType oPayrollType, int allowanceId, double total)
|
|
{
|
|
List<ADParameter> applicableParams = new ADParameterService().GetApplicableParameters(tempEmployee, (int)tempEmployee.GradeID, oadParameters);
|
|
if (applicableParams == null)
|
|
{
|
|
ErrorList.Add(new SalaryProcessStatus(tempEmployee.EmployeeNo, tempEmployee.Name, " No Alloance/Benifits parameters found in live allowance/Benifits list"));
|
|
return AdparamEmployee;
|
|
}
|
|
var AppliedIndvParam = applicableParams.Where(x => x.EntitleType == EnumEntitleType.Individual && x.IsDependsOnAttendance == true && x.Periodicity == EnumPeriodicity.Monthly && x.AllowDeductID == allowanceId).ToList();
|
|
if (AppliedIndvParam == null)
|
|
{
|
|
ErrorList.Add(new SalaryProcessStatus(tempEmployee.EmployeeNo, tempEmployee.Name, " Individualy and depand on Attandance declared Alloance/Benifits parameters found in live allowance/Benifits list"));
|
|
return AdparamEmployee;
|
|
}
|
|
foreach (ADParameter indvParam in AppliedIndvParam)
|
|
{
|
|
ADParameterEmployee adparamEmp = new ADParameterEmployee();
|
|
adparamEmp.EmployeeID = tempEmployee.ID;
|
|
adparamEmp.MonthlyAmount = total * indvParam.FlatAmount;
|
|
adparamEmp.Periodicity = EnumPeriodicity.Monthly;
|
|
adparamEmp.FormDate = GlobalFunctions.FirstDateOfMonth(oPayrollType.NextPayProcessDate);
|
|
adparamEmp.TillDate = GlobalFunctions.LastDateOfMonth(oPayrollType.NextPayProcessDate);
|
|
adparamEmp.ADParameterID = indvParam.ID;
|
|
adparamEmp.ADEmpType = EnumADEmpType.AppliedToIndividual;
|
|
adparamEmp.AllowDeductID = allowanceId;
|
|
adparamEmp.Arreartype = EnumArrearType.NotPresent;
|
|
adparamEmp.CreatedBy = 0;
|
|
adparamEmp.CreatedDate = DateTime.Today;
|
|
|
|
AdparamEmployee.Add(adparamEmp);
|
|
}
|
|
|
|
return AdparamEmployee;
|
|
}
|
|
private List<EmployeeOverTime> MakeEmployeeOvertimeObj(ref List<EmployeeOverTime> EmpOverTimes, ref List<SalaryProcessStatus> ErrorList, Employee tempEmployee, List<EmployeeSetupParameter> appOtParam, List<TermParameter> termParameters, List<AttnWiseAllowance> attnAllows, PayrollType oPayrollType, int allowanceId, double total)
|
|
{
|
|
AttnWiseAllowance attnAllow = new AttnWiseAllowance();
|
|
EmployeeSetupParameter esp = appOtParam.Find(otparam => otparam.Employee.ID == tempEmployee.ID);
|
|
|
|
bool paramNotFound = true;
|
|
if (esp != null)
|
|
{
|
|
for (int i = 0; i <= esp.ParameterIDs.Count - 1; i++)
|
|
{
|
|
TermParameter tpt = termParameters.Find(delegate (TermParameter tm)
|
|
{
|
|
return (tm.ID == esp.ParameterIDs[i])
|
|
&& tm.TermID == allowanceId;
|
|
});
|
|
if (tpt != null)
|
|
{
|
|
attnAllow = attnAllows.Where(o => o.ProvisionType == enumPayrollComponentType.Over_Time && o.ProvisionID == allowanceId).FirstOrDefault();
|
|
EmployeeOverTime empot = new EmployeeOverTime();
|
|
empot.EmployeeID = tempEmployee.ID;
|
|
empot.OTMonth = oPayrollType.NextPayProcessDate;
|
|
empot.PayrollTypeID = oPayrollType.ID;
|
|
empot.TermID = allowanceId;
|
|
empot.TermParameterID = esp.ParameterIDs[i];
|
|
TermParameter op = termParameters.Find(item => item.ID == empot.TermParameterID);
|
|
if (attnAllow != null)
|
|
{
|
|
empot.OTHours = total;
|
|
empot.Value = op.Amount;
|
|
}
|
|
|
|
empot.CreatedBy = oPayrollType.ID;
|
|
empot.CreatedDate = DateTime.Today;
|
|
empot.MonthDate = oPayrollType.NextPayProcessDate;
|
|
EmpOverTimes.Add(empot);
|
|
paramNotFound = false;
|
|
break;
|
|
}
|
|
}
|
|
if (paramNotFound)
|
|
{
|
|
ErrorList.Add(new SalaryProcessStatus(tempEmployee.EmployeeNo, tempEmployee.Name, "OT setup not found"));
|
|
return EmpOverTimes;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ErrorList.Add(new SalaryProcessStatus(tempEmployee.EmployeeNo, tempEmployee.Name, "OT setup not found"));
|
|
return EmpOverTimes;
|
|
}
|
|
|
|
return EmpOverTimes;
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
} |