EchoTex_Payroll/HRM.BO/AllowDeduct/ADParameter.cs
2024-10-14 10:01:49 +06:00

748 lines
26 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace HRM.BO
{
#region ADParameter
public class ADParameter : AuditTrailBase
{
#region Constructor
public ADParameter()
{
AllowDeductID = 0;
IsForConfirmOnly = false;
FlatAmount = 0;
PercentOfBasic = 0;
PercentOfGross = 0;
MinAmount = 0;
MaxAmount = 0;
IsCurrentlyActive = false;
TaxablePercentage = 100;
IsTaxable = false;
IsTaxProjection = false;
IsDependsOnAttendance = false;
IsDependsOnOTHour = false;
IsWithException = false;
Periodicity = EnumPeriodicity.Monthly;
AllowOrDeductType = EnumAllowOrDeduct.Allowance;
Gender = EnumGender.None;
AllowanceDeduction = null;
ISDEPENDSONSPECIALHOUR = false;
EntitleType = EnumEntitleType.Grade;
NotApplicable = new List<ADParameterEmployee>();
Exception = new List<ADParameterEmployee>();
ADParameterEmployees = new List<ADParameterEmployee>();
}
#endregion
#region Internal Class
public class ADParameterGrade : AuditTrailBase
{
#region Constructor
public ADParameterGrade()
{
ADParameterID = 0;
GradeID = 0;
AllowDeductID = 0;
//Garde = null;
}
#endregion
#region Properties
public int ADParameterID { get; set; }
public int GradeID { get; set; }
public int AllowDeductID { get; set; }
//public Grade Garde { get; set; }
#endregion
}
#endregion
#region Internal Class ADParameterShift
public class ADParameterShift : AuditTrailBase
{
#region Constructor
public ADParameterShift()
{
ADParameterID = 0;
ShiftID = 0;
AllowDeductID = 0;
Shift = null;
}
#endregion
#region Properties
public int ADParameterID { get; set; }
public int ShiftID { get; set; }
public int AllowDeductID { get; set; }
public Shift Shift { get; set; }
#endregion
}
#endregion
#region Internal Class
public class ADParameterDesignation : AuditTrailBase
{
#region Constructor
public ADParameterDesignation()
{
ADParameterID = 0;
AllowDeductID = 0;
DesignationID = 0;
FlatAmount = 0;
PercentOfBasic = 0;
PercentOfGross = 0;
EffectMonth = PayrollGlobalFunctions.PayrollFirstDateOfMonth(DateTime.Today);
ArrearToCalculationMonth = PayrollGlobalFunctions.PayrollFirstDateOfMonth(DateTime.Today);
}
#endregion
#region Properties
public int ADParameterDesignationID { get; set; }
public int ADParameterID { get; set; }
public int AllowDeductID { get; set; }
public int AllowDeduct { get; set; }
public int DesignationID { get; set; }
public double FlatAmount { get; set; }
public double PercentOfBasic { get; set; }
public double PercentOfGross { get; set; }
public DateTime EffectMonth { get; set; }
public DateTime ArrearToCalculationMonth { get; set; }
#endregion
//#region employee : Employee
//private Designation _designation;
//public Designation Desingation
//{
// get
// {
// if (_designation == null)
// {
// _designation = new Designation();
// _designation = Designation.Get(_designationID);
// }
// return this._designation;
// }
// set
// {
// _designation = value;
// }
//}
//#endregion
//#region Service Factory IADParameterEmployeeService : IADParameterEmployeeService
//internal static IADParameterEmployeeService Service
//{
// get { return Services.Factory.CreateService<IADParameterEmployeeService>(typeof(IADParameterEmployeeService)); }
//}
//#endregion
#endregion
}
#endregion
#region Properties
public int AllowDeductID { get; set; }
public int PayrollTypeID { get; set; }
public bool IsForConfirmOnly { get; set; }
public bool IsFractionateApplicable { get; set; }
public double FlatAmount { get; set; }
public double PercentOfBasic { get; set; }
public double PercentOfEarnedBasic { get; set; }
public double PercentOfGross { get; set; }
public double GFFlatAmount { get; set; }
public double GFPercentOfBasic { get; set; }
public double GFPercentOfGross { get; set; }
public double MinAmount { get; set; }
public double MaxAmount { get; set; }
public bool IsCurrentlyActive { get; set; }
public double TaxablePercentage { get; set; }
public bool IsTaxable { get; set; }
public bool IsFlatAmount { get; set; }
public bool IsTaxProjection { get; set; }
public bool IsDependsOnAttendance { get; set; }
public bool ISDEPENDSONSPECIALHOUR { get; set; }
public bool IsDependsOnOTHour { get; set; }
public bool IsWithException { get; set; }
public EnumPeriodicity Periodicity { get; set; }
public EnumEntitleType EntitleType { get; set; }
public EnumAllowOrDeduct AllowOrDeductType { get; set; }
public EnumGender Gender { get; set; }
public AllowanceDeduction AllowanceDeduction { get; set; }
public List<ADParameterEmployee> Exception { get; set; }
public List<ADParameterEmployee> NotApplicable { get; set; }
public List<ADParameter.ADParameterGrade> ADParameterGrades { get; set; }
public List<ADParameter.ADParameterDesignation> ADParameterDesignations { get; set; }
public List<EmpChangeDesignation> DesignationChanges { get; set; }
public List<ADParameterEmployee> ADParameterEmployees { get; set; }
public List<ADParameter.ADParameterShift> ADParameterShifts { get; set; }
//private List<empchangedesignation> _designationchanges = null;
//public List<empchangedesignation> designationchanges
//{
// get
// {
// if (_designationchanges == null) _designationchanges = new objectstemplate<empchangedesignation>();
// return _designationchanges;
// }
// set
// {
// _designationchanges = value;
// }
//}
//#region allowanceDeduction : AllowanceDeduction
//private AllowanceDeduction _allowanceDeduction;
//public AllowanceDeduction AllowanceDeduction
//{
// get
// {
// if (_allowDeductID.Integer > 0 && _allowanceDeduction == null)
// {
// _allowanceDeduction = new AllowanceDeduction();
// _allowanceDeduction = AllowanceDeduction.Get(_allowDeductID);
// }
// return this._allowanceDeduction;
// }
// set
// {
// _allowanceDeduction = value;
// }
//}
//#endregion
//#region ADParamEmployee : ADParameterEmployee
//private List<ADParameterEmployee> _ADParameterEmployee = null;
//public List<ADParameterEmployee> ADParameterEmployees
//{
// get
// {
// if (_ADParameterEmployee == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _ADParameterEmployee = ADParameterEmployee.GetbyParameter(this.ID);
// }
// return this._ADParameterEmployee;
// }
// set
// {
// _ADParameterEmployee = value;
// }
//}
//#endregion
//#region Exception : ADParameterEmployee
//private List<ADParameterEmployee> _Exception = null;
//public List<ADParameterEmployee> Exception
//{
// get
// {
// if (_Exception == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _Exception = ADParameterEmployee.GetbyParameter(this.ID,EnumADEmpType.Exception);
// }
// return this._Exception;
// }
// set
// {
// this._Exception = value;
// }
//}
//#endregion
//#region NotApplicable : ADParameterEmployee
//private List<ADParameterEmployee> _NotApplicable = null;
//public List<ADParameterEmployee> NotApplicable
//{
// get
// {
// if (_NotApplicable == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _NotApplicable = ADParameterEmployee.GetbyParameter(this.ID, EnumADEmpType.NotApplicable);
// }
// return this._NotApplicable;
// }
// set
// {
// this._NotApplicable = value;
// }
//}
//#endregion
//#region ADParamGrade : ADParameterGrade
//private List<ADParameter.ADParameterGrade> _ADParameterGrades = null;
//public List<ADParameter.ADParameterGrade> ADParameterGrades
//{
// get
// {
// if (_ADParameterGrades == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _ADParameterGrades = ADParameter.GetGrades(this.ID);
// }
// return this._ADParameterGrades;
// }
// set
// {
// _ADParameterGrades = value;
// }
//}
//#endregion
//#region ADParamGrade : ADParameterGrade
//private List<ADParameter.ADParameterDesignation> _ADParameterDesignations = null;
//public List<ADParameter.ADParameterDesignation> ADParameterDesignations
//{
// get
// {
// if (_ADParameterDesignations == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _ADParameterDesignations = ADParameter.GetDesignations(this.ID);
// }
// return this._ADParameterDesignations;
// }
// set
// {
// _ADParameterDesignations = value;
// }
//}
//#endregion
//#region ADParamGrade : ADParameterGrade
//private List<EmpChangeDesignation> _designationchanges = null;
//public List<EmpChangeDesignation> DesignationChanges
//{
// get
// {
// if (_designationchanges == null) _designationchanges = new List<EmpChangeDesignation>();
// return _designationchanges;
// }
// set
// {
// _designationchanges = value;
// }
//}
//#endregion
//#region Service Factory IADParameterService : IADParameterService
//internal static IADParameterService Service
//{
// get { return Services.Factory.CreateService<IADParameterService>(typeof(IADParameterService)); }
//}
//#endregion
#endregion
// #region Functions
// public static ADParameter Get(ID nID)
// {
// ADParameter oADParameter = null;
// #region Cache Header
// oADParameter = (ADParameter)_cache["Get", nID];
// if (oADParameter != null)
// return oADParameter;
// #endregion
// oADParameter = ADParameter.Service.Get(nID,SystemInformation .CurrentSysInfo .PayrollTypeID.Integer);
// #region Cache Footer
// _cache.Add(oADParameter, "Get", nID);
// #endregion
// return oADParameter;
// }
// public static List<ADParameter> GetApplicableParameters(Employee employee, ID graId, List<ADParameter> parameters)
// {
// List<ADParameter> applicableParams = parameters.FindAll(delegate(ADParameter param) { return IsApplicable(param, graId, employee) ;});
// return applicab leParams;
// }mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm,,,,,,,,,,,,,,,,,,,,,,,,,,,,,kkkkkkkkkkkkkkkkkkkkkkkkk]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]yg-4e nnnnn 330o
// //public static ADParameter GetApplicableParameter(Employee employee,
// // ID graId, List<ADParameter> parameters)
// //{
// // foreach (ADParameter item in parameters)
// // {
// // if (IsApplicable(item, graId, employee) == true)
// // return item;
// // }
// // return null;
// //}
// public static ADParameter GetApplicableParameter(Employee employee, ID graId, List<ADParameter> parameters, ID allowdeductID)
// {
// foreach (ADParameter item in parameters)
// {
// if (item.AllowDeductID == allowdeductID)
// {
// if (IsApplicable(item, graId, employee) == true)
// return item;
// }
// }
// return null;
// }
// private static bool IsApplicable(ADParameter param, ID graid, Employee employee)
// {
// bool isApplicable = false;
// foreach (ADParameterGrade adgrade in param.ADParameterGrades)
// {
// if (adgrade.GradeID.Integer == graid.Integer)
// {
// isApplicable = true;
// }
// }
// if (!isApplicable) return false;
// if (param.Gender != EnumGender.None
// && param.Gender != employee.Gender)
// {
// return false;
// }
// if (param.IsForConfirmOnly && !employee.IsConfirmed)
// {
// return false;
// }
// return true;
// }
public double CalculateAmount(Employee oEmp)
{
double amount = 0;
if (this.PercentOfBasic > 0)
{
amount = this.FlatAmount + (this.PercentOfBasic * oEmp.BasicSalary) / 100;
}
else if (this.PercentOfGross > 0)
{
amount = this.FlatAmount + (this.PercentOfGross * oEmp.GrossSalary) / 100;
}
else
{
amount = this.FlatAmount;
}
return amount;
}
// public static List<ADParameter> Get(EnumStatus status)
// {
// #region Cache Header
// List<ADParameter> aDParameters = _cache["Get"] as List<ADParameter>;
// if (aDParameters != null)
// return aDParameters;
// #endregion
// try
// {
// aDParameters = Service.Get(status,SystemInformation .CurrentSysInfo.PayrollTypeID .Integer );
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameters, "Get",status);
// #endregion
// return aDParameters;
// }
// public static List<ADParameter> Get(EnumStatus status, EnumAllowOrDeduct type)
// {
// #region Cache Header
// List<ADParameter> aDParameters = _cache["Get", type] as List<ADParameter>;
// if (aDParameters != null)
// return aDParameters;
// #endregion
// try
// {
// aDParameters = Service.Get(status, type, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameters, "Get", status, type);
// #endregion
// return aDParameters;
// }
// public static List<ADParameter> GetDistinct(EnumStatus status, EnumAllowOrDeduct type)
// {
// #region Cache Header
// List<ADParameter> aDParameters = _cache["Get", type] as List<ADParameter>;
// if (aDParameters != null)
// return aDParameters;
// #endregion
// try
// {
// aDParameters = Service.Get(status, type, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameters, "Get", status, type);
// #endregion
// return aDParameters;
// }
// public static List<ADParameter> Get(EnumStatus status, ID nAllowDeducID)
// {
// #region Cache Header
// List<ADParameter> aDParameters = _cache["Get", nAllowDeducID] as List<ADParameter>;
// if (aDParameters != null)
// return aDParameters;
// #endregion
// try
// {
// aDParameters = Service.Get(status, nAllowDeducID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameters, "Get", status, nAllowDeducID);
// #endregion
// return aDParameters;
// }
// public static List<ADParameter> Get(ID gradeID, EnumEntitleType nADEmpType, EnumAllowOrDeduct nType)
// {
// #region Cache Header
// List<ADParameter> aDParameters = _cache["Get", gradeID, nADEmpType, nType] as List<ADParameter>;
// if (aDParameters != null)
// return aDParameters;
// #endregion
// try
// {
// aDParameters = Service.Get(gradeID, nADEmpType, nType,SystemInformation.CurrentSysInfo.PayrollTypeID .Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameters, "Get", gradeID, nADEmpType, nType);
// #endregion
// return aDParameters;
// }
// public static List<ADParameter.ADParameterGrade> GetGrades(ID adID)
// {
// #region Cache Header
// List<ADParameter.ADParameterGrade> aDParameterGrades = _cache["Get", adID] as List<ADParameter.ADParameterGrade>;
// if (aDParameterGrades != null)
// return aDParameterGrades;
// #endregion
// try
// {
// aDParameterGrades = Service.GetGrades(adID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameterGrades, "Get", adID);
// #endregion
// return aDParameterGrades;
// }
// public static List<ADParameter.ADParameterDesignation> GetDesignations(ID adID)
// {
// #region Cache Header
// List<ADParameter.ADParameterDesignation> aDParameterGrades = _cache["Get", adID] as List<ADParameter.ADParameterDesignation>;
// if (aDParameterGrades != null)
// return aDParameterGrades;
// #endregion
// try
// {
// aDParameterGrades = Service.GetDesignaitons(adID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(aDParameterGrades, "Get", adID);
// #endregion
// return aDParameterGrades;
// }
// public ID Save()
// {
// base.SetAuditTrailProperties();
// return ADParameter.Service.Save(this);
// }
// public void Delete()
// {
// ADParameter.Service.Delete(ID);
// }
// public void ChangeStatus(EnumStatus enumStatus)
// {
// ADParameter.Service.ChangeStatus(this.ID,enumStatus);
// }
// private List<ADParameter> GetParametes(Employee employee,
// ID gradeId, List<ADParameter> allparameters)
// {
// List<ADParameter> parameters = new List<ADParameter>();
// return parameters;
// }
// public static void ApplicableParameters(Employee emlpoyee,
// SalaryMonthly salary, List<ADParameter> allAdparameters)
// {
// foreach (EmployeeGradeSalary gs in salary.GradeSalaries)
// {
// List<ADParameter> lparameter = ADParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allAdparameters);
// gs.ADParameters = new List<ADParameter>();
// foreach (ADParameter item in lparameter)
// gs.ADParameters.Add(item);
// }
// foreach (EmployeeGradeSalary gs in salary.ArrearGradeSalaries)
// {
// List<ADParameter> alparameter = ADParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allAdparameters);
// gs.ADParameters = new List<ADParameter>();
// foreach (ADParameter item in alparameter)
// gs.ADParameters.Add(item);
// }
// foreach (EmployeeGradeSalary gs in salary.ArrearPaidGradeSalaries)
// {
// List<ADParameter> aplparameter = ADParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allAdparameters);
// gs.ADParameters = new List<ADParameter>();
// foreach (ADParameter item in aplparameter)
// gs.ADParameters.Add(item);
// }
// }
//#endregion
}
#region IADParameter Service
public interface IADParameterService
{
ADParameter Get(int id, int payrollTypeID);
List<ADParameter> Get(int? gradeID, EnumEntitleType nADEmpType, EnumAllowOrDeduct nType, int payrolltypeid);
List<ADParameter.ADParameterGrade> GetGrades(int adparameterid);
List<ADParameter.ADParameterGrade> GetUsedGrades(int allowancedeductid);
List<ADParameter.ADParameterDesignation> GetDesignaitons(int adID);
List<ADParameter> GetWithPayrollType(EnumStatus status, int payrollTypeID);
List<ADParameter> Get(EnumStatus status, EnumAllowOrDeduct nType, int parollTypeID);
List<ADParameter> GetDistinct(EnumStatus status, EnumAllowOrDeduct type, int payrollTypeID);
int Save(ADParameter item);
void Delete(int id);
void ChangeStatus(int id, EnumStatus enumStatus);
List<ADParameter> Get(int gradeID, EnumEntitleType nADEmpType, EnumAllowOrDeduct nType, int payrollTypeID);
List<ADParameter> GetWithDetail(EnumStatus status, int payrollTypeID);
double GetGradeDefinedAmount(Employee employee, double basicSalary, double grossSalary, EmployeeGradeSalary oEmpGradeSalary, ADParameter param);
}
#endregion
}