306 lines
12 KiB
C#
306 lines
12 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public class EmployeeConfirmation : AuditTrailBase
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(EmployeeConfirmation));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public EmployeeConfirmation()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region EmployeeID : ID
|
|||
|
|
|||
|
private ID _employeeID;
|
|||
|
public ID EmployeeID
|
|||
|
{
|
|||
|
get { return _employeeID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("EmployeeID", _employeeID, value);
|
|||
|
_employeeID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Month : int
|
|||
|
|
|||
|
private int _month;
|
|||
|
public int Month
|
|||
|
{
|
|||
|
get { return _month; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("Month", _month, value);
|
|||
|
_month = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ConfirmDate : DateTime
|
|||
|
|
|||
|
private DateTime _confirmDate;
|
|||
|
public DateTime ConfirmDate
|
|||
|
{
|
|||
|
get { return _confirmDate; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<DateTime>("ConfirmDate", _confirmDate, value);
|
|||
|
_confirmDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory IEmployeeConfirmationService : IEmployeeConfirmationService
|
|||
|
|
|||
|
internal static IEmployeeConfirmationService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IEmployeeConfirmationService>(typeof(IEmployeeConfirmationService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
public static EmployeeConfirmation Get(ID nID)
|
|||
|
{
|
|||
|
EmployeeConfirmation oEmployeeConfirmation = null;
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
oEmployeeConfirmation = (EmployeeConfirmation)_cache["Get", nID];
|
|||
|
if (oEmployeeConfirmation != null)
|
|||
|
return oEmployeeConfirmation;
|
|||
|
#endregion
|
|||
|
oEmployeeConfirmation = EmployeeConfirmation.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployeeConfirmation, "Get", nID);
|
|||
|
#endregion
|
|||
|
|
|||
|
return oEmployeeConfirmation;
|
|||
|
}
|
|||
|
|
|||
|
public static EmployeeConfirmation GetByEmployeeID(ID nID)
|
|||
|
{
|
|||
|
EmployeeConfirmation oEmployeeConfirmation = null;
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
oEmployeeConfirmation = (EmployeeConfirmation)_cache["GetByEmployeeID", nID];
|
|||
|
if (oEmployeeConfirmation != null)
|
|||
|
return oEmployeeConfirmation;
|
|||
|
#endregion
|
|||
|
|
|||
|
EmployeeConfirmation tempEmpConfirmation = EmployeeConfirmation.Service.GetByEmployeeID(nID);
|
|||
|
if (tempEmpConfirmation != null) oEmployeeConfirmation = Employee.GetAllEmps().Where(obj=>obj.ID==tempEmpConfirmation.EmployeeID && obj.IsConfirmed).Any() ? null : tempEmpConfirmation;
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployeeConfirmation, "GetByEmployeeID", nID);
|
|||
|
#endregion
|
|||
|
|
|||
|
return oEmployeeConfirmation;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<EmployeeConfirmation> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<EmployeeConfirmation> employeeConfirmations = _cache["Get"] as ObjectsTemplate<EmployeeConfirmation>;
|
|||
|
if (employeeConfirmations != null)
|
|||
|
return employeeConfirmations;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oEmployees = Employee.GetAllEmps();
|
|||
|
employeeConfirmations = new ObjectsTemplate<EmployeeConfirmation>();
|
|||
|
ObjectsTemplate<EmployeeConfirmation> tempEmpConfirmation = EmployeeConfirmation.Service.Get();
|
|||
|
if (tempEmpConfirmation != null)
|
|||
|
{
|
|||
|
foreach (EmployeeConfirmation item in tempEmpConfirmation)
|
|||
|
{
|
|||
|
if (!oEmployees.Where(obj => obj.ID == item.EmployeeID && obj.IsConfirmed).Any())
|
|||
|
employeeConfirmations.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employeeConfirmations, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employeeConfirmations;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<EmployeeConfirmation> GetByDateRange(DateTime dStart,DateTime dEnd)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<EmployeeConfirmation> employeeConfirmations = _cache["GetByDateRange", dStart, dEnd] as ObjectsTemplate<EmployeeConfirmation>;
|
|||
|
if (employeeConfirmations != null)
|
|||
|
return employeeConfirmations;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oEmployees = Employee.GetAllEmps();
|
|||
|
employeeConfirmations = new ObjectsTemplate<EmployeeConfirmation>();
|
|||
|
List<EmployeeConfirmation> tempEmpConfirmation = EmployeeConfirmation.Service.Get().Where(item => item.ConfirmDate >= dStart && item.ConfirmDate <= dEnd).ToList();
|
|||
|
if (tempEmpConfirmation != null)
|
|||
|
{
|
|||
|
if (User.CurrentUser == null || User.CurrentUser.LogInPayrollTypeID == null)
|
|||
|
{
|
|||
|
foreach (EmployeeConfirmation item in tempEmpConfirmation)
|
|||
|
{
|
|||
|
if (oEmployees.Where(obj => obj.ID == item.EmployeeID && !obj.IsConfirmed).Any())
|
|||
|
employeeConfirmations.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
foreach (EmployeeConfirmation item in tempEmpConfirmation)
|
|||
|
{
|
|||
|
if (oEmployees.Where(obj => obj.ID == item.EmployeeID && !obj.IsConfirmed && obj.PayrollTypeID == SystemInformation.CurrentSysInfo.PayrollTypeID).Any())
|
|||
|
employeeConfirmations.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
if(employeeConfirmations.Count>0)
|
|||
|
_cache.Add(employeeConfirmations,"GetByDateRange", dStart, dEnd);
|
|||
|
else
|
|||
|
_cache.Add(null, "GetByDateRange", dStart, dEnd);
|
|||
|
#endregion
|
|||
|
|
|||
|
return employeeConfirmations;
|
|||
|
}
|
|||
|
|
|||
|
public static bool IsWaitingForConfirmation()
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oAllEmployees = Employee.GetAllEmps();
|
|||
|
ObjectsTemplate<EmployeeConfirmation> oEmpConfirms = GetByDateRange(GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate), GlobalFunctions.LastDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate));
|
|||
|
|
|||
|
if (oEmpConfirms != null)
|
|||
|
return true;
|
|||
|
|
|||
|
//**** 6 Month Auto Confirm Logic***************
|
|||
|
//List<Employee> oUnConfirmedEmployee = oAllEmployees.Where(obj => obj.Status == EnumEmployeeStatus.Live &&
|
|||
|
// obj.PayrollTypeID == Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID &&
|
|||
|
// obj.IsConfirmed == false &&
|
|||
|
// obj.JoiningDate.AddMonths(6) >= GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate) &&
|
|||
|
// obj.JoiningDate.AddMonths(6) <= GlobalFunctions.LastDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate) &&
|
|||
|
// EmployeeConfirmation.GetByEmployeeID(obj.ID)==null).ToList();
|
|||
|
//if (oUnConfirmedEmployee != null)
|
|||
|
// return true;
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Employee> GetEmployeesWaitingForConfirmation()
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oUnConfirmedEmployees = new ObjectsTemplate<Employee>();
|
|||
|
ObjectsTemplate<Employee> oAllEmployees = Employee.GetAllEmps();
|
|||
|
ObjectsTemplate<EmployeeConfirmation> oEmpConfirms = GetByDateRange(GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate), GlobalFunctions.LastDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate));
|
|||
|
if (oEmpConfirms == null) return oUnConfirmedEmployees;
|
|||
|
foreach (EmployeeConfirmation item in oEmpConfirms)
|
|||
|
{
|
|||
|
Employee empTemp = oAllEmployees.Where(obj => obj.ID == item.EmployeeID && obj.IsConfirmed == false).SingleOrDefault();
|
|||
|
if (empTemp != null) oUnConfirmedEmployees.Add(empTemp);
|
|||
|
}
|
|||
|
|
|||
|
//**** 6 Month Auto Confirm Logic***************
|
|||
|
//List<Employee> oUnConfirmedEmployee = oAllEmployees.Where(obj => obj.Status == EnumEmployeeStatus.Live &&
|
|||
|
// obj.PayrollTypeID == Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID &&
|
|||
|
// obj.IsConfirmed == false &&
|
|||
|
// obj.JoiningDate.AddMonths(6) >= GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate) &&
|
|||
|
// obj.JoiningDate.AddMonths(6) <= GlobalFunctions.LastDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate) &&
|
|||
|
// EmployeeConfirmation.GetByEmployeeID(obj.ID)==null).ToList();
|
|||
|
//if (oUnConfirmedEmployee != null)
|
|||
|
// return true;
|
|||
|
|
|||
|
return oUnConfirmedEmployees;
|
|||
|
}
|
|||
|
|
|||
|
//public static ObjectsTemplate<Employee> WaitingForConfirmationOnSelectedEmployees(ObjectsTemplate<Employee> employees)
|
|||
|
//{
|
|||
|
// ObjectsTemplate<Employee> oAllEmployees = new ObjectsTemplate<Employee>();
|
|||
|
// ObjectsTemplate<EmployeeConfirmation> oEmpConfirms = GetByDateRange(GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate), GlobalFunctions.LastDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate));
|
|||
|
|
|||
|
// foreach (var confirm in oEmpConfirms)
|
|||
|
// {
|
|||
|
// Employee employee = employees.Where(obj => obj.ID == confirm.EmployeeID).SingleOrDefault();
|
|||
|
// if (employee != null) oAllEmployees.Add(employee);
|
|||
|
// }
|
|||
|
|
|||
|
// return oAllEmployees;
|
|||
|
//}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
base.SetAuditTrailProperties();
|
|||
|
return EmployeeConfirmation.Service.Save(this);
|
|||
|
}
|
|||
|
|
|||
|
public void Delete()
|
|||
|
{
|
|||
|
EmployeeConfirmation.Service.Delete(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region IEmployeeConfirmation Service
|
|||
|
|
|||
|
public interface IEmployeeConfirmationService
|
|||
|
{
|
|||
|
EmployeeConfirmation Get(ID nID);
|
|||
|
|
|||
|
EmployeeConfirmation GetByEmployeeID(ID nID);
|
|||
|
|
|||
|
ObjectsTemplate<EmployeeConfirmation> Get();
|
|||
|
|
|||
|
ID Save(EmployeeConfirmation employeeConfirmation);
|
|||
|
|
|||
|
void Delete(ID iD);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|