343 lines
12 KiB
C#
343 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Model;
|
|
|
|
namespace Payroll.BO
|
|
{
|
|
[Serializable]
|
|
public class GrossDefination : AuditTrailBase
|
|
{
|
|
public GrossDefination()
|
|
{
|
|
_salaryComponentType = EnumSalaryComponent.Basic;
|
|
_componentID = null;
|
|
}
|
|
|
|
#region Property SalaryComponentType : int
|
|
|
|
private EnumSalaryComponent _salaryComponentType;
|
|
public EnumSalaryComponent SalaryComponentType
|
|
{
|
|
get { return _salaryComponentType; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<short>("SalaryComponentType", (short)_salaryComponentType, (short)value);
|
|
_salaryComponentType = value;
|
|
}
|
|
}
|
|
|
|
#endregion Property SalaryComponentType : int
|
|
|
|
#region Property BenefitDefinationType : int
|
|
private EnumBenefitDefinationType _benefitDefinationType;
|
|
public EnumBenefitDefinationType BenefitDefinationType
|
|
{
|
|
get { return _benefitDefinationType; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<short>("BenefitDefinationType", (short)_benefitDefinationType, (short)value);
|
|
_benefitDefinationType = value;
|
|
}
|
|
}
|
|
#endregion Property BenefitDefinationType : int
|
|
|
|
#region Property ComponentID : ID
|
|
|
|
private ID _componentID;
|
|
public ID ComponentID
|
|
{
|
|
get { return _componentID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("ComponentID", _componentID, value);
|
|
_componentID = value;
|
|
}
|
|
}
|
|
|
|
#endregion Property ComponentID : ID
|
|
|
|
#region Property Quantity : int
|
|
|
|
private int _quantity;
|
|
|
|
public int Quantity
|
|
{
|
|
get { return _quantity; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<int>("Quantity", (short)_quantity, (int)value);
|
|
_quantity = value;
|
|
}
|
|
}
|
|
|
|
#endregion Property Quantity : int
|
|
|
|
#region Property Description : string
|
|
|
|
private string _description;
|
|
|
|
public string Description
|
|
{
|
|
get { return _description; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<string>("Description", _description, (string)value);
|
|
_description = value;
|
|
}
|
|
}
|
|
|
|
#endregion Property Quantity : int
|
|
|
|
#region Service Factory IGrossDefinationService : IGrossDefinationService
|
|
|
|
internal static IGrossDefinationService Service
|
|
{
|
|
get { return Services.Factory.CreateService<IGrossDefinationService>(typeof(IGrossDefinationService)); }
|
|
}
|
|
|
|
#endregion Service Factory IGrossDefinationService : IGrossDefinationService
|
|
|
|
#region Save Methods
|
|
public void Save()
|
|
{
|
|
try
|
|
{
|
|
GrossDefination.Service.Save(this);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
}
|
|
#endregion Save Methods
|
|
|
|
|
|
#region Get Methods
|
|
|
|
public GrossDefination Get(ID id)
|
|
{
|
|
GrossDefination grossDefination = new GrossDefination();
|
|
try
|
|
{
|
|
grossDefination = GrossDefination.Service.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return grossDefination;
|
|
}
|
|
|
|
public static ObjectsTemplate<GrossDefination> Get()
|
|
{
|
|
ObjectsTemplate<GrossDefination> grossDefinationColl = new ObjectsTemplate<GrossDefination>();
|
|
try
|
|
{
|
|
grossDefinationColl = GrossDefination.Service.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return grossDefinationColl;
|
|
}
|
|
|
|
public static ObjectsTemplate<GrossDefination> Get(EnumBenefitDefinationType definationType)
|
|
{
|
|
ObjectsTemplate<GrossDefination> grossDefinationColl = new ObjectsTemplate<GrossDefination>();
|
|
try
|
|
{
|
|
grossDefinationColl = GrossDefination.Service.Get(definationType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return grossDefinationColl;
|
|
}
|
|
|
|
#endregion Get Methods
|
|
|
|
|
|
#region Delete Methods
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
GrossDefination.Service.Delete(id);
|
|
}
|
|
|
|
#endregion Delete Methods
|
|
|
|
|
|
/// <summary>
|
|
/// Return the gross amount of the employee
|
|
/// </summary>
|
|
/// <param name="employee"></param>
|
|
/// <returns></returns>
|
|
public double GetGross(Employee oemployee)
|
|
{
|
|
ObjectsTemplate<GrossDefination> grossDefinations = GrossDefination.Get();
|
|
ObjectsTemplate<ADParameter> adparamters = ADParameter.Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance);
|
|
ObjectsTemplate<BonusParameter> bonusParamters = BonusParameter.Get(EnumStatus.Regardless);
|
|
ObjectsTemplate<Bonus> bonuses = Bonus.Get(EnumStatus.Regardless);
|
|
double GrossAmount = 0;
|
|
foreach (GrossDefination gd in grossDefinations)
|
|
{
|
|
switch (gd.SalaryComponentType)
|
|
{
|
|
case EnumSalaryComponent.Basic:
|
|
// basic salary is monthly, so we are multipliying by 12
|
|
GrossAmount = GrossAmount + oemployee.BasicSalary * 12;
|
|
|
|
break;
|
|
case EnumSalaryComponent.Allowance:
|
|
ADParameter param = ADParameter.GetApplicableParameter(
|
|
oemployee, oemployee.GradeID, adparamters, gd.ComponentID);
|
|
if (param == null) continue;
|
|
switch (param.Periodicity)
|
|
{
|
|
case EnumPeriodicity.Monthly:
|
|
// Allowance is monthly, so we are multipliying by 12
|
|
GrossAmount = GrossAmount + param.CalculateAmount(oemployee) * 12;
|
|
break;
|
|
case EnumPeriodicity.OneOff:
|
|
// allowance is onceoff and paid once in year
|
|
GrossAmount = GrossAmount + param.CalculateAmount(oemployee);
|
|
break;
|
|
case EnumPeriodicity.RegardLess:
|
|
case EnumPeriodicity.Schedule:
|
|
case EnumPeriodicity.Periodic:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case EnumSalaryComponent.Bonus:
|
|
// annual bonus , so we are not multipling 12
|
|
BonusParameter bparamter = BonusParameter.ApplicableParameters(bonusParamters, oemployee, gd.ComponentID);
|
|
if (bparamter != null)
|
|
{
|
|
BonusCalculator ocal = new BonusCalculator();
|
|
GrossAmount = GrossAmount + 3 * oemployee.BasicSalary; //ocal.GeneralAmount(odetail.Employee, bparamter, opiMonth);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return GrossAmount;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the gross amount of the multiple employees
|
|
/// </summary>
|
|
/// <param name="employees"></param>
|
|
/// <returns></returns>
|
|
public Dictionary<int, double> GetGross(ObjectsTemplate<Employee> oemployees)
|
|
{
|
|
ObjectsTemplate<GrossDefination> grossDefinations = GrossDefination.Get();
|
|
ObjectsTemplate<ADParameter> adparamters = ADParameter.Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance);
|
|
ObjectsTemplate<BonusParameter> bonusParamters = BonusParameter.Get(EnumStatus.Regardless);
|
|
ObjectsTemplate<Bonus> bonuses = Bonus.Get(EnumStatus.Regardless);
|
|
double GrossAmount = 0;
|
|
Dictionary<int, double> empGross = new Dictionary<int, double>();
|
|
|
|
foreach (Employee oemployee in oemployees)
|
|
{
|
|
GrossAmount = 0;
|
|
foreach (GrossDefination gd in grossDefinations)
|
|
{
|
|
#region switch case
|
|
switch (gd.SalaryComponentType)
|
|
{
|
|
case EnumSalaryComponent.Basic:
|
|
// basic salary is monthly, so we are multipliying by 12
|
|
GrossAmount = GrossAmount + oemployee.BasicSalary * 12;
|
|
|
|
break;
|
|
case EnumSalaryComponent.Allowance:
|
|
ADParameter param = ADParameter.GetApplicableParameter(
|
|
oemployee, oemployee.GradeID, adparamters, gd.ComponentID);
|
|
if (param == null) continue;
|
|
switch (param.Periodicity)
|
|
{
|
|
case EnumPeriodicity.Monthly:
|
|
// Allowance is monthly, so we are multipliying by 12
|
|
GrossAmount = GrossAmount + param.CalculateAmount(oemployee) * 12;
|
|
break;
|
|
case EnumPeriodicity.OneOff:
|
|
// allowance is onceoff and paid once in year, so we are multipliying by 12
|
|
GrossAmount = GrossAmount + param.CalculateAmount(oemployee);
|
|
break;
|
|
case EnumPeriodicity.RegardLess:
|
|
case EnumPeriodicity.Schedule:
|
|
case EnumPeriodicity.Periodic:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case EnumSalaryComponent.Bonus:
|
|
// annual bonus , so we are not multipling 12
|
|
BonusParameter bparamter = BonusParameter.ApplicableParameters(bonusParamters, oemployee, gd.ComponentID);
|
|
if (bparamter != null)
|
|
{
|
|
BonusCalculator ocal = new BonusCalculator();
|
|
GrossAmount = GrossAmount + 3 * oemployee.BasicSalary; //ocal.GeneralAmount(odetail.Employee, bparamter, opiMonth);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endregion switch case
|
|
|
|
}
|
|
empGross.Add(oemployee.ID.Integer, GrossAmount);
|
|
}
|
|
return empGross;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public interface IGrossDefinationService
|
|
{
|
|
GrossDefination Get(ID id);
|
|
ObjectsTemplate<GrossDefination> Get();
|
|
ObjectsTemplate<GrossDefination> Get(EnumBenefitDefinationType definationType);
|
|
void Save(GrossDefination grossDefination);
|
|
void Delete(ID id);
|
|
}
|
|
}
|