392 lines
20 KiB
C#
392 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace HRM.BO
|
|
{
|
|
public class GrossDefination : AuditTrailBase
|
|
{
|
|
public GrossDefination()
|
|
{
|
|
SalaryComponentType = EnumSalaryComponent.Basic;
|
|
ComponentID = 0;
|
|
}
|
|
|
|
public EnumSalaryComponent SalaryComponentType { get; set; }
|
|
public int ComponentID { get; set; }
|
|
public EnumBenefitDefinationType BenefitDefinationType { get; set; }
|
|
|
|
public int Quantity { get; set; }
|
|
public string Description { get; set; }
|
|
|
|
|
|
//#region Service Factory IGrossDefinationService : IGrossDefinationService
|
|
|
|
//internal static IGrossDefinationService Service
|
|
//{
|
|
// get { return Services.Factory.CreateService<IGrossDefinationService>(typeof(IGrossDefinationService)); }
|
|
//}
|
|
|
|
//#endregion Service Factory IGrossDefinationService : IGrossDefinationService
|
|
|
|
|
|
//public static double GetGross(Employee oemployee)
|
|
//{
|
|
// List<GrossDefination> grossDefinations = GrossDefination.Get();
|
|
// List<ADParameter> adparamters = ADParameter.Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance);
|
|
// List<BonusParameter> bonusParamters = BonusParameter.Get(EnumStatus.Regardless);
|
|
// List<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 * gd.Quantity;
|
|
|
|
// 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) * gd.Quantity;
|
|
// 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
|
|
// BATBGrandFatherTaging grandFather = BATBGrandFatherTaging.Get(oemployee.ID.Integer);
|
|
// if ((grandFather != null && grandFather.Bonus) && (oemployee.GradeID.Integer == 26 || oemployee.GradeID.Integer == 31 || oemployee.GradeID.Integer == 32))
|
|
// { }
|
|
// else
|
|
// {
|
|
// BonusParameter bparamter = BonusParameter.ApplicableParameters(bonusParamters, oemployee, gd.ComponentID);
|
|
// if (bparamter != null)
|
|
// {
|
|
// double basicSalary = oemployee.BasicSalary;
|
|
// BonusCalculator ocal = new BonusCalculator();
|
|
|
|
// //List<EmployeeGradeSalary> Gradesalaries = EmployeeGradeSalary.Get(oemployee.ID.Integer);
|
|
// //List<dynamic> salarys = EmployeeGradeSalary.GetMonthlySalary(Gradesalaries, oemployee.ID, PayrollPayrollGlobalFunctions.FirstDateOfYear(DateTime.Now), PayrollPayrollGlobalFunctions.LastDateOfYear(DateTime.Now));
|
|
// //salarys.ForEach(s => basicSalary += s.GetType().GetProperty("BasicSalary").GetValue(s, null));
|
|
|
|
// GrossAmount = GrossAmount + (((basicSalary) * bparamter.FlatAmount) / 100) * 12; //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(List<Employee> oemployees)
|
|
//{
|
|
// List<GrossDefination> grossDefinations = GrossDefination.Get();
|
|
// List<ADParameter> adparamters = ADParameter.Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance);
|
|
// List<BonusParameter> bonusParamters = BonusParameter.Get(EnumStatus.Regardless);
|
|
// List<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 static double GetGurantedCach(Employee oEmp, List<GrossDefination> gds, List<BonusParameter> oBonusParams, DateTime year, List<SalaryMonthly> sms, List<SalaryMonthlyDetail> smds)
|
|
//{
|
|
// List<GrossDefination> oGurantedCashs = null;
|
|
// //DateTime fromdate=PayrollPayrollGlobalFunctions.FirstDateOfYear(year);
|
|
// //DateTime todate=PayrollPayrollGlobalFunctions.LastDateOfYear(year);
|
|
// double amount = 0;
|
|
// if (gds != null)
|
|
// {
|
|
// oGurantedCashs = gds.Where(o => o.BenefitDefinationType == EnumBenefitDefinationType.Guranteed_Cash).ToList();
|
|
// }
|
|
// if (oGurantedCashs != null && oGurantedCashs.Count > 0)
|
|
// {
|
|
// List<ADParameter> adParams = null;
|
|
// List<ADParameterEmployee> adParamEmps = null;
|
|
// EmployeeGradeSalary oEmpGSalary = new EmployeeGradeSalary();
|
|
// adParams = ADParameter.Get(oEmp.GradeID, EnumEntitleType.Grade, EnumAllowOrDeduct.Allowance);
|
|
// adParamEmps = ADParameterEmployee.GetByEmployee(oEmp.ID, EnumAllowOrDeduct.Allowance, EnumADEmpType.AppliedToIndividual);
|
|
// List<SalaryMonthlyDetail> empSMDs = new List<SalaryMonthlyDetail>();
|
|
// SalaryMonthlyDetail tempSMD = new SalaryMonthlyDetail();
|
|
// SalaryMonthly empSMs = sms.FirstOrDefault(o => o.EmployeeID == oEmp.ID);
|
|
// if (empSMs != null)
|
|
// {
|
|
// //empSMDs=empSMDs.Contains()
|
|
|
|
// empSMDs = smds.Where(o => o.SalaryMonthlyID == empSMs.ID).ToList();
|
|
// }
|
|
// else
|
|
// {
|
|
// if (oEmp.JoiningDate < year)
|
|
// {
|
|
// SalaryMonthly osalaryMonthly = SalaryMonthly.Get(oEmp.ID, year.AddMonths(1));
|
|
// if (osalaryMonthly != null)
|
|
// empSMDs = SalaryMonthly.GetSalaryDetail(osalaryMonthly.ID);
|
|
// }
|
|
// }
|
|
// foreach (GrossDefination item in oGurantedCashs)
|
|
// {
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Basic && item.ComponentID.Integer == (int)EnumSalaryComponent.Basic)
|
|
// {
|
|
// tempSMD = empSMDs.FirstOrDefault(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Basic_Salary && d.ItemID == (int)EnumSalaryItemCode.Basic_Salary);
|
|
// if (tempSMD != null)
|
|
// {
|
|
|
|
// amount += tempSMD.ChangedAmount * 12;
|
|
// }
|
|
|
|
// }
|
|
|
|
// //amount +=new SalaryMonthly().GetAmountOnDateDiff(oEmp.ID, fromdate, todate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
|
|
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Allowance)
|
|
// {
|
|
// tempSMD = null;
|
|
// foreach (ADParameterEmployee adParam in adParamEmps)
|
|
// {
|
|
|
|
// if (item.ComponentID == adParam.AllowDeductID)
|
|
// {
|
|
// tempSMD = empSMDs.FirstOrDefault(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Allowance && d.ItemID == adParam.AllowDeductID.Integer);
|
|
// if (tempSMD != null)
|
|
// {
|
|
// if (adParam.AllowDeductID.Integer == 2)
|
|
// {
|
|
// amount += adParam.MonthlyAmount * 12;
|
|
// }
|
|
// else
|
|
// {
|
|
// amount += tempSMD.ChangedAmount * 12;
|
|
// }
|
|
// }
|
|
// //amount += empSMDs.Where(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Allowance && d.ItemID == adParam.AllowDeductID.Integer).Sum(d => d.ChangedAmount);
|
|
// //amount += new SalaryMonthly().GetAmountOnDateDiff(oEmp.ID, fromdate, todate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, adParam.AllowDeductID.Integer);
|
|
// }
|
|
// }
|
|
// if (tempSMD == null)
|
|
// {
|
|
// foreach (ADParameter adParam in adParams)
|
|
// {
|
|
|
|
// if (item.ComponentID == adParam.AllowDeductID)
|
|
// {
|
|
// tempSMD = empSMDs.FirstOrDefault(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Allowance && d.ItemID == adParam.AllowDeductID.Integer);
|
|
// if (tempSMD != null)
|
|
// {
|
|
// if (adParam.AllowDeductID.Integer == 2)
|
|
// {
|
|
// if ((oEmp.GrandFather != null && oEmp.GrandFather.Allowance))
|
|
// {
|
|
// amount += adParam.GFFlatAmount * 12;
|
|
// }
|
|
// else
|
|
// {
|
|
// amount += adParam.FlatAmount * 12;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// amount += tempSMD.ChangedAmount * 12;
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Bonus)
|
|
// {
|
|
|
|
// //foreach (BonusParameter bParam in oBonusParams)
|
|
// //{
|
|
|
|
// // if (bParam.BonusID.Integer == 38)
|
|
// // {
|
|
// tempSMD = empSMDs.FirstOrDefault(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Basic_Salary && d.ItemID == (int)EnumSalaryItemCode.Basic_Salary);
|
|
// if (tempSMD != null)
|
|
// {
|
|
// if ((oEmp.GrandFather != null && oEmp.GrandFather.Bonus) && (oEmp.GradeID.Integer == 26 || oEmp.GradeID.Integer == 31 || oEmp.GradeID.Integer == 32)) //Grade 30,31,32 and Grandfather will not get any festival
|
|
// {
|
|
// // amount += tempSMD.ChangedAmount * 0.2 * 12;
|
|
// }
|
|
// else if (oEmp.GradeID.Integer == 26 || oEmp.GradeID.Integer == 31 || oEmp.GradeID.Integer == 32) //Grade 30,31,32 and not Grandfather get 20% of yearly basic for festival
|
|
// {
|
|
// amount += tempSMD.ChangedAmount * 0.2 * 12;
|
|
// }
|
|
// else if (!(oEmp.GradeID.Integer == 26 || oEmp.GradeID.Integer == 31 || oEmp.GradeID.Integer == 32)) //All other Grade other than 30,31,32
|
|
// {
|
|
// amount += tempSMD.ChangedAmount * (33.33 / 100) * 12;
|
|
// }
|
|
// }
|
|
// //amount += new BonusCalculator().CalcluateBonus(bParam, oEmp, oEmp.BasicSalary, oEmp.GrossSalary, Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate) * item.Quantity;
|
|
// // amount += smds.Where(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Bonus && d.ItemID == bParam.BonusID.Integer && d.SalaryMonthlyID == sms.Where(s => s.EmployeeID == oEmp.ID && s.SalaryMonth >= fromdate && s.SalaryMonth <= todate && s.PayrollTypeID == SystemInformation.CurrentSysInfo.PayrollTypeID).Select(s => s.ID)).Sum(d => d.ChangedAmount);
|
|
// // amount += empSMDs.Where(d => d.itemGroupCode == EnumSalaryGroup.Gross && d.ItemCode == EnumSalaryItemCode.Bonus && d.ItemID == bParam.BonusID.Integer).Sum(d => d.ChangedAmount);
|
|
// //amount += new SalaryMonthly().GetAmountOnDateDiff(oEmp.ID, fromdate, todate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Bonus, bParam.BonusID.Integer);
|
|
// // }
|
|
|
|
// //}
|
|
|
|
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
// return amount;
|
|
//}
|
|
//public static double GetGurantedCach(Employee oEmp, List<GrossDefination> gds, List<BonusParameter> oBonusParams)
|
|
//{
|
|
// List<GrossDefination> oGurantedCashs = null;
|
|
// double amount = 0;
|
|
// if (gds != null)
|
|
// {
|
|
// oGurantedCashs = gds.Where(o => o.BenefitDefinationType == EnumBenefitDefinationType.Guranteed_Cash).ToList();
|
|
// }
|
|
// if (oGurantedCashs != null && oGurantedCashs.Count > 0)
|
|
// {
|
|
// List<ADParameter> adParams = null;
|
|
// List<ADParameterEmployee> adParamEmps = null;
|
|
// EmployeeGradeSalary oEmpGSalary = new EmployeeGradeSalary();
|
|
// adParams = ADParameter.Get(oEmp.GradeID, EnumEntitleType.Grade, EnumAllowOrDeduct.Allowance);
|
|
// adParamEmps = ADParameterEmployee.GetByEmployee(oEmp.ID, EnumAllowOrDeduct.Allowance, EnumADEmpType.AppliedToIndividual);
|
|
|
|
// foreach (GrossDefination item in oGurantedCashs)
|
|
// {
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Basic && item.ComponentID.Integer == (int)EnumSalaryComponent.Basic)
|
|
// amount += oEmp.BasicSalary * item.Quantity;
|
|
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Allowance)
|
|
// {
|
|
|
|
// foreach (ADParameter adParam in adParams)
|
|
// {
|
|
|
|
// if (item.ComponentID == adParam.AllowDeductID)
|
|
// {
|
|
// amount += adParam.GetGradeDefinedAmount(oEmp,
|
|
// oEmp.BasicSalary,
|
|
// oEmp.GrossSalary, oEmpGSalary) * item.Quantity;
|
|
// }
|
|
|
|
// }
|
|
// foreach (ADParameterEmployee adParam in adParamEmps)
|
|
// {
|
|
// if (item.ComponentID == adParam.AllowDeductID)
|
|
// {
|
|
// amount += adParam.MonthlyAmount * item.Quantity;
|
|
// }
|
|
// }
|
|
// }
|
|
// if (item.SalaryComponentType == EnumSalaryComponent.Bonus)
|
|
// {
|
|
|
|
// foreach (BonusParameter bParam in oBonusParams)
|
|
// {
|
|
|
|
// if (bParam.BonusID.Integer == 38)
|
|
// {
|
|
// amount += new BonusCalculator().CalcluateBonus(bParam, oEmp, oEmp.BasicSalary, oEmp.GrossSalary, Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate) * item.Quantity;
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
// }
|
|
// return amount;
|
|
//}
|
|
}
|
|
|
|
public interface IGrossDefinationService
|
|
{
|
|
GrossDefination Get(int id);
|
|
List<GrossDefination> Get(EnumBenefitDefinationType type);
|
|
|
|
List<GrossDefination> Get();
|
|
void Save(GrossDefination grossDefination);
|
|
void Delete(int id);
|
|
}
|
|
} |