CEL_Payroll/Payroll.BO/Bonus/BonusParameter.cs

1352 lines
40 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
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 BonusParameter
[Serializable]
public class BonusParameter : BasicBaseObject,ISetupManager
{
#region Cache Store
private static Cache _cache = new Cache(typeof(BonusParameter));
#endregion
#region Constructor
public BonusParameter()
{
_confirmeRequired = false;
_isFestival = false;
_EligibleCuttoffDate = false;
_isProrated = false;
_isOverYearCalculation = false;
_flatAmount = 0;
_noOfBasic = 0;
_noOfDays = 0;
_payrollTypeID = null;
_noOfEarnedBasic = 0;
_noOfDisbusement = 0;
_bonusID = null;
_BonusParamAdjustItems = null;
_BonusParamSalaryItems = null;
_BonusServiceLengths = null;
_taxProjectInMonth = 1;
_percentOfGross = 0;
}
#endregion
#region Internal Class
[Serializable]
public class BonusServiceLength : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(BonusServiceLength));
#endregion
#region Constructor
public BonusServiceLength()
{
_bonusParameterID = null;
_lengthOfService = 0;
_entitlePercent = 0;
}
#endregion
#region Properties
#region BonusParameterID : ID
private ID _bonusParameterID;
public ID BonusParameterID
{
get { return _bonusParameterID; }
set
{
base.OnPropertyChange<ID>("BonusParameterID", _bonusParameterID, value);
_bonusParameterID = value;
}
}
#endregion
#region LengthOfService : Int
private int _lengthOfService;
public int LengthOfService
{
get { return _lengthOfService; }
set
{
base.OnPropertyChange<int>("LengthOfService", _lengthOfService, value);
_lengthOfService = value;
}
}
#endregion
#region EntitlePercent : Int
private int _entitlePercent;
public int EntitlePercent
{
get { return _entitlePercent; }
set
{
base.OnPropertyChange<int>("EntitlePercent", _entitlePercent, value);
_entitlePercent = value;
}
}
#endregion
#endregion
}
#endregion
#region Internal Class
[Serializable]
public class BonusParamSalaryItem : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(BonusParamSalaryItem));
#endregion
#region Constructor
public BonusParamSalaryItem()
{
_allowDeductID = 0;
_noOfSalary = 0;
_percent = 0;
_salaryGroupCode = 0;
_bonusParameterID = null;
}
#endregion
#region Properties
#region AllowDeductID : ID
private int _allowDeductID;
public int AllowDeductID
{
get { return _allowDeductID; }
set
{
base.OnPropertyChange<int>("AllowDeductID", _allowDeductID, value);
_allowDeductID = value;
}
}
#endregion
#region NoOfSalary : Int
private int _noOfSalary;
public int NoOfSalary
{
get { return _noOfSalary; }
set
{
base.OnPropertyChange<int>("NoOfSalary", _noOfSalary, value);
_noOfSalary = value;
}
}
#endregion
#region Percent : Int
private int _percent;
public int Percent
{
get { return _percent; }
set
{
base.OnPropertyChange<int>("Percent", _percent, value);
_percent = value;
}
}
#endregion
#region SalaryGroupCode : Int
private int _salaryGroupCode;
public int SalaryGroupCode
{
get { return _salaryGroupCode; }
set
{
base.OnPropertyChange<int>("SalaryGroupCode", _salaryGroupCode, value);
_salaryGroupCode = value;
}
}
#endregion
#region BonusParameterID : ID
private ID _bonusParameterID;
public ID BonusParameterID
{
get { return _bonusParameterID; }
set
{
base.OnPropertyChange<ID>("BonusParameterID", _bonusParameterID, value);
_bonusParameterID = value;
}
}
#endregion
#endregion
}
#endregion
#region Internal Class
[Serializable]
public class BonusParamAdjustItem : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(BonusParamAdjustItem));
#endregion
#region Constructor
public BonusParamAdjustItem()
{
_amount = 0.0;
_bonusAdjustItemID = 0;
_bonusParameterID = null;
}
#endregion
#region Properties
#region Amount : double
private double _amount;
public double Amount
{
get { return _amount; }
set
{
base.OnPropertyChange<double>("Amount", _amount, value);
_amount = value;
}
}
#endregion
#region BonusAdjustItemID : int
private int _bonusAdjustItemID;
public int BonusAdjustItemID
{
get { return _bonusAdjustItemID; }
set
{
base.OnPropertyChange<int>("BonusAdjustItemID", _bonusAdjustItemID, value);
_bonusAdjustItemID = value;
}
}
#endregion
#region BonusParameterID : ID
private ID _bonusParameterID;
public ID BonusParameterID
{
get { return _bonusParameterID; }
set
{
base.OnPropertyChange<ID>("BonusParameterID", _bonusParameterID, value);
_bonusParameterID = value;
}
}
#endregion
#endregion
}
#endregion
#region Internal Class
[Serializable]
public class BonusSlab : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(BonusSlab));
#endregion
#region Constructor
public BonusSlab()
{
_bonusParameterID = null;
_slabType = EnumSlabType.BasicSalary;
_SlabAmount = 0.0;
_Amount = 0.0;
_AmountType = EnumSlabAmountType.FlatAmount;
}
#endregion
#region Properties
#region BonusParameterID : ID
private ID _bonusParameterID;
public ID BonusParameterID
{
get { return _bonusParameterID; }
set
{
base.OnPropertyChange<ID>("BonusParameterID", _bonusParameterID, value);
_bonusParameterID = value;
}
}
#endregion
#region SlabType : EnumSlabType
private EnumSlabType _slabType;
public EnumSlabType SlabType
{
get { return _slabType; }
set
{
base.OnPropertyChange<short>("SlabType",(short) _slabType,(short) value);
_slabType = value;
}
}
#endregion
#region SlabAmount : Double
private double _SlabAmount;
public double SlabAmount
{
get { return _SlabAmount; }
set
{
base.OnPropertyChange<double>("SlabAmount", _SlabAmount, value);
_SlabAmount = value;
}
}
#endregion
#region Amount : Double
private double _Amount;
public double Amount
{
get { return _Amount; }
set
{
base.OnPropertyChange<double>("Amount", _Amount, value);
_Amount = value;
}
}
#endregion
#region AmountType : EnumSlabAmountType
private EnumSlabAmountType _AmountType;
public EnumSlabAmountType AmountType
{
get { return _AmountType; }
set
{
base.OnPropertyChange<short>("AmountType",(short) _AmountType, (short)value);
_AmountType = value;
}
}
#endregion
#endregion
}
#endregion
#region Properties
#region confirmeRequired : bool
private bool _confirmeRequired;
public bool ConfirmeRequired
{
get { return _confirmeRequired; }
set
{
base.OnPropertyChange<bool>("confirmeRequired", _confirmeRequired, value);
_confirmeRequired = value;
}
}
#endregion
#region IsFestival : bool
private bool _isFestival;
public bool IsFestival
{
get { return _isFestival; }
set
{
base.OnPropertyChange<bool>("IsFestival", _isFestival, value);
_isFestival = 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 PerformanceBonusPercent : Double
private double _performanceBonusPercent;
public double PerformanceBonusPercent
{
get { return _performanceBonusPercent; }
set {
base.OnPropertyChange<double>("PerformanceBonusPercent", _performanceBonusPercent, value);
_performanceBonusPercent = value;
}
}
#endregion
#region Q1:Double
private double _q1;
public double Q1
{
get { return _q1; }
set {
base.OnPropertyChange<double>("Q1", _q1, value);
_q1 = value;
}
}
#endregion
#region Q2:Double
private double _q2;
public double Q2
{
get { return _q2; }
set {
base.OnPropertyChange<double>("Q2", _q2, value);
_q2 = value; }
}
#endregion
#region Q3:double
private double _q3;
public double Q3
{
get { return _q3; }
set {
base.OnPropertyChange<double>("Q3", _q3, value);
_q3 = value; }
}
#endregion
#region Q4:Double
private double _q4;
public double Q4
{
get { return _q4; }
set {
base.OnPropertyChange<double>("Q4", _q4, value);
_q4 = value; }
}
#endregion
#region noOfBasic : int
private double _noOfBasic;
public double NoOfBasic
{
get { return _noOfBasic; }
set
{
base.OnPropertyChange<double>("noOfBasic", _noOfBasic, value);
_noOfBasic = value;
}
}
#endregion
#region noOfDays : int
private int _noOfDays;
public int NoOfDays
{
get { return _noOfDays; }
set
{
base.OnPropertyChange<int>("noOfDays", _noOfDays, value);
_noOfDays = value;
}
}
#endregion
#region TaxProjectInMonth : int
private int _taxProjectInMonth;
public int TaxProjectInMonth
{
get { return _taxProjectInMonth; }
set
{
_taxProjectInMonth = value;
}
}
#endregion
#region PayrollTypeID : ID
private ID _payrollTypeID;
public ID PayrollTypeID
{
get { return _payrollTypeID; }
set
{
base.OnPropertyChange<ID>("PayrollTypeID", _payrollTypeID, value);
_payrollTypeID = value;
}
}
#endregion
#region BonusID : ID
private ID _bonusID;
public ID BonusID
{
get { return _bonusID; }
set
{
base.OnPropertyChange<ID>("BonusID", _bonusID, value);
_bonusID = value;
}
}
#endregion
#region noOfEarnedBasic : int
private int _noOfEarnedBasic;
public int NoOfEarnedBasic
{
get { return _noOfEarnedBasic; }
set
{
base.OnPropertyChange<int>("noOfEarnedBasic", _noOfEarnedBasic, value);
_noOfEarnedBasic = value;
}
}
#endregion
#region NoOfDisbusement : int
private int _noOfDisbusement;
public int NoOfDisbusement
{
get { return _noOfDisbusement; }
set
{
base.OnPropertyChange<int>("NoOfDisbusement", _noOfDisbusement, value);
_noOfDisbusement = value;
}
}
#endregion
#region noOfGross : int
private double _noOfGross;
public double NoOfGross
{
get { return _noOfGross; }
set
{
base.OnPropertyChange<double>("NoOfGross", _noOfGross, value);
_noOfGross = value;
}
}
#endregion
#region PercentOfGross : int
private double _percentOfGross;
public double PercentOfGross
{
get { return _percentOfGross; }
set
{
base.OnPropertyChange<double>("PercentOfGross", _percentOfGross, value);
_percentOfGross = value;
}
}
#endregion
#region GrossOfDays : int
private int _grossOfDays;
public int GrossOfDays
{
get { return _grossOfDays; }
set
{
base.OnPropertyChange<int>("GrossOfDays", _grossOfDays, value);
_grossOfDays = value;
}
}
#endregion
#region EligibleCuttoffDate : bool
private bool _EligibleCuttoffDate;
public bool EligibleCuttoffDate
{
get { return _EligibleCuttoffDate; }
set
{
base.OnPropertyChange<bool>("EligibleCuttoffDate", _EligibleCuttoffDate, value);
_EligibleCuttoffDate = value;
}
}
#endregion
#region IsProrated : bool
private bool _isProrated;
public bool IsProrated
{
get { return _isProrated; }
set
{
base.OnPropertyChange<bool>("IsProrated", _isProrated, value);
_isProrated = value;
}
}
#endregion
#region IsOverYearCalculation : bool
private bool _isOverYearCalculation;
public bool IsOverYearCalculation
{
get { return _isOverYearCalculation; }
set
{
base.OnPropertyChange<bool>("IsOverYearCalculation", _isOverYearCalculation, value);
_isOverYearCalculation = value;
}
}
#endregion
#region BonusServiceLength : BonusServiceLength
private ObjectsTemplate<BonusParameter.BonusServiceLength> _BonusServiceLengths = null;
public ObjectsTemplate<BonusParameter.BonusServiceLength> BonusServiceLengths
{
get
{
if (_BonusServiceLengths == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_BonusServiceLengths = BonusParameter.GetSerLengthByBonus(this.ID);
}
return this._BonusServiceLengths;
}
set
{
_BonusServiceLengths = value;
}
}
#endregion
#region BonusSlabs : BonusSlabs
private ObjectsTemplate<BonusParameter.BonusSlab> _BonusSlabs = null;
public ObjectsTemplate<BonusParameter.BonusSlab> BonusSlabs
{
get
{
if (_BonusSlabs == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_BonusSlabs = BonusParameter.GetSlabByBonus(this.ID);
}
return this._BonusSlabs;
}
set
{
_BonusSlabs = value;
}
}
#endregion
#region BonusParamSalaryItem : BonusParamSalaryItem
private ObjectsTemplate<BonusParameter.BonusParamSalaryItem> _BonusParamSalaryItems = null;
public ObjectsTemplate<BonusParameter.BonusParamSalaryItem> BonusParamSalaryItems
{
get
{
if (_BonusParamSalaryItems == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_BonusParamSalaryItems = BonusParameter.GetSalaryItemByBonus(this.ID);
}
return this._BonusParamSalaryItems;
}
set
{
_BonusParamSalaryItems = value;
}
}
#endregion
#region BonusParamAdjustItem : BonusParamAdjustItem
private ObjectsTemplate<BonusParameter.BonusParamAdjustItem> _BonusParamAdjustItems = null;
public ObjectsTemplate<BonusParameter.BonusParamAdjustItem> BonusParamAdjustItems
{
get
{
if (_BonusParamAdjustItems == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_BonusParamAdjustItems = BonusParameter.GetAdjustItemByBonus(this.ID);
}
return this._BonusParamAdjustItems;
}
set
{
_BonusParamAdjustItems = value;
}
}
#endregion
#region Service Factory IBonusService : IBonusService
internal static IBonusParameterService Service
{
get { return Services.Factory.CreateService<IBonusParameterService>(typeof(IBonusParameterService)); }
}
#endregion
#endregion
#region Functions
public static BonusParameter Get(ID nBonsuParamID)
{
BonusParameter oBonusParameter = null;
#region Cache Header
oBonusParameter = (BonusParameter)_cache["Get", nBonsuParamID];
if (oBonusParameter != null)
return oBonusParameter;
#endregion
oBonusParameter = BonusParameter.Service.Get(nBonsuParamID);
#region Cache Footer
_cache.Add(oBonusParameter, "Get", nBonsuParamID);
#endregion
return oBonusParameter;
}
public static BonusParameter GetByBonusID(ID nBonsuID)
{
BonusParameter oBonusParameter = null;
#region Cache Header
oBonusParameter = (BonusParameter)_cache["Get", nBonsuID];
if (oBonusParameter != null)
return oBonusParameter;
#endregion
oBonusParameter = BonusParameter.Service.GetByBonusID(nBonsuID, SystemInformation.CurrentSysInfo.PayrollTypeID);
#region Cache Footer
_cache.Add(oBonusParameter, "Get", nBonsuID);
#endregion
return oBonusParameter;
}
public bool IsPercent()
{
if (_noOfBasic > 0 || _noOfGross > 0)
{
return false;
}
else
return true;
}
public string CurrentProcessText()
{
string scaption="Basic";
if (_flatAmount > 0)
{
scaption = "% Flat Amount";
}
else if (_noOfBasic > 0)
{
scaption = "Basic";
}
else if (_noOfGross > 0)
{
scaption = "Gross";
}
else if(this.BonusServiceLengths!=null && this.BonusServiceLengths.Count>0)
{
scaption = "%";
}
else if(this.BonusParamSalaryItems!=null && this.BonusParamSalaryItems.Count>0)
{
scaption = "%";
}
else if(this.BonusSlabs!=null && this.BonusSlabs.Count>0)
{
scaption = "%";
}
return scaption;
}
public double CurrentProcessItem(double nUsedProcess, double nUsedDisburs)
{
double nAmount = (double)this.NoOfBasic;
if (this.NoOfDisbusement - nUsedDisburs == 0) return 1;
if (_flatAmount > 0)
{
nAmount = 100;
if ((nAmount - nUsedProcess) == 0 && (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
else if (_noOfBasic > 0)
{
if ((nAmount - nUsedProcess) == 0 && (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
else if (_noOfGross > 0)
{
if ((nAmount - nUsedProcess) == 0 || (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
else if (this.BonusParamSalaryItems != null && this.BonusParamSalaryItems.Count > 0)
{
nAmount = 100;
if ((nAmount - nUsedProcess) == 0 || (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
else if (this.BonusServiceLengths != null && this.BonusServiceLengths.Count > 0)
{
nAmount = 100;
if ((nAmount - nUsedProcess) == 0 || (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
else if (this.BonusSlabs != null && this.BonusSlabs.Count > 0)
{
nAmount = 100;
if ((nAmount - nUsedProcess) == 0 || (this.NoOfDisbusement - nUsedDisburs) == 0)
return 0;
else
nAmount = (nAmount - nUsedProcess) / (this.NoOfDisbusement - nUsedDisburs);
}
return nAmount;
}
//public double CurrentProcessItem(DateTime dBonusYear)
//{
// double nAmount =(double) this.NoOfBasic;
// if (_flatAmount > 0)
// {
// nAmount = 100;
// nAmount = nAmount/ this.NoOfDisbusement;
// }
// else if (_noOfBasic > 0)
// {
// nAmount = nAmount / this.NoOfDisbusement;
// }
// else if (_noOfGross > 0)
// {
// nAmount = nAmount / this.NoOfDisbusement;
// }
// else if(this.BonusParamSalaryItems!=null && this.BonusParamSalaryItems.Count>0)
// {
// nAmount = 100;
// nAmount = nAmount / this.NoOfDisbusement;
// }
// else if(this.BonusServiceLengths!=null && this.BonusServiceLengths.Count>0)
// {
// nAmount = 100;
// nAmount = nAmount / this.NoOfDisbusement;
// }
// else if (this.BonusSlabs != null && this.BonusSlabs.Count > 0)
// {
// nAmount = 100;
// nAmount = nAmount / this.NoOfDisbusement;
// }
// return nAmount;
//}
public static ObjectsTemplate<BonusParameter> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<BonusParameter> bonusParameters = _cache["Get", status] as ObjectsTemplate<BonusParameter>;
if (bonusParameters != null)
return bonusParameters;
#endregion
try
{
bonusParameters = Service.Get(status, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(bonusParameters, "Get", status);
#endregion
return bonusParameters;
}
public static ObjectsTemplate<BonusParameter> GetBy(ID nBonusID)
{
ObjectsTemplate<BonusParameter> bonusParameters=new ObjectsTemplate<BonusParameter>();
try
{
bonusParameters = Service.Get(nBonusID, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return bonusParameters;
}
public static ObjectsTemplate<BonusParameter.BonusServiceLength> GetSerLengthByBonus(ID bonusParamID)
{
#region Cache Header
ObjectsTemplate<BonusParameter.BonusServiceLength> bonusParameterServiceLengths = _cache["GetSerLengthByBonus", bonusParamID] as ObjectsTemplate<BonusParameter.BonusServiceLength>;
if (bonusParameterServiceLengths != null)
return bonusParameterServiceLengths;
#endregion
try
{
bonusParameterServiceLengths = Service.GetSerLengthByBonus(bonusParamID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(bonusParameterServiceLengths, "GetSerLengthByBonus", bonusParamID);
#endregion
return bonusParameterServiceLengths;
}
public static ObjectsTemplate<BonusParameter.BonusSlab> GetSlabByBonus(ID bonusParamID)
{
#region Cache Header
ObjectsTemplate<BonusParameter.BonusSlab> bonusParameterSlabs = _cache["GetSlabByBonus", bonusParamID] as ObjectsTemplate<BonusParameter.BonusSlab>;
if (bonusParameterSlabs != null)
return bonusParameterSlabs;
#endregion
try
{
bonusParameterSlabs = Service.GetSlabByBonus(bonusParamID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(bonusParameterSlabs, "GetSlabByBonus", bonusParamID);
#endregion
return bonusParameterSlabs;
}
public static ObjectsTemplate<BonusParameter.BonusParamSalaryItem> GetSalaryItemByBonus(ID bonusParamID)
{
#region Cache Header
ObjectsTemplate<BonusParameter.BonusParamSalaryItem> bonusParamSalaryItems = _cache["GetSalaryItemByBonus", bonusParamID] as ObjectsTemplate<BonusParameter.BonusParamSalaryItem>;
if (bonusParamSalaryItems != null)
return bonusParamSalaryItems;
#endregion
try
{
bonusParamSalaryItems = Service.GetSalaryItemByBonus(bonusParamID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(bonusParamSalaryItems, "GetSalaryItemByBonus", bonusParamID);
#endregion
return bonusParamSalaryItems;
}
public static ObjectsTemplate<BonusParameter.BonusParamAdjustItem> GetAdjustItemByBonus(ID bonusParamID)
{
#region Cache Header
ObjectsTemplate<BonusParameter.BonusParamAdjustItem> bonusParamAdjustItems = _cache["GetAdjustItemByBonus", bonusParamID] as ObjectsTemplate<BonusParameter.BonusParamAdjustItem>;
if (bonusParamAdjustItems != null)
return bonusParamAdjustItems;
#endregion
try
{
bonusParamAdjustItems = Service.GetAdjustItemByBonus(bonusParamID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(bonusParamAdjustItems, "GetAdjustItemByBonus", bonusParamID);
#endregion
return bonusParamAdjustItems;
}
public ID Save()
{
base.SetAuditTrailProperties();
return BonusParameter.Service.Save(this);
}
public void Delete()
{
BonusParameter.Service.Delete(ID);
}
#endregion
#region ISetupManager Members
private ObjectsTemplate<SetupDetail> _setupDetails;
public ObjectsTemplate<SetupDetail> SetupDetails
{
get
{
return _setupDetails;
}
set
{
_setupDetails = value;
}
}
public static BonusParameter ApplicableParameters(ObjectsTemplate<BonusParameter> parameters, Employee employee, ID bonusID)
{
List<int> paramerIDs = SetupManager.ApplicableParameters(employee, EnumParameterSetup.Bonus);
foreach (int i in paramerIDs)
{
foreach (BonusParameter param in parameters)
{
if (param.ID.Integer == i && param.BonusID.Integer == bonusID.Integer)
return param;
}
}
return null;
}
public static ObjectsTemplate<BonusParameter> ApplicableParameters(Employee employee, ID nBonusID, List<EnmSetupManagerTranType> setupTypes, ObjectsTemplate<SetupDetail> setupDetails, List<BonusParameter> bonusParameters)
{
EmployeeSetupParameter empParameter = new EmployeeSetupParameter(EnumParameterSetup.Bonus);
ObjectsTemplate<BonusParameter> oParams = new ObjectsTemplate<BonusParameter>();
empParameter.Employee = employee;
empParameter.ParameterIDs = SetupManager.ApplicableParameters(employee, EnumParameterSetup.Bonus,setupTypes,setupDetails);
for (int i = 0; i < empParameter.ParameterIDs.Count; i++)
{
BonusParameter param = bonusParameters.Find(delegate(BonusParameter bp) { return bp.ID.Integer == empParameter.ParameterIDs[i]; }); //BonusParameter.Get(ID.FromInteger(empParameter.ParameterIDs[i]));
if(param!=null)
{
if (param.BonusID == nBonusID)
{
oParams.Add(param);
}
}
}
return oParams;
}
public static ObjectsTemplate<BonusParameter> ApplicableParameters2(Employee employee, ID nBonusID, List<EnmSetupManagerTranType> setupTypes, ObjectsTemplate<SetupDetail> details)
{
EmployeeSetupParameter empParameter = new EmployeeSetupParameter(EnumParameterSetup.Bonus);
ObjectsTemplate<BonusParameter> oParams = new ObjectsTemplate<BonusParameter>();
empParameter.Employee = employee;
empParameter.ParameterIDs = SetupManager.ApplicableParameters2(employee, EnumParameterSetup.Bonus, setupTypes, details);
for (int i = 0; i < empParameter.ParameterIDs.Count; i++)
{
BonusParameter param = BonusParameter.Get(ID.FromInteger(empParameter.ParameterIDs[i]));
if (param != null)
{
if (param.BonusID == nBonusID)
{
oParams.Add(param);
}
}
}
return oParams;
}
public static ObjectsTemplate<BonusParameter> ApplicableParameters3(Employee employee, ID nBonusID, List<EnmSetupManagerTranType> setupTypes, ObjectsTemplate<SetupDetail> details, ObjectsTemplate<BonusParameter> oParamsAll)
{
EmployeeSetupParameter empParameter = new EmployeeSetupParameter(EnumParameterSetup.Bonus);
ObjectsTemplate<BonusParameter> oParams = new ObjectsTemplate<BonusParameter>();
empParameter.Employee = employee;
empParameter.ParameterIDs = SetupManager.ApplicableParameters2(employee, EnumParameterSetup.Bonus, setupTypes, details);
for (int i = 0; i < empParameter.ParameterIDs.Count; i++)
{
BonusParameter param =oParamsAll.Find(x=>x.ID==ID.FromInteger(empParameter.ParameterIDs[i]));// BonusParameter.Get(ID.FromInteger(empParameter.ParameterIDs[i]));
if (param != null)
{
if (param.BonusID == nBonusID)
{
oParams.Add(param);
}
}
}
return oParams;
}
public static List<BonusParameter> GetApplicableParametersByGrade(Employee employee,
ID graId, ObjectsTemplate<BonusParameter> parameters)
{
List<BonusParameter> applicableParams = parameters.FindAll(delegate(BonusParameter param) { return IsApplicable(param, graId, employee); });
return applicableParams;
}
private static bool IsApplicable(BonusParameter param, ID graid, Employee employee)
{
bool isApplicable = false;
foreach (SetupDetail adgrade in param.SetupDetails)
{
if (adgrade.TranID.Integer == graid.Integer)
{
isApplicable = true;
}
}
if (!isApplicable) return false;
return true;
}
public static BonusParameter ApplicableParameters(ObjectsTemplate<BonusParameter> parameters, Employee employee)
{
List<int> paramerIDs = SetupManager.ApplicableParameters(employee, EnumParameterSetup.Bonus);
foreach (int i in paramerIDs)
{
foreach (BonusParameter param in parameters)
{
if (param.ID.Integer == i)
return param;
}
}
return null;
}
public EmployeeSetupParameter ApplicableParameters(Employee employee)
{
EmployeeSetupParameter empParameter = new EmployeeSetupParameter(EnumParameterSetup.Bonus);
empParameter.Employee = employee;
empParameter.ParameterIDs = SetupManager.ApplicableParameters(employee, EnumParameterSetup.Bonus);
return empParameter;
}
public List<EmployeeSetupParameter> ApplicableParameters(ObjectsTemplate<Employee> employees)
{
ObjectsTemplate<SetupDetail> details = SetupDetail.GetParameters(EnumParameterSetup.Bonus);
List<EnmSetupManagerTranType> types = SetupDetail.GetTypes(EnumParameterSetup.Bonus);
List<EmployeeSetupParameter> empParametes = new List<EmployeeSetupParameter>();
foreach (Employee emp in employees)
{
EmployeeSetupParameter empparameter = new EmployeeSetupParameter(EnumParameterSetup.Bonus);
empparameter.Employee = emp;
empparameter.ParameterIDs = SetupManager.ApplicableParameters(emp, EnumParameterSetup.Bonus,
types, details);
empParametes.Add(empparameter);
}
return empParametes;
}
public void FillMe(ID id)
{
BonusParameter bp = BonusParameter.Get(id);
this.BonusID = bp.BonusID;
this.NoOfBasic = bp.NoOfBasic;
this.NoOfDays = bp.NoOfDays;
this.NoOfEarnedBasic = bp.NoOfEarnedBasic;
this.FlatAmount = bp.FlatAmount;
this.ConfirmeRequired = bp.ConfirmeRequired;
this.PayrollTypeID = bp.PayrollTypeID;
this.CreatedBy = bp.CreatedBy;
this.CreatedDate = bp.CreatedDate;
this.ModifiedBy = bp.ModifiedBy;
this.ModifiedDate = bp.ModifiedDate;
this.SetID(bp.ID);
this.SetState(ObjectState.Saved);
}
#endregion
public double GeneralAmount(double basicSalary, double GrossSalary)
{
double nTotalBonus = 0.0;
nTotalBonus = this.FlatAmount + (GrossSalary * this.NoOfGross) + (basicSalary * this.NoOfBasic) + (GrossSalary * this.PercentOfGross / 100) + (basicSalary * this.NoOfEarnedBasic);
// nTotalBonus = nTotalBonus + ConvertToDailyRate(oEmp.BasicSalary, SalaryMonthDate) * oBParameter.NoOfDays + ConvertToDailyRate(oEmp.GrossSalary, SalaryMonthDate) * oBParameter.GrossOfDays;
return nTotalBonus;
}
public ObjectsTemplate<SetupDetail> GetSetupDetail(ID parmID)
{
if (this.ID != null && this.ID.IsUnassigned == false)
{
return BonusParameter.Service.GetSetupDetail(this.ID);
}
return null;
}
public static DataTable GetByBonusIDAndTranType(string bonusIDs, EnmSetupManagerTranType tranType)
{
return BonusParameter.Service.GetByBonusIDAndTranType(bonusIDs, tranType);
}
}
#endregion
#region IBonusParameter Service
public interface IBonusParameterService
{
BonusParameter Get(ID nBonusParamID);
BonusParameter GetByBonusID(ID nBonusID, ID PayrollTypeID);
ObjectsTemplate<BonusParameter> Get(EnumStatus status, ID PayrollTypeID);
ObjectsTemplate<BonusParameter> Get(ID nBonusID, ID PayrollTypeID);
ObjectsTemplate<BonusParameter.BonusServiceLength> GetSerLengthByBonus(ID bonusParamID);
ObjectsTemplate<BonusParameter.BonusSlab> GetSlabByBonus(ID bonusParamID);
ObjectsTemplate<BonusParameter.BonusParamSalaryItem> GetSalaryItemByBonus(ID bonusParamID);
ObjectsTemplate<BonusParameter.BonusParamAdjustItem> GetAdjustItemByBonus(ID bonusParamID);
ID Save(BonusParameter item);
void Delete(ID id);
ObjectsTemplate<SetupDetail> GetSetupDetail(ID parmID);
DataTable GetByBonusIDAndTranType(string bonusIDs, EnmSetupManagerTranType tranType);
}
#endregion
}