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

396 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
using Ease.Core.Model;
using System.Data;
namespace HRM.BO
{
#region TermParameter
public class TermParameter : AuditTrailBase
{
#region Constructor
public TermParameter()
{
//_termID = ID.FromInteger(0);
//_effectDate = DateTime.MinValue;
//_amount = 0;
//_type = EnumOverTimeType.NONE;
//_term = null;
//_TermEntityGrades = null;
//_payrollTypeID = 0;
this.housInMonth = 173;
}
#endregion
#region Internal Class
public class TermEntityGrade : AuditTrailBase
{
#region Constructor
public TermEntityGrade()
{
//_termEntityID = ID.FromInteger(0);
//_gradeID = ID.FromInteger(0);
//_grade = null;
}
#endregion
#region Properties
public int TermEntityID { get; set; }
public int GradeID { get; set; }
//public Grade Grade { get; set; }
//#region Grade: Grade
//private Grade _grade;
//public Grade Grade
//{
// get
// {
// if (_gradeID.Integer > 0 && _grade == null)
// {
// _grade = new Grade();
// _grade = Grade.Get(_gradeID);
// }
// return this._grade;
// }
// set
// {
// _grade = value;
// }
//}
//#endregion
#endregion
}
#endregion
#region Properties
public int TermID { get; set; }
public DateTime EffectDate { get; set; }
public double Amount { get; set; }
public EnumOverTimeType Type { get; set; }
public static string EntryType { get; set; }
public int PayrollTypeID { get; set; }
public Term Term { get; set; }
public int housInMonth { get; set; }
public List<SetupDetail> SetupDetails { get; set; }
//#region Term: Term
//private Term _term;
//public Term Term
//{
// get
// {
// if (_termID.Integer > 0 && _term == null)
// {
// _term = new Term();
// _term = Term.Get(_termID);
// }
// return this._term;
// }
// set
// {
// _term = value;
// }
//}
//#endregion
public List<TermParameter.TermEntityGrade> TermEntityGrades { get; set; }
//#region TermEntityGrade : TermEntityGrade
//private List<TermParameter.TermEntityGrade> _TermEntityGrades = null;
//public List<TermParameter.TermEntityGrade> TermEntityGrades
//{
// get
// {
// if (_TermEntityGrades == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _TermEntityGrades = TermParameter.GetGrades(this.ID);
// }
// return this._TermEntityGrades;
// }
// set
// {
// _TermEntityGrades = value;
// }
//}
//#endregion
//#region Service Factory ITermParameterService : ITermParameterService
//internal static ITermParameterService Service
//{
// get { return Services.Factory.CreateService<ITermParameterService>(typeof(ITermParameterService)); }
//}
//#endregion
#endregion
//#region Functions
//public double GetPayableAmount(EmployeeOverTime ot,double nBasic)
//{
// double nHour = ot.OTHours;
// switch (TermParameter.EntryType.ToUpper())
// {
// case "MINUTE":
// nHour = Math.Floor(ot.OTHours);
// nHour += (ot.OTHours - nHour) * 100 / 60;
// break;
// }
// switch (this.Type)
// {
// case EnumOverTimeType.AnyAmount:
// return ot.OTHours;
// case EnumOverTimeType.DailyBasicPercent:
// return (this.ConvertToDailyRate(nBasic, ot.OTMonth) * ot.OTHours * ot.Value / 100);
// case EnumOverTimeType.DailyFlatAmount:
// return ot.OTHours;
// case EnumOverTimeType.FixedAmount:
// return ot.OTHours;
// case EnumOverTimeType.HourlyBasicPercent:
// return this.ConvertToHourlyRate(nBasic, ot.OTMonth) * ot.OTHours * ot.Value / 100;
// case EnumOverTimeType.HourlyFlatAmount:
// return ot.OTHours * this.Amount;
// case EnumOverTimeType.HoursOfMonth:
// break;
// case EnumOverTimeType.Slab:
// List<OTSlab> slabs= OTSlab.GetByTermID(ot.TermID);
// double amount = 0;
// if (slabs != null)
// {
// for (int i = 1; i < slabs.Count; i++)
// {
// amount = slabs[i].Amount;
// if (slabs[i].Hours > Math.Round(ot.OTHours,0))
// {
// amount = slabs[i-1].Amount;
// break;
// }
// }
// }
// return amount;
// }
// return 0;
//}
//public static TermParameter Get(ID nID)
//{
// TermParameter oTermParameter = null;
// #region Cache Header
// oTermParameter = (TermParameter)_cache["Get", nID];
// if (oTermParameter != null)
// return oTermParameter;
// #endregion
// oTermParameter = TermParameter.Service.Get(nID);
// #region Cache Footer
// _cache.Add(oTermParameter, "Get", nID);
// #endregion
// return oTermParameter;
//}
//public static List<TermParameter.TermEntityGrade> GetGrades(ID tpID)
//{
// #region Cache Header
// List<TermParameter.TermEntityGrade> termEntityGrades = _cache["Get", tpID] as List<TermParameter.TermEntityGrade>;
// if (termEntityGrades != null)
// return termEntityGrades;
// #endregion
// try
// {
// termEntityGrades = Service.GetGrades(tpID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(termEntityGrades, "Get", tpID);
// #endregion
// return termEntityGrades;
//}
//public static List<TermParameter> Get()
//{
// #region Cache Header
// List<TermParameter> termParams = _cache["Get"] as List<TermParameter>;
// if (termParams != null)
// return termParams;
// #endregion
// try
// {
// termParams = Service.Get(SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(termParams, "Get");
// #endregion
// return termParams;
//}
//public static List<TermParameter> GetByGradeID(ID nGradeID)
//{
// #region Cache Header
// List<TermParameter> termParams = _cache["Get",nGradeID] as List<TermParameter>;
// if (termParams != null)
// return termParams;
// #endregion
// try
// {
// termParams = Service.GetByGradeID(nGradeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(termParams, "Get",nGradeID);
// #endregion
// return termParams;
//}
//public ID Save()
//{
// this.SetAuditTrailProperties();
// return TermParameter.Service.Save(this);
//}
//public void Delete()
//{
// TermParameter.Service.Delete(ID);
//}
///// <summary>
/////
///// </summary>
///// <param name="parameters"> All paramters of current payroll type</param>
///// <param name="employee"> employee</param>
///// <param name="TermID"> Term/OT basic IS</param>
///// <returns></returns>
public static TermParameter GetParameter(List<TermParameter> parameters, int gradeid, int TermID)
{
List<TermParameter> selectedTerms = parameters.FindAll(x => x.TermID == TermID);
if (selectedTerms == null) return null;
foreach (TermParameter item in selectedTerms)
{
var ei = item.TermEntityGrades.FirstOrDefault(x => x.GradeID == gradeid);
if (ei != null) return item;
}
return null;
}
public static List<TermParameter> ApplicableParameters(List<TermParameter> parameters, int gradeid )
{
List<TermParameter> selectedTerms = new List<TermParameter>();
foreach (TermParameter item in parameters)
{
var ei = item.TermEntityGrades.FirstOrDefault(x => x.GradeID == gradeid);
if (ei != null) selectedTerms.Add(item);
}
return selectedTerms;
}
//public static List<TermParameter> Get(bool IncludeChildren)
//{
// List<TermParameter> termParams = new List<TermParameter>();
// try
// {
// termParams = Service.Get(IncludeChildren);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return termParams;
//}
//public void FillMe(ID id)
//{
// TermParameter tpm = TermParameter.Get(id);
// this.TermID = tpm.TermID;
// this.EffectDate = tpm.EffectDate;
// this.Amount = tpm.Amount;
// this.Type = tpm.Type;
// this.CreatedBy = tpm.CreatedBy;
// this.CreatedDate = tpm.CreatedDate;
// this.ModifiedBy = tpm.ModifiedBy;
// this.ModifiedDate = tpm.ModifiedDate;
// this.SetID(tpm.ID);
// this.SetState(ObjectState.Saved);
//}
//#endregion
}
#region ITermParameter Service
public interface ITermParameterService
{
List<TermParameter> Get(bool IncludeChildren, int payrolltypeId);
TermParameter Get(int id);
List<TermParameter> GetByPayrollTypeID(int payrollTypeID);
List<TermParameter> GetByGradeID(int nGradeID);
List<TermParameter.TermEntityGrade> GetGrades(int ntpID);
int Save(TermParameter item);
void Delete(int id);
List<TermParameter.TermEntityGrade> GetUsedGrades(int termID);
}
#endregion
}
#endregion