CEL_Payroll/Payroll.BO/CarFuel/CarFuelParameter.cs
2024-09-17 14:30:13 +06:00

1061 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 CarFuelParameter
[Serializable]
public class CarFuelParameter : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(CarFuelParameter));
#endregion
#region Constructor
public CarFuelParameter()
{
_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;
_CarFuelItemID = null;
_CarFuelParameterGrades = null;
_CarFuelParameterIndividuals = null;
_CarFuelPeriodicity = EnumCarFuelPeriodicity.OnceOff;
_CarFuelType = EnumCarFuelType.Provision;
_percentOfBasic = 0.0;
_percentOfGross = 0.0;
_entitleType = EnumEntitleType.Grade;
_CarFuelAvgPayType = EnumCarFuelAvgPayType.NONE;
_CarFuelAvgPayItemID = null;
_nNoOfMonth = 0;
_payrollTypeID = SystemInformation.CurrentSysInfo.PayrollTypeID;
}
#endregion
#region Properties
#region CarFuelType : EnumCarFuelType
private EnumCarFuelType _CarFuelType;
public EnumCarFuelType CarFuelType
{
get { return _CarFuelType; }
set
{
base.OnPropertyChange<short>("CarFueltype", (short)_CarFuelType, (short)value);
_CarFuelType = 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 payrollTypeID : ID
private ID _payrollTypeID;
public ID PayrollTypeID
{
get { return _payrollTypeID; }
set
{
base.OnPropertyChange<ID>("payrollTypeID", _payrollTypeID, value);
_payrollTypeID = 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 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 CarFuelItemID : ID
private ID _CarFuelItemID;
public ID CarFuelItemID
{
get
{
return _CarFuelItemID;
}
set
{
base.OnPropertyChange<ID>("CarFuelitemid", _CarFuelItemID, value);
_CarFuelItemID = value;
}
}
#endregion
#region CarFuelPeriodicity : EnumCarFuelPeriodicity
private EnumCarFuelPeriodicity _CarFuelPeriodicity;
public EnumCarFuelPeriodicity CarFuelPeriodicity
{
get
{
return _CarFuelPeriodicity;
}
set
{
base.OnPropertyChange<short>("CarFuelperiodicity", (short)_CarFuelPeriodicity, (short)value);
_CarFuelPeriodicity = 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 CarFuelAvgPayType : EnumCarFuelAvgPayType
private EnumCarFuelAvgPayType _CarFuelAvgPayType;
public EnumCarFuelAvgPayType CarFuelAvgPayType
{
get
{
return _CarFuelAvgPayType;
}
set
{
base.OnPropertyChange<short>("CarFuelAvgPayType", (short)_CarFuelAvgPayType, (short)value);
_CarFuelAvgPayType = value;
}
}
#endregion
#region CarFuelAvgPayItemID : ID
private ID _CarFuelAvgPayItemID;
public ID CarFuelAvgPayItemID
{
get
{
return _CarFuelAvgPayItemID;
}
set
{
base.OnPropertyChange<ID>("CarFuelAvgPayItemID", _CarFuelAvgPayItemID, value);
_CarFuelAvgPayItemID = 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 CarFuelParameterGrades : ObjectsTemplate<CarFuelParameterGrade>
private ObjectsTemplate<CarFuelParameterGrade> _CarFuelParameterGrades;
public ObjectsTemplate<CarFuelParameterGrade> CarFuelParameterGrades
{
get
{
if (_CarFuelParameterGrades == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_CarFuelParameterGrades = CarFuelParameter.GetGrades(this.ID);
}
return this._CarFuelParameterGrades;
}
set
{
_CarFuelParameterGrades = value;
}
}
#endregion
#region CarFuelParameterIndividuals : ObjectsTemplate<CarFuelParameterIndividual>
private ObjectsTemplate<CarFuelParameterIndividual> _CarFuelParameterIndividuals;
public ObjectsTemplate<CarFuelParameterIndividual> CarFuelParameterIndividuals
{
get
{
if (_CarFuelParameterIndividuals == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_CarFuelParameterIndividuals = CarFuelParameterIndividual.GetByParameterID(this.ID);
}
else if (_CarFuelParameterIndividuals == null)
{
_CarFuelParameterIndividuals = new ObjectsTemplate<CarFuelParameterIndividual>();
}
return this._CarFuelParameterIndividuals;
}
set
{
_CarFuelParameterIndividuals = value;
}
}
#endregion
#region CarFuelItem : CarFuelItem
private CarFuelItem _CarFuelItem;
public CarFuelItem CarFuelItem
{
get
{
if (_CarFuelItemID.Integer > 0 && _CarFuelItem == null)
{
_CarFuelItem = new CarFuelItem();
_CarFuelItem = CarFuelItem.Get(_CarFuelItemID);
}
return this._CarFuelItem;
}
set
{
_CarFuelItem = value;
}
}
#endregion
//#region NotApplicable : CarFuelParameterIndividual
//private ObjectsTemplate<CarFuelParameterIndividual> _NotApplicable = null;
//public ObjectsTemplate<CarFuelParameterIndividual> NotApplicable
//{
// get
// {
// if (_NotApplicable == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _NotApplicable = CarFuelParameterIndividual.GetIndividuals(this.ID, EnumCarFuelIndivdualType.NotApplicable);
// }
// return this._NotApplicable;
// }
//}
//#endregion
#region NoOfAplicableEmp : int
private int _noOfemployee;
public int NoOfAplicableEmp
{
get
{
if (_noOfemployee <= 0)
{
string gradeIDs = string.Empty;
foreach (CarFuelParameterGrade pGrade in this.CarFuelParameterGrades)
{
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 CarFuelParameter Get(ID nCarFuelParameterID)
{
CarFuelParameter oCarFuelParameter = null;
#region Cache Header
oCarFuelParameter = (CarFuelParameter)_cache["Get", nCarFuelParameterID];
if (oCarFuelParameter != null)
return oCarFuelParameter;
#endregion
oCarFuelParameter = CarFuelParameter.Service.Get(nCarFuelParameterID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
#region Cache Footer
_cache.Add(oCarFuelParameter, "Get", nCarFuelParameterID);
#endregion
return oCarFuelParameter;
}
public static ObjectsTemplate<CarFuelParameter> Get()
{
#region Cache Header
ObjectsTemplate<CarFuelParameter> CarFuelParameters = _cache["Get"] as ObjectsTemplate<CarFuelParameter>;
if (CarFuelParameters != null)
return CarFuelParameters;
#endregion
try
{
CarFuelParameters = Service.Get(Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(CarFuelParameters, "Get");
#endregion
return CarFuelParameters;
}
public static ObjectsTemplate<CarFuelParameterGrade> GetGrades(ID CarFuelParameterID)
{
#region Cache Header
ObjectsTemplate<CarFuelParameterGrade> oGrades = _cache["Get", CarFuelParameterID] as ObjectsTemplate<CarFuelParameterGrade>;
if (oGrades != null)
return oGrades;
#endregion
try
{
oGrades = Service.GetGrades(CarFuelParameterID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oGrades, "Get", CarFuelParameterID);
#endregion
return oGrades;
}
public static ObjectsTemplate<CarFuelParameter> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<CarFuelParameter> CarFuelParameters = _cache["Get", status] as ObjectsTemplate<CarFuelParameter>;
if (CarFuelParameters != null)
return CarFuelParameters;
#endregion
try
{
CarFuelParameters = Service.Get(status,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(CarFuelParameters, "Get", status);
#endregion
return CarFuelParameters;
}
public static ObjectsTemplate<CarFuelParameter> Get(EnumStatus status, EnumCarFuelType type)
{
#region Cache Header
ObjectsTemplate<CarFuelParameter> CarFuelParameters = _cache["Get", status, type] as ObjectsTemplate<CarFuelParameter>;
if (CarFuelParameters != null)
return CarFuelParameters;
#endregion
try
{
CarFuelParameters = Service.Get(status, type,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(CarFuelParameters, "Get", status, type);
#endregion
return CarFuelParameters;
}
public ID Save()
{
this.SetAuditTrailProperties();
return CarFuelParameter.Service.Save(this,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
public void Delete()
{
CarFuelParameter.Service.Delete(ID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
#region Exception : ADParameterEmployee
private ObjectsTemplate<CarFuelParameterIndividual > _Exception = null;
public ObjectsTemplate<CarFuelParameterIndividual> Exception
{
get
{
if (_Exception == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_Exception = CarFuelParameterIndividual.GetIndividuals(this.ID, EnumCarFuelIndivdualType.Exception);
}
return this._Exception;
}
}
#endregion
#region NotApplicable : ADParameterEmployee
private ObjectsTemplate<CarFuelParameterIndividual> _NotApplicable = null;
public ObjectsTemplate<CarFuelParameterIndividual> NotApplicable
{
get
{
if (_NotApplicable == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_NotApplicable = CarFuelParameterIndividual.GetIndividuals(this.ID, EnumCarFuelIndivdualType.NotApplicable);
}
return this._NotApplicable;
}
}
#endregion
public static List<CarFuelParameter> GetApplicableParameters(Employee employee,
ID graId, ObjectsTemplate<CarFuelParameter> parameters)
{
List<CarFuelParameter> applicableParams = parameters.FindAll(delegate(CarFuelParameter param) { return IsApplicable(param, graId, employee); });
return applicableParams;
}
private static bool IsApplicable(CarFuelParameter param, ID graid, Employee employee)
{
bool isApplicable = false;
foreach (CarFuelParameterGrade adgrade in param.CarFuelParameterGrades)
{
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, EmployeeGradeSalary gradeSalary)
{
return this.GetGradeDefinedAmount(employee, gradeSalary.BasicSalary, gradeSalary.GrossSalary, gradeSalary.FractionofFromTo);
}
public double GetGradeDefinedAmount(Employee employee, double basicSalary,
double grossSalary, double fractionate)
{
CarFuelParameterIndividual CarFuelIndividual = 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 + (basicSalary * this.PercentOfBasic * fractionate) / 100.0;
else
nAmount = nAmount + ((basicSalary * this.PercentOfBasic / 100.0) * fractionate);
else
nAmount = this.FlatAmount * fractionate;
if (this.NotApplicable.Exists(delegate(CarFuelParameterIndividual adEmployee) { return adEmployee.EmployeeId.Integer == employee.ID.Integer; }))
{
nAmount = 0;
}
else
{
CarFuelParameterIndividual adEmp = this.Exception.Find(delegate(CarFuelParameterIndividual 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,
CarFuelParameterIndividual ademployee)
{
return GetIndividualAmount(employee, fortheMonth,
ademployee, employee.BasicSalary, employee.GrossSalary);
}
public double GetIndividualAmount(Employee employee, DateTime fortheMonth,
CarFuelParameterIndividual 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.CarFuelPeriodicity != EnumCarFuelPeriodicity.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<CarFuelParameter> ApplicableParameters(Employee emlpoyee,
CarFuelProcessDetail oprocdetail, ObjectsTemplate<CarFuelParameter> allCarFuelParameters,
ObjectsTemplate<EmployeeGradeSalary> gradeSalaries)
{
ObjectsTemplate<CarFuelParameter> oparameters = new ObjectsTemplate<CarFuelParameter>();
foreach (EmployeeGradeSalary gs in gradeSalaries)
{
List<CarFuelParameter> lparameter = CarFuelParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allCarFuelParameters);
foreach (CarFuelParameter item in lparameter)
{
if (oparameters.Contains(item) == false)
oparameters.Add(item);
}
}
return oparameters;
//foreach (EmployeeGradeSalary gs in oprocdetail.ArrearGradeSalaries)
//{
// List<CarFuelParameter> alparameter = CarFuelParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allCarFuelParameters);
// gs.CarFuelParameters = new ObjectsTemplate<CarFuelParameter>();
// foreach (CarFuelParameter item in alparameter)
// gs.CarFuelParameters.Add(item);
//}
//foreach (EmployeeGradeSalary gs in oprocdetail.ArrearPaidGradeSalaries)
//{
// List<CarFuelParameter> aplparameter = CarFuelParameter.GetApplicableParameters(emlpoyee, gs.GradeID, allCarFuelParameters);
// gs.CarFuelParameters = new ObjectsTemplate<CarFuelParameter>();
// foreach (CarFuelParameter item in aplparameter)
// gs.CarFuelParameters.Add(item);
//}
}
public static ObjectsTemplate<CarFuelParameterGrade> GetGrades()
{
return CarFuelParameter.Service.GetGrades(Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
internal static ObjectsTemplate<CarFuelParameter> Get(EnumStatus enumStatus, EnumCarFuelType enumCarFuelType, EnumEntitleType enumEntitleType)
{
#region Cache Header
ObjectsTemplate<CarFuelParameter> CarFuelitems = _cache["Get", enumStatus, enumCarFuelType, enumEntitleType] as ObjectsTemplate<CarFuelParameter>;
if (CarFuelitems != null)
return CarFuelitems;
#endregion
try
{
CarFuelitems = Service.Get(enumStatus, enumCarFuelType, enumEntitleType,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(CarFuelitems, "Get", enumStatus, enumCarFuelType, enumEntitleType);
#endregion
return CarFuelitems;
}
internal static ObjectsTemplate<CarFuelParameter> Get(EnumStatus enumStatus,EnumEntitleType enumEntitleType)
{
#region Cache Header
ObjectsTemplate<CarFuelParameter> CarFuelitems = _cache["Get", enumStatus, enumEntitleType] as ObjectsTemplate<CarFuelParameter>;
if (CarFuelitems != null)
return CarFuelitems;
#endregion
try
{
CarFuelitems = Service.Get(enumStatus, enumEntitleType,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(CarFuelitems, "Get", enumStatus, enumEntitleType);
#endregion
return CarFuelitems;
}
#endregion
#region Service Factory
internal static ICarFuelParameterService Service
{
get
{
return Services.Factory.CreateService<ICarFuelParameterService>(typeof(ICarFuelParameterService));
}
}
#endregion
}
#endregion
#region ICarFuelParameter Service
public interface ICarFuelParameterService
{
CarFuelParameter Get(ID id, int payrollTypeID);
ObjectsTemplate<CarFuelParameter> Get(int payrollTypeID);
ObjectsTemplate<CarFuelParameterGrade> GetGrades(ID CarFuelParameterID, int payrollTypeID);
ObjectsTemplate<CarFuelParameterGrade> GetGrades(int payrollTypeID);
ObjectsTemplate<CarFuelParameter> Get(EnumStatus status, int payrollTypeID);
ObjectsTemplate<CarFuelParameter> Get(EnumStatus status, EnumCarFuelType type, int payrollTypeID);
ObjectsTemplate<CarFuelParameter> Get(EnumStatus enumStatus, EnumCarFuelType enumCarFuelType, EnumEntitleType enumEntitleType, int payrollTypeID);
ObjectsTemplate<CarFuelParameter> Get(EnumStatus enumStatus, EnumEntitleType enumEntitleType, int payrollTypeID);
ID Save(CarFuelParameter oCarFuelParameter, int payrollTypeID);
void Delete(ID id, int payrollTypeID);
}
#endregion
}