CEL_Payroll/Payroll.BO/Process/BonusCalculation.cs

139 lines
5.4 KiB
C#
Raw Permalink 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;
namespace Payroll.BO
{
[Serializable]
public class BonusCalculation
{
public BonusCalculation()
{
}
public void BCalculate(ObjectsTemplate<Employee> oEmployees,ID BonusID,DateTime payDate)
{
}
public double ConvertToDailyRate(double nBasic, DateTime dMonthDate)
{
double amount = 0;
amount = nBasic / Convert.ToDouble(DateTime.DaysInMonth(dMonthDate.Year, dMonthDate.Month));
return amount;
}
public double GeneralAmount(Employee oEmp,BonusParameter oBParameter,DateTime SalaryMonthDate)
{
double nTotalBonus = 0.0;
nTotalBonus = oBParameter.FlatAmount +(oEmp.GrossSalary*oBParameter.NoOfGross) + (oEmp.BasicSalary * oBParameter.NoOfBasic) + (oEmp.GrossSalary * oBParameter.PercentOfGross / 100) + (oEmp.BasicSalary * oBParameter.NoOfEarnedBasic);
nTotalBonus = nTotalBonus + ConvertToDailyRate(oEmp.BasicSalary, SalaryMonthDate) * oBParameter.NoOfDays + ConvertToDailyRate(oEmp.GrossSalary, SalaryMonthDate) * oBParameter.GrossOfDays;
return nTotalBonus;
}
public double CaculatedSalaryComponentAmount( BonusParameter.BonusParamSalaryItem oBonusPSalaryItem,Employee oEmp,DateTime dSalaryMonth)
{
ObjectsTemplate<SalaryComponent> _SalaryComponents = SalaryComponent.Benefits();
double BonusSalaryComponentAmount = 0.0;
foreach(SalaryComponent oSComponent in _SalaryComponents)
{
if (oBonusPSalaryItem.AllowDeductID == oSComponent.ObjectID.Integer)
{
BonusSalaryComponentAmount = ((oEmp.BasicSalary * oBonusPSalaryItem.NoOfSalary) * oBonusPSalaryItem.Percent) / 100;
break;
}
}
return BonusSalaryComponentAmount;
}
public double CaculatedServiceLengthAmount(BonusParameter oBonusParameter,Employee oEmp,double TotalBonusAmount,DateTime dCuttOffDate)
{
DateTime toDate = DateTime.Now;
DateTime joiningDate = oEmp.JoiningDate;
double BonusSLengthAmount = 0.0;
int ServiceLength = 0;
int Counter = 0;
//while (joiningDate.ToString("MMMM yyyy") != toDate.ToString("MMMM yyyy"))
//{
// Counter++;
// joiningDate = joiningDate.AddMonths(1);
//}
//while (joiningDate.ToString("dd") != toDate.ToString("dd"))
//{
// Counter++;
// joiningDate = joiningDate.AddDays(1);
//}
Counter = (dCuttOffDate - joiningDate).Days + 1;
//countDays = DateTime.Compare(DateTime.Now, joiningDate);
if (oBonusParameter.BonusServiceLengths != null)
{
for (int i = oBonusParameter.BonusServiceLengths.Count; i >=1 ; i--)
{
ServiceLength = oBonusParameter.BonusServiceLengths[i-1].LengthOfService;
if (oBonusParameter.BonusServiceLengths[i-1].LengthOfService < Counter)
{
ServiceLength = oBonusParameter.BonusServiceLengths[i-1].EntitlePercent;
break;
}
}
BonusSLengthAmount = (TotalBonusAmount * ServiceLength)/100;
}
return BonusSLengthAmount;
}
public double CalculationBDearnessAmount(BonusParameter oBonusParameter, Employee oEmp)
{
double BonusDearnessAmount=0.0;
if (oBonusParameter.BonusSlabs != null)
{
for (int i = oBonusParameter.BonusSlabs.Count; i >= 1; i--)
{
if (oBonusParameter.BonusSlabs[i - 1].SlabAmount < oEmp.BasicSalary)
{
if(oBonusParameter.BonusSlabs[i - 1].AmountType==EnumSlabAmountType.ActualBasic)
{
BonusDearnessAmount = oEmp.BasicSalary;//oBonusParameter.BonusSlabs[i - 1].Amount;
break;
}
else if (oBonusParameter.BonusSlabs[i - 1].AmountType == EnumSlabAmountType.FlatAmount)
{
BonusDearnessAmount = oBonusParameter.BonusSlabs[i - 1].Amount;
break;
}
}
}
}
return BonusDearnessAmount;
}
//public double CaculatedBonusAdjustAmount(BonusParameter.BonusParamAdjustItem oBonusPAdjustAmount)
//{
// double BonusAdjustAmount = 0.0;
// if (oBonusParameter.BonusParamAdjustItems != null)
// {
// foreach (BonusParameter.BonusParamAdjustItem oBAdjustAmount in oBonusParameter.BonusParamAdjustItems)
// {
// BonusAdjustAmount += oBAdjustAmount.Amount;
// }
// }
// return BonusAdjustAmount;
//}
}
}