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 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 TermEntityGrades { get; set; } //#region TermEntityGrade : TermEntityGrade //private List _TermEntityGrades = null; //public List 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(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 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 GetGrades(ID tpID) //{ // #region Cache Header // List termEntityGrades = _cache["Get", tpID] as List; // 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 Get() //{ // #region Cache Header // List termParams = _cache["Get"] as List; // 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 GetByGradeID(ID nGradeID) //{ // #region Cache Header // List termParams = _cache["Get",nGradeID] as List; // 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); //} ///// ///// ///// ///// All paramters of current payroll type ///// employee ///// Term/OT basic IS ///// public static TermParameter GetParameter(List parameters, int gradeid, int TermID) { List 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 ApplicableParameters(List parameters, int gradeid ) { List selectedTerms = new List(); 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 Get(bool IncludeChildren) //{ // List termParams = new List(); // 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 Get(bool IncludeChildren, int payrolltypeId); TermParameter Get(int id); List GetByPayrollTypeID(int payrollTypeID); List GetByGradeID(int nGradeID); List GetGrades(int ntpID); int Save(TermParameter item); void Delete(int id); List GetUsedGrades(int termID); } #endregion } #endregion