617 lines
18 KiB
C#
617 lines
18 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Caching;
|
|
using Ease.CoreV35.Model;
|
|
|
|
namespace Payroll.BO
|
|
{
|
|
#region BudgetComponent BaseObject
|
|
[Serializable]
|
|
public class BudgetComponent : BasicBaseObject
|
|
{
|
|
#region Cache Store
|
|
private static Cache _cache = new Cache(typeof(BudgetComponent));
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public BudgetComponent()
|
|
{
|
|
_basedOn = EnumBasedOnPercent.None;
|
|
_budgetID = null;
|
|
_componentType = EnumBudgetComponent.None;
|
|
_flatAmount = 0;
|
|
_name = string.Empty;
|
|
_originID = null;
|
|
_parameterID = null;
|
|
_percentage = 0;
|
|
_periodicity = 0;
|
|
_taxable = false;
|
|
_payrollTypeID = null;
|
|
|
|
#region Child Variables
|
|
|
|
_oBudgetComponentIndivisuals = null;
|
|
_oBudgetComponentGrades = null;
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region Parent Properties
|
|
|
|
#region BasedOn : EnumBasedOnPercent
|
|
private EnumBasedOnPercent _basedOn;
|
|
public EnumBasedOnPercent BasedOn
|
|
{
|
|
get { return _basedOn; }
|
|
set { _basedOn = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region BudgetID : ID
|
|
private ID _budgetID;
|
|
public ID BudgetID
|
|
{
|
|
get { return _budgetID; }
|
|
set { _budgetID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region PayrollTypeID : ID
|
|
private ID _payrollTypeID;
|
|
public ID PayrollTypeID
|
|
{
|
|
get { return _payrollTypeID; }
|
|
set { _payrollTypeID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region ComponentType : EnumBudgetComponent
|
|
private EnumBudgetComponent _componentType;
|
|
public EnumBudgetComponent ComponentType
|
|
{
|
|
get { return _componentType; }
|
|
set { _componentType = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region FlatAmount : double
|
|
private double _flatAmount;
|
|
public double FlatAmount
|
|
{
|
|
get { return _flatAmount; }
|
|
set { _flatAmount = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Name : string
|
|
private string _name;
|
|
public string Name
|
|
{
|
|
get { return _name; }
|
|
set { _name = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region OriginID : ID
|
|
private ID _originID;
|
|
public ID OriginID
|
|
{
|
|
get { return _originID; }
|
|
set { _originID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region ParameterID : ID
|
|
private ID _parameterID;
|
|
public ID ParameterID
|
|
{
|
|
get { return _parameterID; }
|
|
set { _parameterID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Percentage : double
|
|
private double _percentage;
|
|
public double Percentage
|
|
{
|
|
get { return _percentage; }
|
|
set { _percentage = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Periodicity : double
|
|
private double _periodicity;
|
|
public double Periodicity
|
|
{
|
|
get { return _periodicity; }
|
|
set { _periodicity = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Taxable : bool
|
|
private bool _taxable;
|
|
public bool Taxable
|
|
{
|
|
get { return _taxable; }
|
|
set { _taxable = value; }
|
|
}
|
|
#endregion
|
|
#region IndivisuallyDefined : bool
|
|
private bool _indivisuallyDefined;
|
|
public bool IndivisuallyDefined
|
|
{
|
|
get { return _indivisuallyDefined; }
|
|
set { _indivisuallyDefined = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region allowanceDeduction : AllowanceDeduction
|
|
|
|
private AllowanceDeduction _allowanceDeduction;
|
|
public AllowanceDeduction AllowanceDeduction
|
|
{
|
|
get
|
|
{
|
|
if (_originID.Integer > 0 && _allowanceDeduction == null)
|
|
{
|
|
_allowanceDeduction = new AllowanceDeduction();
|
|
_allowanceDeduction = AllowanceDeduction.Get(_originID);
|
|
}
|
|
return this._allowanceDeduction;
|
|
}
|
|
set
|
|
{
|
|
_allowanceDeduction = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Child Properties
|
|
|
|
#region BudgetComponentIndivisual Property
|
|
private ObjectsTemplate<BudgetComponentIndivisual> _oBudgetComponentIndivisuals;
|
|
public ObjectsTemplate<BudgetComponentIndivisual> OBudgetComponentIndivisuals
|
|
{
|
|
get
|
|
{
|
|
if (_oBudgetComponentIndivisuals == null)
|
|
{
|
|
//_oBudgetComponentIndivisuals = new ObjectsTemplate<BudgetComponentIndivisual>();
|
|
//if (!this.ID.IsUnassigned && _oBudgetComponentIndivisuals.Count>=0)
|
|
//{
|
|
// if (this.ID.Integer > 0)
|
|
// _oBudgetComponentIndivisuals = Service.GetBudgetComponentIndivisuals(this.ID);
|
|
//}
|
|
_oBudgetComponentIndivisuals = new ObjectsTemplate<BudgetComponentIndivisual>();
|
|
}
|
|
return _oBudgetComponentIndivisuals;
|
|
}
|
|
set { _oBudgetComponentIndivisuals = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region BudgetComponentGrade Property
|
|
private ObjectsTemplate<BudgetComponentGrade> _oBudgetComponentGrades;
|
|
public ObjectsTemplate<BudgetComponentGrade> OBudgetComponentGrades
|
|
{
|
|
get
|
|
{
|
|
if (_oBudgetComponentGrades == null)
|
|
{
|
|
_oBudgetComponentGrades = new ObjectsTemplate<BudgetComponentGrade>();
|
|
//if (!this.ID.IsUnassigned)
|
|
// _oBudgetComponentGrades = Service.GetBudgetComponentGrades(this.ID);
|
|
}
|
|
return _oBudgetComponentGrades;
|
|
}
|
|
set { _oBudgetComponentGrades = value; }
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
public double CalculateAmount(Employee oEmp)
|
|
{
|
|
double amount = 0;
|
|
|
|
switch (_basedOn)
|
|
{
|
|
case EnumBasedOnPercent.None:
|
|
break;
|
|
case EnumBasedOnPercent.Basic:
|
|
amount = this.FlatAmount + (this.Percentage * oEmp.BasicSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Base:
|
|
amount = 0;//(this.Percentage * oEmp.GrossSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Gross:
|
|
amount = this.FlatAmount + (this.Percentage * oEmp.GrossSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Fixed_Amount:
|
|
amount = this.FlatAmount;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return amount;
|
|
}
|
|
public double CalculateExceptionAmount(Employee oEmp, DateTime processMonth)
|
|
{
|
|
double amount = 0;
|
|
|
|
switch (_basedOn)
|
|
{
|
|
case EnumBasedOnPercent.None:
|
|
break;
|
|
case EnumBasedOnPercent.Basic:
|
|
if (this.IndivisuallyDefined)
|
|
{
|
|
amount = GetIndvAmt(processMonth, oEmp.BasicSalary);
|
|
}
|
|
if(amount==0)
|
|
amount = this.FlatAmount + (this.Percentage * oEmp.BasicSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Base:
|
|
amount = 0;//(this.Percentage * oEmp.GrossSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Gross:
|
|
if (this.IndivisuallyDefined)
|
|
{
|
|
amount = GetIndvAmt(processMonth, oEmp.GrossSalary);
|
|
}
|
|
if (amount == 0)
|
|
amount = this.FlatAmount + (this.Percentage * oEmp.GrossSalary) / 100;
|
|
break;
|
|
case EnumBasedOnPercent.Fixed_Amount:
|
|
amount = this.FlatAmount;
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
}
|
|
if (!this.IndivisuallyDefined)
|
|
{
|
|
if(GetExceptionAmt(oEmp)!=0)
|
|
amount = GetExceptionAmt(oEmp);
|
|
if (GetNotAppAmt(oEmp) != null)
|
|
amount = 0;
|
|
}
|
|
return amount;
|
|
}
|
|
private double GetIndvAmt(DateTime dMonth,double nAmount)
|
|
{
|
|
double amount = 0.0;
|
|
BudgetComponentIndivisual budIndv = this.OBudgetComponentIndivisuals.Find(delegate(BudgetComponentIndivisual item) { return item.FromDate.Date >= dMonth.Date && item.ToDate.Date <= dMonth.Date && item.DetailType == EnumADEmpType.AppliedToIndividual; });
|
|
if (budIndv != null)
|
|
{
|
|
if (budIndv.ValueType == EnumValueType.Amount)
|
|
{
|
|
amount = budIndv.Amount;
|
|
}
|
|
else
|
|
{
|
|
amount = (budIndv.Amount * nAmount) / 100;
|
|
}
|
|
}
|
|
return amount;
|
|
}
|
|
private double GetExceptionAmt(Employee oEmp)
|
|
{
|
|
double amount = 0.0;
|
|
BudgetComponentIndivisual budIndv = this.OBudgetComponentIndivisuals.Find(delegate(BudgetComponentIndivisual item) { return item.EmployeeID==oEmp.ID && item.DetailType==EnumADEmpType.Exception; });
|
|
if (budIndv != null)
|
|
{
|
|
if (budIndv.ValueType == EnumValueType.Amount)
|
|
{
|
|
amount = budIndv.Amount;
|
|
}
|
|
else
|
|
{
|
|
amount = (oEmp.BasicSalary * budIndv.Amount) / 100;
|
|
}
|
|
}
|
|
return amount;
|
|
}
|
|
private BudgetComponentIndivisual GetNotAppAmt(Employee oEmp)
|
|
{
|
|
BudgetComponentIndivisual budIndv = this.OBudgetComponentIndivisuals.Find(delegate(BudgetComponentIndivisual item) { return item.EmployeeID == oEmp.ID && item.DetailType == EnumADEmpType.NotApplicable; });
|
|
return budIndv;
|
|
}
|
|
|
|
#region Function(s)
|
|
|
|
#region Get
|
|
|
|
public static BudgetComponent Get(ID nID)
|
|
{
|
|
BudgetComponent oBudgetComponent = null;
|
|
#region Cache Header
|
|
oBudgetComponent = (BudgetComponent)_cache["Get", nID];
|
|
if (oBudgetComponent != null)
|
|
return oBudgetComponent;
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
oBudgetComponent = Service.Get(nID);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
#region Cache Footer
|
|
_cache.Add(oBudgetComponent, "Get", nID);
|
|
#endregion
|
|
return oBudgetComponent;
|
|
}
|
|
|
|
public static ObjectsTemplate<BudgetComponent> Get()
|
|
{
|
|
|
|
#region Cache Header
|
|
ObjectsTemplate<BudgetComponent> oBudgetComponents = _cache["Get"] as ObjectsTemplate<BudgetComponent>;
|
|
if (oBudgetComponents != null)
|
|
return oBudgetComponents;
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
oBudgetComponents = Service.Get();
|
|
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oBudgetComponents, "Get");
|
|
#endregion
|
|
|
|
return oBudgetComponents;
|
|
}
|
|
public static ObjectsTemplate<BudgetComponent> Get(int BudgetID)
|
|
{
|
|
|
|
#region Cache Header
|
|
ObjectsTemplate<BudgetComponent> oBudgetComponents = _cache["Get"] as ObjectsTemplate<BudgetComponent>;
|
|
if (oBudgetComponents != null)
|
|
return oBudgetComponents;
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
oBudgetComponents = Service.Get(BudgetID);
|
|
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oBudgetComponents, "Get");
|
|
#endregion
|
|
|
|
return oBudgetComponents;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Save
|
|
public ID Save()
|
|
{
|
|
//SetAuditTrailProperties();
|
|
return Service.Save(this);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete
|
|
public void Delete(ID id)
|
|
{
|
|
Service.Delete(id);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Service Factory
|
|
|
|
internal static IBudgetComponentService Service
|
|
{
|
|
get { return Services.Factory.CreateService<IBudgetComponentService>(typeof(IBudgetComponentService)); }
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region child Objects
|
|
|
|
#region BudgetComponentIndivisual
|
|
[Serializable]
|
|
public class BudgetComponentIndivisual : ObjectTemplate
|
|
{
|
|
#region Cache Store
|
|
private static Cache _cache = new Cache(typeof(BudgetComponentIndivisual));
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public BudgetComponentIndivisual()
|
|
{
|
|
_amount = 0;
|
|
_budgetComponentID = null;
|
|
_employeeID = null;
|
|
_detailType = EnumADEmpType.AppliedToIndividual;
|
|
_fromDate = DateTime.MinValue;
|
|
_toDate = DateTime.MinValue;
|
|
_valueType = EnumValueType.Amount;
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region Amount : double
|
|
private double _amount;
|
|
public double Amount
|
|
{
|
|
get { return _amount; }
|
|
set { _amount = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region BudgetComponentID : ID
|
|
private ID _budgetComponentID;
|
|
public ID BudgetComponentID
|
|
{
|
|
get { return _budgetComponentID; }
|
|
set { _budgetComponentID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region DetailType : EnumBudgetDetailType
|
|
private EnumADEmpType _detailType;
|
|
public EnumADEmpType DetailType
|
|
{
|
|
get { return _detailType; }
|
|
set { _detailType = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region EmployeeID : ID
|
|
private ID _employeeID;
|
|
public ID EmployeeID
|
|
{
|
|
get { return _employeeID; }
|
|
set { _employeeID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region FromDate : DateTime
|
|
private DateTime _fromDate;
|
|
public DateTime FromDate
|
|
{
|
|
get { return _fromDate; }
|
|
set { _fromDate = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region ToDate : DateTime
|
|
private DateTime _toDate;
|
|
public DateTime ToDate
|
|
{
|
|
get { return _toDate; }
|
|
set { _toDate = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region ValueType : EnumValueType
|
|
private EnumValueType _valueType;
|
|
public EnumValueType ValueType
|
|
{
|
|
get { return _valueType; }
|
|
set { _valueType = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Employee : Employee
|
|
|
|
private Employee _employee;
|
|
public Employee Employee
|
|
{
|
|
get
|
|
{
|
|
if (_employeeID != null)
|
|
{
|
|
if (_employee == null && !_employeeID.IsUnassigned)
|
|
{
|
|
_employee = new Employee();
|
|
_employee = Employee.Get(_employeeID);
|
|
}
|
|
}
|
|
return this._employee;
|
|
}
|
|
set
|
|
{
|
|
_employee = value;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region BudgetComponentGrade
|
|
[Serializable]
|
|
public class BudgetComponentGrade : ObjectTemplate
|
|
{
|
|
#region Cache Store
|
|
private static Cache _cache = new Cache(typeof(BudgetComponentGrade));
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public BudgetComponentGrade()
|
|
{
|
|
_budgetComponentID = null;
|
|
_gradeID = null;
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region BudgetComponentID : ID
|
|
private ID _budgetComponentID;
|
|
public ID BudgetComponentID
|
|
{
|
|
get { return _budgetComponentID; }
|
|
set { _budgetComponentID = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region GradeID : ID
|
|
private ID _gradeID;
|
|
public ID GradeID
|
|
{
|
|
get { return _gradeID; }
|
|
set { _gradeID = value; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region IBudgetComponentService
|
|
public interface IBudgetComponentService
|
|
{
|
|
#region parent's function definition
|
|
BudgetComponent Get(ID nID);
|
|
ObjectsTemplate<BudgetComponent> Get();
|
|
ObjectsTemplate<BudgetComponent> Get(int BudgetID);
|
|
ID Save(BudgetComponent item);
|
|
void Delete(ID nID);
|
|
#endregion
|
|
|
|
#region child's function Definition
|
|
ObjectsTemplate<BudgetComponentIndivisual> GetBudgetComponentIndivisuals(ID id);
|
|
ObjectsTemplate<BudgetComponentGrade> GetBudgetComponentGrades(ID id);
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
}
|