EchoTex_Payroll/HRM.DA/Service/OPI/OpiCalculator.cs

794 lines
35 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
namespace HRM.DA
{
public class OpiCalculator
{
private List<Employee> _employees;
private List<Employee> _IAemployees;
private List<OPIProcessDetail> _processDetails;
private List<OpiParameter> _opiParameters;
private List<OpiItem> _opiItems;
public DateTime _processMonth;
private bool isOPISeparateAcountApplicable;
private PayrollType _payrolltype;
private List<OpiProcessStatus> _processStatuses;
public List<OPIProcessDetail> OpiProcessDetails
{
get
{
return _processDetails;
}
}
public OpiCalculator()
{
// _opiItems = new IOpiItemService().Get(EnumStatus.Regardless, );
// isOPISeparateAcountApplicable = ConfigurationManager.GetBoolValue("opi", "separateaccount", EnumConfigurationType.Logic);
}
public List<OpiProcessStatus> ErrorList
{
get
{
return _processStatuses;
}
}
public List<Employee> Employees
{
get
{
return _employees;
}
}
public string MakeErrorMessage(List<OpiProcessStatus> allerrors)
{
string error = String.Empty;
foreach (OpiProcessStatus item in allerrors)
{
error += item.EmployeeNo + " " + item.Remarks + "\n";
}
return error;
}
public void Process(List<Employee> employees, DateTime processMonth, int payrolltypeid, int userid)
{
_employees = employees;
_processMonth = processMonth;
_opiParameters = new OpiParameterService().Get(EnumStatus.Active, payrolltypeid);
//_opiItems = OpiItem.Get();
_payrolltype = new PayrollTypeService().Get(payrolltypeid);
this.Initialize();
this.AddEmployeeToProcessDetail();
if (_processStatuses.Count > 0) return;
if (_processStatuses.Count > 0)
{
string message = MakeErrorMessage(_processStatuses);
return;
}
this.CalculateBasicSalary();
if (_processStatuses.Count > 0) return;
this.OPIItems();
if (_processStatuses.Count == 0)
{
OPIProcess op = new OPIProcess();
op.ProcessDate = DateTime.Today;
op.PayrollTypeID = payrolltypeid;
op.OPIMonth = processMonth;
op.CreatedBy = userid;
op.CreatedDate = DateTime.Today;
this.OpiProcessDetails.ForEach(x => {
x.CreatedBy = userid;
x.CreatedDate = DateTime.Today;
foreach (var item in x.opiProcessDetailItems)
{
item.CreatedBy = userid;
item.CreatedDate = DateTime.Today;
}
});
op.OPIProcessDetails = this.OpiProcessDetails;
new OPIProcessService().Save(op, op.OPIProcessDetails);
}
}
//public void ProcessForLC(List<Employee> employees, DateTime processMonth)
//{
// _employees = employees;
// _processMonth = processMonth;
// //_opiItems = OpiItem.Get();
// UpdateprocessStatus("Collecting Employee basic information....");
// this.Initialize();
// this.AddEmployeeToProcessDetail();
// if (_processStatuses.Count > 0) return;
// if (_processStatuses.Count > 0)
// {
// string message = MakeErrorMessage(_processStatuses);
// if (ErrorMessage != null) ErrorMessage(message);
// return;
// }
// UpdateprocessStatus("Calculating basic Salary....");
// this.CalculateBasicSalary();
// if (_processStatuses.Count > 0) return;
// UpdateprocessStatus("Calculating out side payroll items....");
// if (_processStatuses.Count > 0) return;
// this.OPIItemsLC();
// this.CalculationException(_processDetails, _processMonth);
// //return _processDetails;
//}
private void Initialize()
{
_processStatuses = new List<OpiProcessStatus>();
_processDetails = new List<OPIProcessDetail>();
}
private bool ProcessStartValidation()
{
return false;
}
private void AddEmployeeToProcessDetail()
{
//_processDetails = new List<OPIProcessDetail>();
List<Branch> obranches = new BranchService().Get(EnumStatus.Regardless, this._payrolltype.ID);
foreach (Employee employee in _employees)
{
if (GlobalFunctions.FirstDateOfMonth(employee.JoiningDate) > GlobalFunctions.FirstDateOfMonth(_processMonth))
{
AddProcessStatus(employee, "Employee Joining Date is greater than Process Date");
continue;
}
OPIProcessDetail procDetail = new OPIProcessDetail();
procDetail.CategoryID = employee.CategoryID;
procDetail.EmployeeID = employee.ID;
procDetail.Gender = employee.Gender;
procDetail.IsConfirmed = employee.IsConfirmed;
procDetail.PayrollTypeID = employee.PayrollTypeID;
procDetail.PFMemberType = employee.PFMemberType;
if (employee.ReligionID == null)
AddProcessStatus(employee, "Religion not yet assigned");
else
procDetail.ReligionID = employee.ReligionID;
if (employee.GradeID == null)
AddProcessStatus(employee, "Grade not yet assigned");
else
procDetail.GradeID = (int)employee.GradeID;
if (employee.DepartmentID == null)
AddProcessStatus(employee, "Department not yet assigned");
else
procDetail.DepartmentID = (int)employee.DepartmentID;
if (employee.DesignationID == null)
AddProcessStatus(employee, "Designation not yet assigned");
else
procDetail.DesignationID = (int)employee.DesignationID;
if (employee.LocationID == null)
AddProcessStatus(employee, "Location not yet assigned");
else
procDetail.LocationID = (int)employee.LocationID;
if (isOPISeparateAcountApplicable)
{
if (employee.OutPayPaymentMode == EnumPaymentMode.BankTransfer)
{
if (employee.OutPayBranchID == null)
{
AddProcessStatus(employee, "Employee payment mode is declared"
+ " to bank transfer, but no OPI bank/account information found");
}
else
{
procDetail.BranchID = (int)employee.OutPayBranchID;
procDetail.AccountNo = employee.OutPayAccountNo;
Branch branch = new Branch();
branch = obranches.FirstOrDefault(x => x.ID == (int)employee.OutPayBranchID);
procDetail.BankID = branch.BankID;
}
//procDetail.BranchID = employee.BranchID;
//Branch branch = new Branch();
//branch = obranches.GetItem(employee.BranchID);
//procDetail.BankID = branch.BankID;
//procDetail.AccountNo = employee.AccountNo;
}
else
{
procDetail.BranchID = null;
procDetail.BankID = null;
}
}
else
{
if (employee.PaymentMode == EnumPaymentMode.BankTransfer)
{
if (employee.BranchID == null && employee.OutPayBranchID ==null )
AddProcessStatus(employee, "Employee payment mode is diclared"
+ " to bank transfer, but no bank/account information found");
else
{
if (employee.OutPayBranchID != null)
{
procDetail.BranchID = employee.OutPayBranchID;
procDetail.AccountNo = employee.OutPayAccountNo;
Branch branch = new Branch();
branch = obranches.FirstOrDefault(x => x.ID == (int)employee.OutPayBranchID);
procDetail.BankID = branch.BankID;
}
if (employee.OutPayBranchID == null && employee.BranchID != null)
{
procDetail.BranchID = employee.BranchID;
procDetail.AccountNo = employee.AccountNo;
Branch branch = new Branch();
branch = obranches.FirstOrDefault(x => x.ID == (int)employee.BranchID);
procDetail.BankID = branch.BankID;
}
}
//procDetail.BranchID = employee.BranchID;
//Branch branch = new Branch();
//branch = obranches.GetItem(employee.BranchID);
//procDetail.BankID = branch.BankID;
//procDetail.AccountNo = employee.AccountNo;
}
else
{
procDetail.BranchID = null;
procDetail.BankID = null;
}
}
procDetail.Employee = employee;
_processDetails.Add(procDetail);
}
}
private void AddProcessStatus(Employee employee, string remarks)
{
OpiProcessStatus status = new OpiProcessStatus();
status.EmployeeNo = employee.EmployeeNo;
status.Name = employee.Name;
status.Remarks = remarks;
_processStatuses.Add(status);
}
private void CalculateBasicSalary()
{
#region Calculate Normal Salary
List<EmployeeGradeSalary> gradeSalaryItems = new EmployeeGradeSalaryService().GetCurrMonthSalaryItems(
this._payrolltype.NextPayProcessDate, this._payrolltype.ID);
foreach (OPIProcessDetail opiProcess in _processDetails)
{
opiProcess.GradeSalaries = gradeSalaryItems.FindAll(x => x.EmployeeID == opiProcess.EmployeeID);
if (opiProcess.GradeSalaries.Count == 0) continue;
EmployeeGradeSalary.PrepareDataForCurrentSalary(this._processMonth, opiProcess.Employee, opiProcess.GradeSalaries);
}
#endregion Calculate Normal Salary
#region calculate arrear amount
List<EmployeeGradeSalary> arrearItems = new EmployeeGradeSalaryService().GetArrearItems(_payrolltype.ID);
foreach (OPIProcessDetail opiProcess in _processDetails)
opiProcess.ArrearGradeSalaries = arrearItems.FindAll(x => x.EmployeeID == opiProcess.EmployeeID);
#endregion calculate arrear amount
}
private void OPIItems()
{
try
{
if (_opiParameters == null || _opiParameters.Count == 0) return;
List<OpiParameterIndividual> opiIndividuals = new OpiParameterIndividualService().Get(
GlobalFunctions.FirstDateOfMonth(_processMonth),
GlobalFunctions.LastDateOfMonth(_processMonth));
OpiParameter paramter = new OpiParameter();
List<OpiParameter> parameters;
foreach (OPIProcessDetail detail in _processDetails)
{
new OpiParameterService().ApplicableParameters(detail.Employee, detail, _opiParameters, detail.GradeSalaries);
parameters = new OpiParameterService().ApplicableParameters(detail.Employee, detail, _opiParameters, detail.GradeSalaries);
if (parameters == null) { throw new ServiceException(" Applicable parameter not found for the employee :" + detail.Employee.EmployeeNo + " and Grade:" + detail.Employee.Grade.Code); }
this.GradeDefinedOpiItem(detail, parameters);
this.IndividualOpiItem(detail, opiIndividuals, detail.GradeSalaries);
}
}
catch (Exception ex)
{
throw new ServiceException(ex.Message);
}
}
//private void OPIItemsLC()
//{
// try
// {
// UpdateProgressStatus(EnumProcessStatus.Start);
// _opiParameters = OpiParameter.Get(EnumStatus.Active);
// if (_opiParameters == null || _opiParameters.Count == 0) return;
// List<OpiParameterIndividual> opiIndividuals = OpiParameterIndividual.Service.Get(
// PayrollPayrollGlobalFunctions.PayrollFirstDateOfMonth(_processMonth),
// PayrollPayrollGlobalFunctions.PayrollLastDateOfMonth(_processMonth));
// OpiParameter paramter = new OpiParameter();
// List<OpiParameter> parameters;
// foreach (OPIProcessDetail detail in _processDetails)
// {
// UpdateProgressStatus(EnumProcessStatus.PerformStep);
// parameters = paramter.ApplicableParameters(detail.Employee, detail, _opiParameters, detail.GradeSalaries);
// if (parameters == null) { throw new ServiceException(" Applicable parameter not found for the employee :" + detail.Employee.EmployeeNo + " and Grade:" + detail.Employee.Grade.Code); }
// this.GradeDefinedOpiItem(detail, parameters);
// this.IndividualOpiItemLC(detail, opiIndividuals, detail.GradeSalaries);
// }
// }
// catch (Exception ex)
// {
// throw new ServiceException(ex.Message);
// }
//}
private void Add(OPIProcessDetail processDetail, OPIProcessDetailItem item)
{
OPIProcessDetailItem existItem = processDetail.opiProcessDetailItems.Find(delegate (OPIProcessDetailItem fItem) { return fItem.OPIItemID == item.OPIItemID; });
if (existItem == null)
{
processDetail.opiProcessDetailItems.Add(item);
}
else
{
existItem.NetAmount = GlobalFunctions.Round(existItem.NetAmount + item.NetAmount);
existItem.ChangeNetAmount = GlobalFunctions.Round(existItem.ChangeNetAmount + item.ChangeNetAmount);
existItem.Description = item.Description;
}
}
/// <summary>
///
/// </summary>
/// <param name="detail"></param>
/// <param name="gradeSalaries"></param>
/// <param name="parameters"></param>
/// <param name="franctionate"></param>
private void GradeDefinedOpiItem(OPIProcessDetail detail,
List<OpiParameter> parameters)
{
double amount = 0, paidAmount = 0;
int paidMonth = 0;
foreach (OpiParameter parameter in parameters)
{
if (parameter.EntitleType != EnumEntitleType.Grade) continue;
if (_IAemployees != null && _IAemployees.Count > 0 && _IAemployees.Any(o => o.ID == detail.EmployeeID) && !parameter.IsIAApplicable) continue;
OPIProcessDetailItem opdItem = new OPIProcessDetailItem();
switch (parameter.OpiPeriodicity)
{
case EnumOpiPeriodicity.Monthly:
if (parameter.IsEarnedBasic == true)
{
SalaryMonthly omonthlysalary = new SalaryMonthlyService().Get(detail.EmployeeID, _processMonth);
if (omonthlysalary != null)
{
amount = omonthlysalary.GetGrossAmount(EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
}
amount = new OpiParameterService().GetGradeDefinedAmount(detail.Employee, amount, 0, 1, parameter);
}
else
{
EmployeeGradeSalary.PrepareDataForCurrentSalary(this._processMonth, detail.Employee, detail.GradeSalaries);
amount = new OpiParameterService().GetGradeDefinedAmount(detail.Employee, detail.GradeSalaries, parameter);
foreach (EmployeeGradeSalary arrearItem in detail.ArrearGradeSalaries)
{
arrearItem.FractionofFromTo = GlobalFunctions.GetFraction(arrearItem.EffectDate, (DateTime)arrearItem.TillDate);
amount = amount + new OpiParameterService().GetGradeDefinedAmount(detail.Employee, arrearItem, parameter);
amount = amount - new OPIProcessService().GetAmountOnRange(detail.Employee, arrearItem.EffectDate, (DateTime)arrearItem.TillDate,
parameter.OpiItemID, parameter);
amount = GlobalFunctions.Round(amount);
}
}
if (amount > 0)
{
opdItem.NetAmount = GlobalFunctions.Round(amount);
opdItem.ChangeNetAmount = GlobalFunctions.Round(amount);
}
else
{
continue;
}
break;
case EnumOpiPeriodicity.OnceOff:
break;
case EnumOpiPeriodicity.Annual:
// Calculation policy 1:
// No_of_paid_month = Jan to Next_Pay_Process_Month
// paidAmount= get cumalative amount on month range
// net_Amount= amount + {(No_of_paid_month * amount) - paidAmount}
//implementing policy 1
//amount = parameter.GetGradeDefinedAmount(detail.Employee, gradeSalaries);
double annualAmount = amount;
amount = amount / 12;
DateTime dFromOpiMonth, dToOpiMonth;
dFromOpiMonth = new DateTime(_processMonth.Year, 1, 1);
paidMonth = Convert.ToInt32(_processMonth.Date.Month) - 1;
if (paidMonth <= 0)
dToOpiMonth = new DateTime(_processMonth.Year, dFromOpiMonth.Date.Month, (GlobalFunctions.LastDateOfMonth(dFromOpiMonth)).Date.Day);
else
dToOpiMonth = new DateTime(_processMonth.Year, paidMonth, 1);
paidAmount = GlobalFunctions.Round(new OPIProcessService().GetPrevMonthAmount(detail.EmployeeID, parameter.OpiItemID, dFromOpiMonth,
GlobalFunctions.LastDateOfMonth(dToOpiMonth)));
if (_processMonth.Month == 12)
{
if (detail.Employee.JoiningDate > Ease.Core.Utility.Global.DateFunctions.FirstDateOfYear(dFromOpiMonth))
{
int dDays = Ease.Core.Utility.Global.DateFunctions.DateDiff("d", detail.Employee.JoiningDate,
Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(dFromOpiMonth)) + 1;
annualAmount = annualAmount / 365 * dDays;
if ((annualAmount - paidAmount) > 0)
{
opdItem.NetAmount = annualAmount - paidAmount;
}
else
{
continue;
}
}
else
{
if ((annualAmount - paidAmount) > 0)
{
opdItem.NetAmount = annualAmount - paidAmount;
}
else
{
continue;
}
}
}
else
{
if (detail.Employee.JoiningDate > Ease.Core.Utility.Global.DateFunctions.FirstDateOfYear(dFromOpiMonth))
{
int dDays = Ease.Core.Utility.Global.DateFunctions.DateDiff("d", detail.Employee.JoiningDate,
Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(dFromOpiMonth)) + 1;
annualAmount = annualAmount / 365 * dDays;
amount = annualAmount / ((12 - detail.Employee.JoiningDate.Month) + 1);
paidMonth = _processMonth.Month - detail.Employee.JoiningDate.Month;
}
if ((amount + ((paidMonth * amount) - paidAmount)) > 0)
{
opdItem.NetAmount = GlobalFunctions.Round(amount + ((paidMonth * amount) - paidAmount));
}
else
{
continue;
}
}
opdItem.ChangeNetAmount = GlobalFunctions.Round(opdItem.NetAmount);
// Calculation Policy 2:
// rest_of_the_Month= (Next_Pay_Process_Month to Dec) + 1
// net_Amount = (amount * 12)/rest_of_the_Month
break;
//case EnumOpiPeriodicity.AveragePayment:
// //find the number of month specific salary item from salary monthly defined in opi parameter
// //DateTime fromDate=null, todate=null;
// // create the from and todate by averagemonth
// // fromdate should be frist date of month
// // todate should be last date of month
// // avgmonth=3 and payprocessmonth=jun, frommonth=march todate=may
// double salaryPaidAmount = 0;
// DateTime dFromDate, dToDate;
// dFromDate = PayrollPayrollGlobalFunctions.PayrollFirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.AddMonths((parameter.NoOfMonth) * (-1)));
// dToDate = PayrollPayrollGlobalFunctions.PayrollLastDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.AddMonths(-1));
// dFromDate = PayrollPayrollGlobalFunctions.PayrollFirstDateOfMonth(dFromDate);
// SalaryMonthly omonthly = new SalaryMonthly();
// switch (parameter.OpiAvgPayType)
// {
// case EnumOpiAvgPayType.OT:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Over_Time_Amount, parameter.OpiAvgPayItemID.Integer);
// break;
// case EnumOpiAvgPayType.Allowance:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, parameter.OpiAvgPayItemID.Integer);
// break;
// case EnumOpiAvgPayType.Deduction:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Deductions, EnumSalaryItemCode.Deduction, parameter.OpiAvgPayItemID.Integer);
// break;
// default:
// break;
// }
// amount = 0;
// if (parameter.NoOfMonth != 0)
// amount = salaryPaidAmount / (double)parameter.NoOfMonth;
// opdItem.NetAmount = PayrollPayrollGlobalFunctions.Round(amount);
// opdItem.ChangeNetAmount = opdItem.NetAmount;
// break;
//case EnumOpiPeriodicity.OnAmount:
// // Number of employee of the parameter selected grade - not applicable employees
// // if gender applicable then remove other gender
// // if confirmed checked then remove unconfirmed
// //
// int nNumOfEmp = parameter.NoOfAplicableEmp;
// if (nNumOfEmp != 0)
// indvAmnt = parameter.ProvisionAmount / (double)nNumOfEmp;
// opdItem.NetAmount = PayrollPayrollGlobalFunctions.Round(indvAmnt);
// opdItem.ChangeNetAmount = PayrollPayrollGlobalFunctions.Round(indvAmnt);
// break;
//case EnumOpiPeriodicity.BonusProvision:
// // find the parameter of the bonus by using employee gradid and bonus id
// // parameter define the number basic/total Amount will get in a year
// // find the bonus paid amount from bonus pay detail
// // find the number of item paid for the employee
// // (rest of the Item * number of basic)
// double annualBonusPaidinYear = BonusProcess.GetBonusAmountWithinYear(
// Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate, detail.Employee.ID, parameter.OpiAvgPayItemID.Integer);
// int paidItem = BonusProcess.GetForNoOfPaid(_processMonth, parameter.OpiAvgPayItemID.Integer);
// double provisionedAmount = PayrollPayrollGlobalFunctions.Round(OPIProcess.GetPrevMonthAmount(detail.EmployeeID,
// parameter.OpiItemID, new DateTime(_processMonth.Year, 1, 1), PayrollPayrollGlobalFunctions.PayrollLastDateOfMonth(_processMonth)));
// double willProvision;
// if (_processMonth.Month != 12)
// {
// int restofMonth = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m", _processMonth, new DateTime(_processMonth.Year, 12, 31)) + 1;
// BonusParameter bonusParameter = BonusParameter.GetByBonusID(parameter.OpiAvgPayItemID);
// willProvision = annualBonusPaidinYear + ((bonusParameter.NoOfBasic - paidItem) * detail.Employee.BasicSalary );
// willProvision = willProvision - provisionedAmount;
// willProvision = willProvision / restofMonth;
// }
// else
// {
// willProvision = annualBonusPaidinYear - provisionedAmount;
// }
// opdItem.NetAmount = PayrollPayrollGlobalFunctions.Round(willProvision);
// opdItem.ChangeNetAmount = PayrollPayrollGlobalFunctions.Round(willProvision);
// break;
default:
break;
}
//opdItem.NetAmount = Math.Abs(opdItem.NetAmount);
//opdItem.ChangeNetAmount = Math.Abs(opdItem.ChangeNetAmount);
if (opdItem.NetAmount > 0)
{
opdItem.NetAmount = opdItem.NetAmount;
}
else
{
continue;
}
if (opdItem.ChangeNetAmount > 0)
{
opdItem.ChangeNetAmount = opdItem.ChangeNetAmount;
}
else
{
continue;
}
OpiItem opItem = _opiItems.FirstOrDefault(x=>x.ID == parameter.OpiItemID);
opdItem.Description = opItem.Name;
opdItem.OPIItemID = parameter.OpiItemID;
opdItem.OPIType = opItem.OpiType;
opdItem.Sequence = opItem.Sequence;
opdItem.Paramter = parameter;
this.Add(detail, opdItem); // add the item in the collection
}
}
public void DeleteOPIProcess(DateTime dOPIMonth)
{
// OPIProcess.Undo(dOPIMonth);
}
private void IndividualOpiItem(OPIProcessDetail detail, List<OpiParameterIndividual> opiIndividuals
, List<EmployeeGradeSalary> gradeSalaries)
{
// currently we are not provisioning any kind of discontinued employee
// but in future we need this.
if (detail.Employee.Status != EnumEmployeeStatus.Live) return;
double amount = 0;
#region Individual Allowance
List<OpiParameterIndividual> items = opiIndividuals.FindAll(delegate (OpiParameterIndividual item)
{
return item.EmployeeId == detail.Employee.ID && item.IndividualType == EnumOPIIndivdualType.AppliedToIndividual;
});
foreach (OpiParameterIndividual item in items)
{
amount = 0;
OpiParameter parameter = _opiParameters.FirstOrDefault(x => x.ID == item.OpiParameterID);
amount = new OpiParameterService().GetIndividualAmount(detail.Employee, _processMonth, item,
detail.Employee.BasicSalary, detail.Employee.GrossSalary, parameter,this._processMonth );
//foreach(EmployeeGradeSalary oItem in gradeSalaries)
//{
// amount = amount + parameter.GetIndividualAmount(detail.Employee, _processMonth, item, detail.Employee.BasicSalary, detail.Employee.GrossSalary, oItem.FractionofFromTo);
//}
OPIProcessDetailItem opdItem = new OPIProcessDetailItem();
if (amount > 0)
{
opdItem.NetAmount = GlobalFunctions.Round(amount);
opdItem.ChangeNetAmount = GlobalFunctions.Round(amount);
}
else
{
continue;
}
opdItem.OPIItemID = parameter.OpiItemID;
if(_opiItems == null)
{
_opiItems = new OpiItemService().Get(EnumStatus.Regardless, this._payrolltype.ID);
}
OpiItem opItem = _opiItems.FirstOrDefault(x => x.ID == parameter.OpiItemID);
opdItem.OPIType = opItem.OpiType;
opdItem.Sequence = opItem.Sequence;
opdItem.Description = opItem.Name;
//opdItem.Paramter = parameter;//new
this.Add(detail, opdItem); // add the item in the collection
}
#endregion Individual Allowance
}
//private void IndividualOpiItemLC(OPIProcessDetail detail, List<OpiParameterIndividual> opiIndividuals
// , List<EmployeeGradeSalary> gradeSalaries)
//{
// // currently we are not provisioning any kind of discontinued employee
// // but in future we need this.
// double amount = 0;
// #region Individual Allowance
// List<OpiParameterIndividual> items = opiIndividuals.FindAll(delegate (OpiParameterIndividual item)
// {
// return item.EmployeeId.Integer == detail.Employee.ID.Integer && item.IndividualType == EnumOPIIndivdualType.AppliedToIndividual;
// });
// foreach (OpiParameterIndividual item in items)
// {
// amount = 0;
// OpiParameter parameter = _opiParameters.GetItem(item.OpiParameterID);
// amount = parameter.GetIndividualAmount(detail.Employee, _processMonth, item, detail.Employee.BasicSalary, detail.Employee.GrossSalary);
// //foreach(EmployeeGradeSalary oItem in gradeSalaries)
// //{
// // amount = amount + parameter.GetIndividualAmount(detail.Employee, _processMonth, item, detail.Employee.BasicSalary, detail.Employee.GrossSalary, oItem.FractionofFromTo);
// //}
// OPIProcessDetailItem opdItem = new OPIProcessDetailItem();
// opdItem.NetAmount = PayrollPayrollGlobalFunctions.Round(amount);
// opdItem.ChangeNetAmount = PayrollPayrollGlobalFunctions.Round(amount);
// opdItem.OPIItemID = parameter.OpiItemID;
// OpiItem opItem = _opiItems.GetItem(parameter.OpiItem.ID);
// opdItem.OPIType = opItem.OpiType;
// opdItem.Sequence = opItem.Sequence;
// opdItem.Description = opItem.Name;
// //opdItem.Paramter = parameter;//new
// this.Add(detail, opdItem); // add the item in the collection
// }
// #endregion Individual Allowance
//}
}
public class OpiProcessStatus
{
public OpiProcessStatus()
{
_employeeNo = "";
_name = "";
_remarks = "";
}
#region EmployeeNo : Employee No
private string _employeeNo;
public string EmployeeNo
{
get { return _employeeNo; }
set
{
_employeeNo = value;
}
}
#endregion
#region Employee Name : Employee Name
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value;
}
}
#endregion
#region Remaks : Remarks
private string _remarks;
public string Remarks
{
get { return _remarks; }
set
{
_remarks = value;
}
}
#endregion
}
}