EchoTex_Payroll/HRM.BO/Gratuity/ESBDefinition.cs

618 lines
19 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace HRM.BO
{
#region ESBDefinition
public class ESBDefinition : BasicBaseObject
{
#region Constructor
public ESBDefinition()
{
Description = string.Empty;
MaxServiceLength = 0.0;
PayrollTypeID = 0;
Trading = 0.0;
UserID = 0;
}
#endregion
#region Properties
public string Description { get; set; }
public int PayrollTypeID { get; set; }
public double MaxServiceLength { get; set; }
public double Trading { get; set; }
public int UserID { get; set; }
public List<ESBSlab> ESBSlabs { get; set; } = new List<ESBSlab>();
//#region ESBSlabs : List<ESBSlab>
//private List<ESBSlab> _esbSlabs;
//public List<ESBSlab> ESBSlabs
//{
// get
// {
// if (_esbSlabs == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _esbSlabs = ESBSlab.GetSlabs(this.ID.Integer);
// }
// if (_esbSlabs == null)
// {
// _esbSlabs = new List<ESBSlab>();
// }
// return _esbSlabs;
// }
// set
// {
// _esbSlabs = value;
// }
//}
//#endregion
public List<ESBGrade> ESBGrades { get; set; } = new List<ESBGrade>();
//#region ESBGrades : List<ESBGrade>
//private List<ESBGrade> _esbGrades;
//public List<ESBGrade> ESBGrades
//{
// get
// {
// if (_esbGrades == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _esbGrades = ESBGrade.GetESBGrade(this.ID.Integer);
// }
// if (_esbGrades == null)
// {
// _esbGrades = new List<ESBGrade>();
// }
// return _esbGrades;
// }
// set
// {
// _esbGrades = value;
// }
//}
//#endregion
public List<ESBElement> ESBElements { get; set; } = new List<ESBElement>();
//#region ESBElements : List<ESBElement>
//private List<ESBElement> _esbElements;
//public List<ESBElement> ESBElements
//{
// get
// {
// if (_esbElements == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _esbElements = ESBElement.GetESBElement(this.ID.Integer);
// }
// if (_esbElements == null)
// {
// _esbElements = new List<ESBElement>();
// }
// return _esbElements;
// }
// set
// {
// _esbElements = value;
// }
//}
//#endregion
//#region Service Factory IESBDefinitionService : IESBDefinitionService
//internal static IESBDefinitionService Service
//{
// get { return Services.Factory.CreateService<IESBDefinitionService>(typeof(IESBDefinitionService)); }
//}
//#endregion
#endregion
//#region Functions
//public static ESBDefinition Get(ID nID)
//{
// ESBDefinition oESBDefinition = null;
// #region Cache Header
// oESBDefinition = (ESBDefinition)_cache["Get", nID];
// if (oESBDefinition != null)
// return oESBDefinition;
// #endregion
// oESBDefinition = ESBDefinition.Service.Get(nID);
// #region Cache Footer
// _cache.Add(oESBDefinition, "Get", nID);
// #endregion
// return oESBDefinition;
//}
//public static ESBDefinition GetByPayrollID(int nID)
//{
// ESBDefinition oESBDefinition = null;
// #region Cache Header
// oESBDefinition = (ESBDefinition)_cache["GetByPayrollID", nID];
// if (oESBDefinition != null)
// return oESBDefinition;
// #endregion
// oESBDefinition = ESBDefinition.Service.GetByPayrollID(nID);
// #region Cache Footer
// _cache.Add(oESBDefinition, "GetByPayrollID", nID);
// #endregion
// return oESBDefinition;
//}
//public static ESBDefinition Get(int nID)
//{
// ESBDefinition oESBDefinition = null;
// #region Cache Header
// oESBDefinition = (ESBDefinition)_cache["Get", nID];
// if (oESBDefinition != null)
// return oESBDefinition;
// #endregion
// oESBDefinition = ESBDefinition.Service.Get(nID);
// #region Cache Footer
// _cache.Add(oESBDefinition, "Get", nID);
// #endregion
// return oESBDefinition;
//}
//public static ESBDefinition Get(List<ESBDefinition> definations, Employee employee)
//{
// ESBDefinition odefinaiton = null;
// ESBGrade oESBGrade = null;
// odefinaiton = definations.Where(x => x.PayrollTypeID == employee.PayrollTypeID).SingleOrDefault();
// if (odefinaiton != null)
// oESBGrade = odefinaiton.ESBGrades.Where(t => t.GradeID == employee.GradeID).SingleOrDefault();
// return odefinaiton;
//}
//public static List<ESBDefinition> Get()
//{
// #region Cache Header
// List<ESBDefinition> oESBDefinition = _cache["Get"] as List<ESBDefinition>;
// if (oESBDefinition != null)
// return oESBDefinition;
// #endregion
// try
// {
// oESBDefinition = Service.Get();
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oESBDefinition, "Get");
// #endregion
// return oESBDefinition;
//}
//public static List<ESBDefinition> GetByPayrollType(int nPayrollTypeID)
//{
// #region Cache Header
// List<ESBDefinition> oESBDefinition = _cache["GetByPayrollType", nPayrollTypeID] as List<ESBDefinition>;
// if (oESBDefinition != null)
// return oESBDefinition;
// #endregion
// try
// {
// oESBDefinition = Service.GetByPayrollType(nPayrollTypeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oESBDefinition, "GetByPayrollType", nPayrollTypeID);
// #endregion
// return oESBDefinition;
//}
//public void CalculateProvisionAmount(Employee oEmployee, List<SalaryMonthlyDetail> oSalaryMonthlyDetails, ESBProvision oESBProvision, DataSet oDS)
//{
// EnumSalaryItemCode nItemCode = EnumSalaryItemCode.Basic_Salary;
// double nESBAmount = 0.0;
// double nProvisioned = 0.0;
// double nToBeProvisioned = 0.0;
// double nServiceLength = 0.0;
// double nNoOfEntitlement = 0.0;
// double nNoRestofMonth = 0;
// double nAvgAmount = 0.0;
// SalaryMonthlyDetail oSalaryMonthlyDetail = null;
// foreach (ESBElement oElement in this.ESBElements)
// {
// if (oElement.ElementID == ID.FromInteger((int)EnumSalaryItemCode.Basic_Salary))
// nItemCode = EnumSalaryItemCode.Basic_Salary;
// else
// nItemCode = EnumSalaryItemCode.Allowance;
// oSalaryMonthlyDetail = new SalaryMonthlyDetail();
// oSalaryMonthlyDetail = oSalaryMonthlyDetails.Find(delegate (SalaryMonthlyDetail t) { return t.ItemCode == nItemCode && t.ItemID == oElement.ElementID.Integer && t.itemGroupCode == EnumSalaryGroup.Gross; });
// if (oSalaryMonthlyDetail != null)
// {
// nESBAmount = nESBAmount + oSalaryMonthlyDetail.ChangedAmount;
// nAvgAmount = nAvgAmount + oSalaryMonthlyDetail.ChangedAmount;
// }
// }
// nServiceLength = oEmployee.ServiceYears(Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfYear(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate));
// nNoRestofMonth = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m", Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate, Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfYear(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate)) + 1;
// nProvisioned = 0.0;
// //foreach(DataRow oRow in oDS.Tables[0].Rows)
// //{
// // if (oEmployee.ID.Integer == Convert.ToInt16(oRow[0].ToString()))
// // {
// // nProvisioned = Convert.ToDouble(oRow[1].ToString());
// // break;
// // }
// //}
// if (nServiceLength > MaxServiceLength)
// nServiceLength = MaxServiceLength;
// nNoOfEntitlement = ESBSlab.GetCalcualateNo(nServiceLength, oEmployee.PayrollTypeID.Integer);
// if (nNoOfEntitlement <= 0.0)
// nNoOfEntitlement = 1;
// nToBeProvisioned = (nESBAmount) * nServiceLength * nNoOfEntitlement;
// oESBProvision.Provision = Math.Round((nToBeProvisioned - nProvisioned) / nNoRestofMonth);
// oESBProvision.Provision = PayrollPayrollGlobalFunctions.Round(oESBProvision.Provision);
//}
//public ID Save()
//{
// this.SetAuditTrailProperties();
// return ESBDefinition.Service.Save(this);
//}
//public void Delete(ID id)
//{
// ESBDefinition.Service.Delete(id);
//}
//#endregion
}
#endregion
//#region IESBDefinition Service
//public interface IESBDefinitionService
//{
// ESBDefinition Get(ID id);
// ESBDefinition GetByPayrollID(int nID);
// ESBDefinition Get(int nID);
// List<ESBDefinition> Get();
// List<ESBDefinition> GetByPayrollType(int nPayrollTypeID);
// ID Save(ESBDefinition item);
// void Delete(ID id);
// //
// List<ESBElement> GetESBElement(int nESBID);
// ID SaveESBElement(ESBElement item);
// void DeleteESBElement(ID id);
// //
// List<ESBGrade> GetESBGrade(int nESBID);
// ID SaveESBGrade(ESBGrade item);
// void DeleteESBGrade(ID id);
// //
// List<ESBSlab> GetSlabs(int nESBID);
// ID SaveESBSlab(ESBSlab item);
// void DeleteESBSlab(ID id);
//}
//#endregion
#region ESBElement
public class ESBElement : BasicBaseObject
{
#region Constructor
public ESBElement()
{
ElementType = EnumSalaryComponent.Basic;
ESBID = 0;
ElementID = 0;
}
#endregion
#region Properties
public int ESBID { get; set; }
public int ElementID { get; set; }
public EnumSalaryComponent ElementType { get; set; }
#endregion
//#region Service Factory IESBDefinitionService : IESBDefinitionService
//internal static IESBDefinitionService Service
//{
// get { return Services.Factory.CreateService<IESBDefinitionService>(typeof(IESBDefinitionService)); }
//}
//#endregion
//#region Functions
//public static List<ESBElement> GetESBElement(int nESBID)
//{
// #region Cache Header
// List<ESBElement> oESBElements = _cache["Get", nESBID] as List<ESBElement>;
// if (oESBElements != null)
// return oESBElements;
// #endregion
// try
// {
// oESBElements = Service.GetESBElement(nESBID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oESBElements, "Get", nESBID);
// #endregion
// return oESBElements;
//}
//public ID SaveESBElement()
//{
// return ESBDefinition.Service.SaveESBElement(this);
//}
//public void DeleteESBElement(ID id)
//{
// ESBDefinition.Service.DeleteESBElement(id);
//}
//#endregion
}
#endregion
#region ESBGrade
public class ESBGrade : BasicBaseObject
{
#region Constructor
public ESBGrade()
{
GradeID = 0;
ESBID = 0;
}
#endregion
#region Properties
public int GradeID { get; set; }
public int ESBID { get; set; }
//public Grade Grade { get; set; }
//#region grade : Grade
//private Grade _grade;
//public Grade Grade
//{
// get
// {
// if (_gradeID != null)
// {
// if (_gradeID.Integer > 0 && _grade == null)
// {
// _grade = new Grade();
// _grade = Grade.Get(_gradeID);
// }
// }
// return this._grade;
// }
// set
// {
// _grade = value;
// }
//}
//#endregion
//public static List<ESBGrade> GetESBGrade(int nESBID)
//{
// #region Cache Header
// List<ESBGrade> oESBGrade = _cache["GetESBGrade", nESBID] as List<ESBGrade>;
// if (oESBGrade != null)
// return oESBGrade;
// #endregion
// try
// {
// oESBGrade = Service.GetESBGrade(nESBID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return oESBGrade;
//}
//#region Service Factory IESBDefinitionService : IESBDefinitionService
//internal static IESBDefinitionService Service
//{
// get { return Services.Factory.CreateService<IESBDefinitionService>(typeof(IESBDefinitionService)); }
//}
//#endregion
#endregion
//#region Functions
//public ID Save()
//{
// //this.SetAuditTrailProperties();
// return ESBDefinition.Service.SaveESBGrade(this);
//}
//public void Delete(ID id)
//{
// ESBDefinition.Service.DeleteESBGrade(id);
//}
//#endregion
}
#endregion
#region ESBSlab
public class ESBSlab : BasicBaseObject
{
#region Constructor
public ESBSlab()
{
CalculateNo = 0.0;
DaysToConsider = 0.0;
ESBID = 0;
ServiceYear = 0.0;
UptoServiceYear = 0;
}
#endregion
#region Properties
public double CalculateNo { get; set; }
public double DaysToConsider { get; set; }
public int ESBID { get; set; }
public double ServiceYear { get; set; }
public ESBDefinition ESBDefinition { get; set; }
//#region _esbDefinition : Grade
//private ESBDefinition _esbDefinition;
//public ESBDefinition ESBDefinition
//{
// get
// {
// if (_esbID != null)
// {
// if (_esbID.Integer > 0 && _esbDefinition == null)
// {
// _esbDefinition = new ESBDefinition();
// _esbDefinition = ESBDefinition.Get(_esbID);
// }
// }
// return this._esbDefinition;
// }
// set
// {
// _esbDefinition = value;
// }
//}
//#endregion
public int UptoServiceYear { get; set; }
//#region Service Factory IESBDefinitionService : IESBDefinitionService
//internal static IESBDefinitionService Service
//{
// get { return Services.Factory.CreateService<IESBDefinitionService>(typeof(IESBDefinitionService)); }
//}
//#endregion
#endregion
//#region Functions
//public static List<ESBSlab> GetSlabs(int nESBID)
//{
// #region Cache Header
// List<ESBSlab> ESBSlab = _cache["GetSlabs", nESBID] as List<ESBSlab>;
// if (ESBSlab != null)
// return ESBSlab;
// #endregion
// try
// {
// ESBSlab = Service.GetSlabs(nESBID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(ESBSlab, "GetSlabs", nESBID);
// #endregion
// return ESBSlab;
//}
//public static double GetCalcualateNo(double nServiceYear, int nPID)
//{
// ESBDefinition oItem = new ESBDefinition();
// double n = 0.0;
// oItem = ESBDefinition.GetByPayrollID(nPID);
// List<ESBSlab> oSlabs = new List<ESBSlab>();
// oSlabs = ESBSlab.GetSlabs(oItem.ID.Integer);
// foreach (ESBSlab oSl in oSlabs)
// {
// if (oSl.ServiceYear <= nServiceYear)
// n = oSl.CalculateNo;
// }
// return n;
//}
//public static double GetCalcualateNo(double nServiceYear, ESBDefinition oESBDefinition)
//{
// ESBDefinition oItem = new ESBDefinition();
// double n = 0.0;
// oItem = ESBDefinition.Get(oESBDefinition.ID);
// foreach (ESBSlab oSl in oItem.ESBSlabs)
// {
// if (oSl.ServiceYear <= nServiceYear)
// n = oSl.CalculateNo;
// }
// return n;
//}
//public ID SaveESBSlab()
//{
// return ESBDefinition.Service.SaveESBSlab(this);
//}
//public void Delete(ID id)
//{
// ESBDefinition.Service.DeleteESBSlab(id);
//}
//#endregion
}
#endregion
}