1084 lines
36 KiB
C#
1084 lines
36 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using System.Data.Linq.Mapping;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region OpiParameter
|
|||
|
[Serializable]
|
|||
|
public class OpiParameter : BasicBaseObject
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
private static Cache _cache = new Cache(typeof(OpiParameter));
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
public OpiParameter()
|
|||
|
{
|
|||
|
_amountToDistribute = 0.0;
|
|||
|
_avgMonth = 0;
|
|||
|
_flatAmount = 0.0;
|
|||
|
_provisionAmount = 0.0;
|
|||
|
_fromDate = DateTime.Now;
|
|||
|
_toDate = DateTime.Now;
|
|||
|
_gender = EnumGender.None;
|
|||
|
_isActive = false;
|
|||
|
_isEarnedBasic = false;
|
|||
|
_isTaxable = false;
|
|||
|
_isConfirmed = false;
|
|||
|
_isWithException = false;
|
|||
|
_minAmount = 0.0;
|
|||
|
_maxAmount = 0.0;
|
|||
|
_isFractionate = false;
|
|||
|
_opiItemID = null;
|
|||
|
_opiParameterGrades = null;
|
|||
|
_opiParameterIndividuals = null;
|
|||
|
_opiPeriodicity = EnumOpiPeriodicity.OnceOff;
|
|||
|
_opiType = EnumOpiType.Provision;
|
|||
|
_percentOfBasic = 0.0;
|
|||
|
_percentOfGross = 0.0;
|
|||
|
_entitleType = EnumEntitleType.Grade;
|
|||
|
_opiAvgPayType = EnumOpiAvgPayType.NONE;
|
|||
|
_opiAvgPayItemID = null;
|
|||
|
_nNoOfMonth = 0;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region opiType : EnumOpiType
|
|||
|
private EnumOpiType _opiType;
|
|||
|
public EnumOpiType OpiType
|
|||
|
{
|
|||
|
get { return _opiType; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("opitype", (short)_opiType, (short)value);
|
|||
|
_opiType = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region AmountToDistribute : double
|
|||
|
private double _amountToDistribute;
|
|||
|
public double AmountToDistribute
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _amountToDistribute;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("amounttodistribute", _amountToDistribute, value);
|
|||
|
_amountToDistribute = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region AvgMonth : int
|
|||
|
private int _avgMonth;
|
|||
|
public int AvgMonth
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _avgMonth;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("avgmonth", _avgMonth, value);
|
|||
|
_avgMonth = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ProvisionAmount : double
|
|||
|
private double _provisionAmount;
|
|||
|
public double ProvisionAmount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _provisionAmount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("ProvisionAmount", _provisionAmount, value);
|
|||
|
_provisionAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region FlatAmount : double
|
|||
|
private double _flatAmount;
|
|||
|
public double FlatAmount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _flatAmount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("flatamount", _flatAmount, value);
|
|||
|
_flatAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region AnnualGrossBrand:Double
|
|||
|
|
|||
|
|
|||
|
private double _annualGrossPerBand;
|
|||
|
|
|||
|
public double AnnualGrossPerBand
|
|||
|
{
|
|||
|
get { return _annualGrossPerBand; }
|
|||
|
set {
|
|||
|
base.OnPropertyChange<double>("AnnualGrossPerBand", _annualGrossPerBand, value);
|
|||
|
_annualGrossPerBand = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region PerformanceAchievement:Double
|
|||
|
|
|||
|
|
|||
|
private double _performanceAchievement;
|
|||
|
|
|||
|
public double PerformanceAchievement
|
|||
|
{
|
|||
|
get { return _performanceAchievement; }
|
|||
|
set {
|
|||
|
base.OnPropertyChange<double>("PerformanceAchievement", _performanceAchievement, value);
|
|||
|
_performanceAchievement = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MinAmount : double
|
|||
|
private double _minAmount;
|
|||
|
public double MinAmount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _minAmount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("minamount", _minAmount, value);
|
|||
|
_minAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MaxAmount : double
|
|||
|
private double _maxAmount;
|
|||
|
public double MaxAmount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _maxAmount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("maxamount", _maxAmount, value);
|
|||
|
_maxAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region FromDate : DateTime
|
|||
|
private DateTime _fromDate;
|
|||
|
public DateTime FromDate
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _fromDate;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<DateTime>("fromdate", _fromDate, value);
|
|||
|
_fromDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ToDate : DateTime
|
|||
|
private DateTime? _toDate;
|
|||
|
public DateTime? ToDate
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _toDate;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<DateTime>("todate", _toDate, value);
|
|||
|
_toDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Gender : EnumGender
|
|||
|
private EnumGender _gender;
|
|||
|
public EnumGender Gender
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _gender;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("gender", (short)_gender, (short)value);
|
|||
|
_gender = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsActive : bool
|
|||
|
private bool _isActive;
|
|||
|
public bool IsActive
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isActive;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("isactive", _isActive, value);
|
|||
|
_isActive = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsEarnedBasic : bool
|
|||
|
private bool _isEarnedBasic;
|
|||
|
public bool IsEarnedBasic
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isEarnedBasic;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("isearnedbasic", _isEarnedBasic, value);
|
|||
|
_isEarnedBasic = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsTaxable : bool
|
|||
|
private bool _isTaxable;
|
|||
|
public bool IsTaxable
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isTaxable;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("istaxable", _isTaxable, value);
|
|||
|
_isTaxable = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsConfirmed : bool
|
|||
|
private bool _isConfirmed;
|
|||
|
public bool IsConfirmed
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isConfirmed;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("isconfirmed", _isConfirmed, value);
|
|||
|
_isConfirmed = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsFractionate : bool
|
|||
|
private bool _isFractionate;
|
|||
|
public bool IsFractionate
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isFractionate;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("isfractionate", _isFractionate, value);
|
|||
|
_isFractionate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region isWithException : bool
|
|||
|
|
|||
|
private bool _isWithException;
|
|||
|
public bool IsWithException
|
|||
|
{
|
|||
|
get { return _isWithException; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("isWithException", _isWithException, value);
|
|||
|
_isWithException = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiItemID : ID
|
|||
|
private ID _opiItemID;
|
|||
|
public ID OpiItemID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _opiItemID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("opiitemid", _opiItemID, value);
|
|||
|
_opiItemID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiPeriodicity : EnumOpiPeriodicity
|
|||
|
private EnumOpiPeriodicity _opiPeriodicity;
|
|||
|
public EnumOpiPeriodicity OpiPeriodicity
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _opiPeriodicity;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("opiperiodicity", (short)_opiPeriodicity, (short)value);
|
|||
|
_opiPeriodicity = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region PercentOfBasic : double
|
|||
|
private double _percentOfBasic;
|
|||
|
public double PercentOfBasic
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _percentOfBasic;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("percentofbasic", _percentOfBasic, value);
|
|||
|
_percentOfBasic = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region PercentOfGross : double
|
|||
|
private double _percentOfGross;
|
|||
|
public double PercentOfGross
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _percentOfGross;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("percentofgross", _percentOfGross, value);
|
|||
|
_percentOfGross = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region entitleType : EntitleType
|
|||
|
|
|||
|
private EnumEntitleType _entitleType;
|
|||
|
public EnumEntitleType EntitleType
|
|||
|
{
|
|||
|
get { return _entitleType; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("entitletype", (short)_entitleType, (short)value);
|
|||
|
_entitleType = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region isFlatAmount : bool
|
|||
|
|
|||
|
public bool IsFlatAmount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_flatAmount != 0)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region opiAvgPayType : EnumOpiAvgPayType
|
|||
|
|
|||
|
private EnumOpiAvgPayType _opiAvgPayType;
|
|||
|
public EnumOpiAvgPayType OpiAvgPayType
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _opiAvgPayType;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("OpiAvgPayType", (short)_opiAvgPayType, (short)value);
|
|||
|
_opiAvgPayType = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiAvgPayItemID : ID
|
|||
|
private ID _opiAvgPayItemID;
|
|||
|
public ID OpiAvgPayItemID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _opiAvgPayItemID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("OpiAvgPayItemID", _opiAvgPayItemID, value);
|
|||
|
_opiAvgPayItemID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region NoOfMonth : int
|
|||
|
private int _nNoOfMonth;
|
|||
|
public int NoOfMonth
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _nNoOfMonth;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("NoOfMonth", _nNoOfMonth, value);
|
|||
|
_nNoOfMonth = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiParameterGrades : ObjectsTemplate<OpiParameterGrade>
|
|||
|
private ObjectsTemplate<OpiParameterGrade> _opiParameterGrades;
|
|||
|
public ObjectsTemplate<OpiParameterGrade> OpiParameterGrades
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_opiParameterGrades == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|||
|
{
|
|||
|
_opiParameterGrades = OpiParameter.GetGrades(this.ID);
|
|||
|
}
|
|||
|
return this._opiParameterGrades;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_opiParameterGrades = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiParameterIndividuals : ObjectsTemplate<OpiParameterIndividual>
|
|||
|
private ObjectsTemplate<OpiParameterIndividual> _opiParameterIndividuals;
|
|||
|
public ObjectsTemplate<OpiParameterIndividual> OpiParameterIndividuals
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_opiParameterIndividuals == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|||
|
{
|
|||
|
_opiParameterIndividuals = OpiParameterIndividual.GetByParameterID(this.ID);
|
|||
|
}
|
|||
|
else if (_opiParameterIndividuals == null)
|
|||
|
{
|
|||
|
_opiParameterIndividuals = new ObjectsTemplate<OpiParameterIndividual>();
|
|||
|
}
|
|||
|
return this._opiParameterIndividuals;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_opiParameterIndividuals = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OpiItem : OpiItem
|
|||
|
private OpiItem _opiItem;
|
|||
|
public OpiItem OpiItem
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_opiItemID.Integer > 0 && _opiItem == null)
|
|||
|
{
|
|||
|
_opiItem = new OpiItem();
|
|||
|
_opiItem = OpiItem.Get(_opiItemID);
|
|||
|
}
|
|||
|
return this._opiItem;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_opiItem = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
//#region NotApplicable : OpiParameterIndividual
|
|||
|
//private ObjectsTemplate<OpiParameterIndividual> _NotApplicable = null;
|
|||
|
//public ObjectsTemplate<OpiParameterIndividual> NotApplicable
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// if (_NotApplicable == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|||
|
// {
|
|||
|
// _NotApplicable = OpiParameterIndividual.GetIndividuals(this.ID, EnumOPIIndivdualType.NotApplicable);
|
|||
|
// }
|
|||
|
// return this._NotApplicable;
|
|||
|
// }
|
|||
|
//}
|
|||
|
//#endregion
|
|||
|
|
|||
|
#region NoOfAplicableEmp : int
|
|||
|
private int _noOfemployee;
|
|||
|
public int NoOfAplicableEmp
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_noOfemployee <= 0)
|
|||
|
{
|
|||
|
string gradeIDs = string.Empty;
|
|||
|
foreach (OpiParameterGrade pGrade in this.OpiParameterGrades)
|
|||
|
{
|
|||
|
if (gradeIDs != string.Empty)
|
|||
|
gradeIDs += "," + pGrade.GradeId.ToString();
|
|||
|
else
|
|||
|
gradeIDs += pGrade.GradeId.ToString();
|
|||
|
}
|
|||
|
SearchManager om = new SearchManager(EnumSearchFrom.Employee);
|
|||
|
om.Parameter.Add(EnumSearchParameter.GradeID, EnumSQLOperator.In, EnumSearchObjDataType.String, gradeIDs);
|
|||
|
om.Parameter.Add(EnumSearchParameter.Status, (int)EnumEmployeeStatus.Live);
|
|||
|
//confirmed is selected
|
|||
|
om.Parameter.Add(EnumSearchParameter.Confirm, true);
|
|||
|
|
|||
|
//if gender is selected
|
|||
|
om.Parameter.Add(EnumSearchParameter.Gender, (int)EnumGender.Male);
|
|||
|
ObjectsTemplate<SearchEmployee> emps = om.Find();
|
|||
|
_noOfemployee = emps.Count;
|
|||
|
}
|
|||
|
return _noOfemployee;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
private int ApplicableEmp()
|
|||
|
{
|
|||
|
int nApplEmp = 0;
|
|||
|
|
|||
|
//if (this.EntitleType == EnumEntitleType.Grade)
|
|||
|
//{
|
|||
|
//}
|
|||
|
return nApplEmp;
|
|||
|
}
|
|||
|
public OpiParameter Get(ID nOpiParameterID)
|
|||
|
{
|
|||
|
OpiParameter oOpiParameter = null;
|
|||
|
#region Cache Header
|
|||
|
oOpiParameter = (OpiParameter)_cache["Get", nOpiParameterID];
|
|||
|
if (oOpiParameter != null)
|
|||
|
return oOpiParameter;
|
|||
|
#endregion
|
|||
|
oOpiParameter = OpiParameter.Service.Get(nOpiParameterID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oOpiParameter, "Get", nOpiParameterID);
|
|||
|
#endregion
|
|||
|
return oOpiParameter;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<OpiParameter> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<OpiParameter> OpiParameters = _cache["Get"] as ObjectsTemplate<OpiParameter>;
|
|||
|
if (OpiParameters != null)
|
|||
|
return OpiParameters;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
OpiParameters = Service.GetByPayrollTypeID(SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(OpiParameters, "Get");
|
|||
|
#endregion
|
|||
|
return OpiParameters;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<OpiParameterGrade> GetGrades(ID opiParameterID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<OpiParameterGrade> oGrades = _cache["Get", opiParameterID] as ObjectsTemplate<OpiParameterGrade>;
|
|||
|
if (oGrades != null)
|
|||
|
return oGrades;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
oGrades = Service.GetGrades(opiParameterID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oGrades, "Get", opiParameterID);
|
|||
|
#endregion
|
|||
|
|
|||
|
return oGrades;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<OpiParameter> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<OpiParameter> opiParameters = _cache["Get", status] as ObjectsTemplate<OpiParameter>;
|
|||
|
if (opiParameters != null)
|
|||
|
return opiParameters;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
opiParameters = Service.Get(status, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(opiParameters, "Get", status);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return opiParameters;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<OpiParameter> Get(EnumStatus status, EnumOpiType type)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<OpiParameter> opiParameters = _cache["Get", status, type] as ObjectsTemplate<OpiParameter>;
|
|||
|
if (opiParameters != null)
|
|||
|
return opiParameters;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
opiParameters = Service.Get(status, type, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(opiParameters, "Get", status, type);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return opiParameters;
|
|||
|
}
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
this.SetAuditTrailProperties();
|
|||
|
return OpiParameter.Service.Save(this, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
public void Delete()
|
|||
|
{
|
|||
|
OpiParameter.Service.Delete(ID, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
#region Exception : ADParameterEmployee
|
|||
|
|
|||
|
private ObjectsTemplate<OpiParameterIndividual > _Exception = null;
|
|||
|
public ObjectsTemplate<OpiParameterIndividual> Exception
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_Exception == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|||
|
{
|
|||
|
_Exception = OpiParameterIndividual.GetIndividuals(this.ID, EnumOPIIndivdualType.Exception);
|
|||
|
}
|
|||
|
return this._Exception;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region NotApplicable : ADParameterEmployee
|
|||
|
|
|||
|
private ObjectsTemplate<OpiParameterIndividual> _NotApplicable = null;
|
|||
|
public ObjectsTemplate<OpiParameterIndividual> NotApplicable
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_NotApplicable == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|||
|
{
|
|||
|
_NotApplicable = OpiParameterIndividual.GetIndividuals(this.ID, EnumOPIIndivdualType.NotApplicable);
|
|||
|
}
|
|||
|
return this._NotApplicable;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
public static List<OpiParameter> GetApplicableParameters(Employee employee,
|
|||
|
ID graId, ObjectsTemplate<OpiParameter> parameters)
|
|||
|
{
|
|||
|
List<OpiParameter> applicableParams = parameters.FindAll(delegate(OpiParameter param) { return IsApplicable(param, graId, employee); });
|
|||
|
|
|||
|
return applicableParams;
|
|||
|
}
|
|||
|
private static bool IsApplicable(OpiParameter param, ID graid, Employee employee)
|
|||
|
{
|
|||
|
bool isApplicable = false;
|
|||
|
|
|||
|
foreach (OpiParameterGrade adgrade in param.OpiParameterGrades)
|
|||
|
{
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
/// <param name="employee"></param>
|
|||
|
/// <param name="basicSalary"></param>
|
|||
|
/// <param name="grossSalary"></param>
|
|||
|
/// <returns></returns>
|
|||
|
|
|||
|
public double GetGradeDefinedAmount(Employee employee, ObjectsTemplate<EmployeeGradeSalary> gradeSalarires)
|
|||
|
{
|
|||
|
double nAmount = 0;
|
|||
|
foreach (EmployeeGradeSalary item in gradeSalarires)
|
|||
|
{
|
|||
|
nAmount = nAmount + this.GetGradeDefinedAmount(employee, item.BasicSalary, item.GrossSalary, item.FractionofFromTo);
|
|||
|
}
|
|||
|
return nAmount;
|
|||
|
}
|
|||
|
public double GetGradeDefinedAmount(Employee employee, ObjectsTemplate<EmployeeGradeSalary> gradeSalarires, double nGross)
|
|||
|
{
|
|||
|
double nAmount = 0;
|
|||
|
foreach (EmployeeGradeSalary item in gradeSalarires)
|
|||
|
{
|
|||
|
nAmount = nAmount + this.GetGradeDefinedAmount(employee, item.BasicSalary, nGross, item.FractionofFromTo);
|
|||
|
}
|
|||
|
return nAmount;
|
|||
|
}
|
|||
|
|
|||
|
public double GetGradeDefinedAmount(Employee employee, EmployeeGradeSalary gradeSalary)
|
|||
|
{
|
|||
|
return this.GetGradeDefinedAmount(employee, gradeSalary.BasicSalary, gradeSalary.GrossSalary, gradeSalary.FractionofFromTo);
|
|||
|
}
|
|||
|
public double GetGradeDefinedAmount(Employee employee, double basicSalary,
|
|||
|
double grossSalary, double fractionate)
|
|||
|
{
|
|||
|
OpiParameterIndividual opiIndividual = null;
|
|||
|
double nAmount = 0.0;
|
|||
|
switch (this.EntitleType)
|
|||
|
{
|
|||
|
case EnumEntitleType.Grade:
|
|||
|
if (this.PercentOfBasic > 0)
|
|||
|
//nAmount = basicSalary * this.PercentOfBasic / 100.0 + this.FlatAmount;
|
|||
|
if (this.IsFractionate)
|
|||
|
nAmount = nAmount + this.FlatAmount * fractionate + (basicSalary * this.PercentOfBasic * fractionate) / 100.0;
|
|||
|
else
|
|||
|
nAmount = nAmount + ((basicSalary * this.PercentOfBasic / 100.0) * fractionate);
|
|||
|
else if (this.PercentOfGross > 0)
|
|||
|
//nAmount = grossSalary * this.PercentOfGross / 100.0 + this.FlatAmount;
|
|||
|
if (this.IsFractionate)
|
|||
|
nAmount = nAmount + this.FlatAmount * fractionate + (grossSalary * this.PercentOfGross * fractionate) / 100.0;
|
|||
|
else
|
|||
|
nAmount = nAmount + ((grossSalary * this.PercentOfGross / 100.0) * fractionate);
|
|||
|
else
|
|||
|
nAmount = this.FlatAmount * fractionate;
|
|||
|
|
|||
|
if (this.NotApplicable.Exists(delegate(OpiParameterIndividual adEmployee) { return adEmployee.EmployeeId.Integer == employee.ID.Integer; }))
|
|||
|
{
|
|||
|
nAmount = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpiParameterIndividual adEmp = this.Exception.Find(delegate(OpiParameterIndividual adEmployee) { return adEmployee.EmployeeId.Integer == employee.ID.Integer; });
|
|||
|
if (adEmp != null)
|
|||
|
{
|
|||
|
switch (adEmp.ValueType)
|
|||
|
{
|
|||
|
case EnumValueType.Amount:
|
|||
|
nAmount = adEmp.Value;
|
|||
|
break;
|
|||
|
case EnumValueType.Other:
|
|||
|
if (this.PercentOfBasic > 0)
|
|||
|
nAmount = basicSalary * adEmp.Value / 100.0 * fractionate; //+ this.FlatAmount;
|
|||
|
// nAmount = basicSalary * adEmp.Value / 100.0 + this.FlatAmount;
|
|||
|
else if (this.PercentOfGross > 0)
|
|||
|
{
|
|||
|
nAmount = grossSalary * adEmp.Value / 100.0 * fractionate; //+ this.FlatAmount;
|
|||
|
//nAmount = grossSalary * adEmp.Value / 100.0 + this.FlatAmount;
|
|||
|
}
|
|||
|
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//if (this.IsFlatAmount == true) nAmount = GlobalFunctions.Round(nAmount * fractionate);
|
|||
|
//nAmount = GlobalFunctions.Round(nAmount * fractionate);
|
|||
|
break;
|
|||
|
|
|||
|
case EnumEntitleType.Individual:
|
|||
|
throw new ServiceException("You have choosed the wrong overloaded function to calculate"
|
|||
|
+ " Individual Allowance");
|
|||
|
}
|
|||
|
if (this.MinAmount != 0 || this.MaxAmount != 0)
|
|||
|
{
|
|||
|
if (nAmount < this.MinAmount)
|
|||
|
{
|
|||
|
nAmount = this.MinAmount;
|
|||
|
}
|
|||
|
if (nAmount > this.MaxAmount)
|
|||
|
{
|
|||
|
nAmount = this.MaxAmount;
|
|||
|
}
|
|||
|
}
|
|||
|
return nAmount;
|
|||
|
}
|
|||
|
|
|||
|
public double GetIndividualAmount(Employee employee, DateTime fortheMonth,
|
|||
|
OpiParameterIndividual ademployee)
|
|||
|
{
|
|||
|
return GetIndividualAmount(employee, fortheMonth,
|
|||
|
ademployee, employee.BasicSalary, employee.GrossSalary);
|
|||
|
|
|||
|
}
|
|||
|
public double GetIndividualAmount(Employee employee, DateTime fortheMonth,
|
|||
|
OpiParameterIndividual ademployee, double basicSalary, double grossSalary)
|
|||
|
{
|
|||
|
double nAmount = 0.0;
|
|||
|
switch (this.EntitleType)
|
|||
|
{
|
|||
|
case EnumEntitleType.Grade:
|
|||
|
throw new ServiceException("You have choosed the wrong overloaded function to calculate"
|
|||
|
+ " Grade defined Allowance");
|
|||
|
case EnumEntitleType.Individual:
|
|||
|
|
|||
|
if (ademployee.ArrearType == EnumArrearType.NotPresent)
|
|||
|
{
|
|||
|
DateTime fromDate = GlobalFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
DateTime toDate = SystemInformation.CurrentSysInfo.NextPayProcessDate;
|
|||
|
if (ademployee.FromDate < GlobalFunctions.FirstDateOfMonth(fortheMonth))
|
|||
|
fromDate = GlobalFunctions.FirstDateOfMonth(fortheMonth);
|
|||
|
else fromDate=ademployee.FromDate;
|
|||
|
|
|||
|
if (ademployee.ToDate == null || ademployee.ToDate == DateTime.MinValue)
|
|||
|
toDate = GlobalFunctions.LastDateOfMonth(fortheMonth);
|
|||
|
else toDate = (DateTime)ademployee.ToDate ;
|
|||
|
|
|||
|
if (toDate > GlobalFunctions.LastDateOfMonth(fortheMonth))
|
|||
|
toDate = GlobalFunctions.LastDateOfMonth(fortheMonth);
|
|||
|
|
|||
|
if (ademployee.OpiPeriodicity != EnumOpiPeriodicity.OnceOff)
|
|||
|
if (employee.EndOfContractDate != null || employee.EndOfContractDate != DateTime.MinValue)
|
|||
|
if (employee.EndOfContractDate < toDate)
|
|||
|
toDate = (DateTime)employee.EndOfContractDate;
|
|||
|
if (ademployee.ValueType == EnumValueType.Other)
|
|||
|
{
|
|||
|
//while percent of basic then not required to do fractionate of date basis
|
|||
|
//if(this.PercentOfBasic >0)
|
|||
|
// nAmount = (basicSalary * ademployee.MonthlyAmount)/100 * GlobalFunctions.GetFraction(fromDate, toDate);
|
|||
|
//else if (this.PercentOfGross>0)
|
|||
|
// nAmount = (grossSalary * ademployee.MonthlyAmount)/100 * GlobalFunctions.GetFraction(fromDate, toDate);
|
|||
|
if (this.PercentOfBasic > 0)
|
|||
|
nAmount = (basicSalary * ademployee.Value) / 100 * GlobalFunctions.GetFraction(fromDate, toDate);
|
|||
|
else if (this.PercentOfGross > 0)
|
|||
|
nAmount = (grossSalary * ademployee.Value) / 100 * GlobalFunctions.GetFraction(fromDate, toDate);
|
|||
|
|
|||
|
}
|
|||
|
else nAmount = ademployee.Value * GlobalFunctions.GetFraction(fromDate, toDate);//GlobalFunctions.GetFraction(fromDate, toDate);
|
|||
|
}
|
|||
|
else if (ademployee.ArrearType == EnumArrearType.ToCalculate)
|
|||
|
{
|
|||
|
if (ademployee.ValueType == EnumValueType.Other)
|
|||
|
{
|
|||
|
if (this.PercentOfBasic > 0)
|
|||
|
nAmount = (basicSalary * ademployee.Value) / 100 * GlobalFunctions.GetFraction(ademployee.FromDate , (DateTime)ademployee.ToDate );
|
|||
|
else if (this.PercentOfGross > 0)
|
|||
|
nAmount = (grossSalary * ademployee.Value) / 100 * GlobalFunctions.GetFraction(ademployee.FromDate , (DateTime)ademployee.ToDate );
|
|||
|
}
|
|||
|
else nAmount = ademployee.Value *
|
|||
|
GlobalFunctions.GetFraction(ademployee.FromDate , (DateTime)ademployee.ToDate);
|
|||
|
}
|
|||
|
|
|||
|
break;
|
|||
|
}
|
|||
|
return nAmount;
|
|||
|
}
|
|||
|
public ObjectsTemplate<OpiParameter> ApplicableParameters(Employee emlpoyee,
|
|||
|
OPIProcessDetail oprocdetail, ObjectsTemplate<OpiParameter> allOpiParameters,
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> gradeSalaries)
|
|||
|
{
|
|||
|
ObjectsTemplate<OpiParameter> oparameters = new ObjectsTemplate<OpiParameter>();
|
|||
|
foreach (EmployeeGradeSalary gs in gradeSalaries)
|
|||
|
{
|
|||
|
List<OpiParameter> lparameter = OpiParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allOpiParameters);
|
|||
|
foreach (OpiParameter item in lparameter)
|
|||
|
{
|
|||
|
if (oparameters.Contains(item) == false)
|
|||
|
oparameters.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
return oparameters;
|
|||
|
//foreach (EmployeeGradeSalary gs in oprocdetail.ArrearGradeSalaries)
|
|||
|
//{
|
|||
|
// List<OpiParameter> alparameter = OpiParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allOpiParameters);
|
|||
|
// gs.OpiParameters = new ObjectsTemplate<OpiParameter>();
|
|||
|
// foreach (OpiParameter item in alparameter)
|
|||
|
// gs.OpiParameters.Add(item);
|
|||
|
//}
|
|||
|
|
|||
|
//foreach (EmployeeGradeSalary gs in oprocdetail.ArrearPaidGradeSalaries)
|
|||
|
//{
|
|||
|
// List<OpiParameter> aplparameter = OpiParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allOpiParameters);
|
|||
|
// gs.OpiParameters = new ObjectsTemplate<OpiParameter>();
|
|||
|
// foreach (OpiParameter item in aplparameter)
|
|||
|
// gs.OpiParameters.Add(item);
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<OpiParameterGrade> GetGrades()
|
|||
|
{
|
|||
|
return OpiParameter.Service.GetGrades(SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
internal static ObjectsTemplate<OpiParameter> Get(EnumStatus enumStatus, EnumOpiType enumOpiType, EnumEntitleType enumEntitleType)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<OpiParameter> opiitems = _cache["Get", enumStatus, enumOpiType, enumEntitleType] as ObjectsTemplate<OpiParameter>;
|
|||
|
if (opiitems != null)
|
|||
|
return opiitems;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
opiitems = Service.Get(enumStatus, enumOpiType, enumEntitleType, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(opiitems, "Get", enumStatus, enumOpiType, enumEntitleType);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return opiitems;
|
|||
|
}
|
|||
|
|
|||
|
internal static ObjectsTemplate<OpiParameter> Get(EnumStatus enumStatus,EnumEntitleType enumEntitleType)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<OpiParameter> opiitems = _cache["Get", enumStatus, enumEntitleType] as ObjectsTemplate<OpiParameter>;
|
|||
|
if (opiitems != null)
|
|||
|
return opiitems;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
opiitems = Service.Get(enumStatus, enumEntitleType, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(opiitems, "Get", enumStatus, enumEntitleType);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return opiitems;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory
|
|||
|
internal static IOpiParameterService Service
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return Services.Factory.CreateService<IOpiParameterService>(typeof(IOpiParameterService));
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IOpiParameter Service
|
|||
|
public interface IOpiParameterService
|
|||
|
{
|
|||
|
OpiParameter Get(ID id);
|
|||
|
ObjectsTemplate<OpiParameter> GetByPayrollTypeID(ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameterGrade> GetGrades(ID opiParameterID, ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameterGrade> GetGrades(ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameter> Get(EnumStatus status, ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameter> Get(EnumStatus status, EnumOpiType type, ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameter> Get(EnumStatus enumStatus, EnumOpiType enumOpiType, EnumEntitleType enumEntitleType, ID payrollTypeID);
|
|||
|
ObjectsTemplate<OpiParameter> Get(EnumStatus enumStatus, EnumEntitleType enumEntitleType, ID payrollTypeID);
|
|||
|
ID Save(OpiParameter oOpiParameter, ID payrollTypeID);
|
|||
|
void Delete(ID id, ID payrollTypeID);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|