CEL_Payroll/Payroll.BO/CarFuel/CarFuelCalculator.cs

803 lines
38 KiB
C#
Raw 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;
using System.Data;
namespace Payroll.BO
{
[Serializable]
public class CarFuelCalculator : CarFuelExceptionCalculator
{
private ObjectsTemplate<Employee> _employees;
private ObjectsTemplate<CarFuelProcessDetail> _processDetails;
private ObjectsTemplate<CarFuelParameter> _CarFuelParameters;
private ObjectsTemplate<CarFuelItem> _CarFuelItems;
private DataSet _dsCarFuelRegister;
private ObjectsTemplate<ProcessItem> _processItems;
public DateTime _processMonth;
private ObjectsTemplate<CarFuelProcess> _oCarFuelProcesss;
private ObjectsTemplate<CarFuelProcessDetail> _oCarFuelProcessDetails;
private ObjectsTemplate<CarFuelProcessDetailItem> _oCarFuelProcessDetailItems;
private bool isCarFuelSeparateAcountApplicable;
public bool _isDesignationFromDescriptionText;
private List<CarFuelProcessStatus> _processStatuses;
public event ProcessStatus ProcessStatus;
public event ProgressStatus ProgressStatus;
//
public event ErrorMessage ErrorMessage;
public ObjectsTemplate<CarFuelProcessDetail> CarFuelProcessDetails
{
get
{
return _processDetails;
}
}
public CarFuelCalculator()
{
_CarFuelItems = CarFuelItem.Get();
isCarFuelSeparateAcountApplicable = ConfigurationManager.GetBoolValue("CarFuel", "separateaccount", EnumConfigurationType.Logic);
}
public List<CarFuelProcessStatus> ErrorList
{
get
{
return _processStatuses;
}
}
private void UpdateprocessStatus(string statusString)
{
if (ProcessStatus != null) ProcessStatus(statusString);
}
private void UpdateProgressStatus(EnumProcessStatus status)
{
if (ProgressStatus != null) ProgressStatus(status);
}
public ObjectsTemplate<Employee> Employees
{
get
{
return _employees;
}
}
public string MakeErrorMessage(List<CarFuelProcessStatus> allerrors)
{
string error = String.Empty;
foreach (CarFuelProcessStatus item in allerrors)
{
error += item.EmployeeNo + " " + item.Remarks + "\n";
}
return error;
}
//public ObjectsTemplate<CarFuelProcessDetail> Process(ObjectsTemplate<Employee> employees, DateTime processMonth)
public void Process(ObjectsTemplate<Employee> employees, DateTime processMonth)
{
_employees = employees;
_processMonth = processMonth;
//_CarFuelItems = CarFuelItem.Get();
_isDesignationFromDescriptionText = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic);
ObjectsTemplate<ITEmpHead> oComCars = ITEmpHead.Get(Payroll.BO.SystemInformation.CurrentSysInfo.TaxParamID.Integer);
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 Provision items....");
if (_processStatuses.Count > 0) return;
this.CarFuelItemsLC(oComCars);
this.CalculationException(_processDetails, _processMonth, oComCars);
//return _processDetails;
}
public void ProcessForLC(ObjectsTemplate<Employee> employees, DateTime processMonth)
{
_employees = employees;
_processMonth = processMonth;
//_CarFuelItems = CarFuelItem.Get();
ObjectsTemplate<ITEmpHead> oComCars = ITEmpHead.Get(Payroll.BO.SystemInformation.CurrentSysInfo.TaxParamID.Integer);
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 Provision items....");
if (_processStatuses.Count > 0) return;
this.CarFuelItemsLC(oComCars);
this.CalculationException(_processDetails, _processMonth, oComCars);
//return _processDetails;
}
private void Initialize()
{
_processStatuses = new List<CarFuelProcessStatus>();
_processDetails = new ObjectsTemplate<CarFuelProcessDetail>();
}
private bool ProcessStartValidation()
{
return false;
}
private void AddEmployeeToProcessDetail()
{
//_processDetails = new ObjectsTemplate<CarFuelProcessDetail>();
ObjectsTemplate<Branch> obranches = Branch.Get(EnumStatus.Regardless);
UpdateProgressStatus(EnumProcessStatus.Start);
foreach (Employee employee in _employees)
{
if (GlobalFunctions.FirstDateOfMonth(employee.JoiningDate) > GlobalFunctions.FirstDateOfMonth(_processMonth))
{
AddProcessStatus(employee, "Employee Joining Date is greater than Process Date");
continue;
}
UpdateProgressStatus(EnumProcessStatus.PerformStep);
this.UpdateprocessStatus(" Collecting information for the employee " + employee.Name + " ( " + employee.EmployeeNo + ")");
CarFuelProcessDetail procDetail = new CarFuelProcessDetail();
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.IsUnassigned == true)
AddProcessStatus(employee, "Religion not yet assigned");
else
procDetail.ReligionID = employee.ReligionID;
if (employee.GradeID.IsUnassigned == true)
AddProcessStatus(employee, "Grade not yet assigned");
else
procDetail.GradeID = employee.GradeID;
if (employee.DepartmentID.IsUnassigned == true)
AddProcessStatus(employee, "Department not yet assigned");
else
procDetail.DepartmentID = employee.DepartmentID;
if (_isDesignationFromDescriptionText)
{
if (employee.DescriptionText == "")
AddProcessStatus(employee, "Designation not yet assingned");
}
else
{
if (employee.DesignationID.IsUnassigned == true)
AddProcessStatus(employee, "Designation not yet assingned");
else procDetail.DesignationID = employee.DesignationID;
}
if (employee.LocationID.IsUnassigned == true)
AddProcessStatus(employee, "Location not yet assigned");
else
procDetail.LocationID = employee.LocationID;
if (isCarFuelSeparateAcountApplicable)
{
if (employee.OutPayPaymentMode == EnumPaymentMode.BankTransfer)
{
if (employee.OutPayBranchID == null || employee.OutPayBranchID.IsUnassigned)
{
AddProcessStatus(employee, "Employee payment mode is declared"
+ " to bank transfer, but no CarFuel bank/account information found");
}
else
{
procDetail.BranchID = employee.OutPayBranchID;
procDetail.AccountNo = employee.OutPayAccountNo;
Branch branch = new Branch();
branch = obranches.GetItem(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.BranchID.IsUnassigned)
AddProcessStatus(employee, "Employee payment mode is diclared"
+ " to bank transfer, but no bank/account information found");
else
{
procDetail.BranchID = employee.BranchID;
procDetail.AccountNo = employee.AccountNo;
Branch branch = new Branch();
branch = obranches.GetItem(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);
}
UpdateProgressStatus(EnumProcessStatus.End);
}
private void AddProcessStatus(Employee employee, string remarks)
{
CarFuelProcessStatus status = new CarFuelProcessStatus();
status.EmployeeNo = employee.EmployeeNo;
status.Name = employee.Name;
status.Remarks = remarks;
_processStatuses.Add(status);
}
private void CalculateBasicSalary()
{
UpdateProgressStatus(EnumProcessStatus.Start);
//GetCurrentMonthSalaryItems function return current month's employee grade, salary and effect date.
//effect date must sorted, otherwise error will be generated from next function.
#region Calculate Normal Salary
ObjectsTemplate<EmployeeGradeSalary> gradeSalaryItems = EmployeeGradeSalary.Service.GetCurrMonthSalaryItems(SystemInformation.CurrentSysInfo.NextPayProcessDate);
foreach (CarFuelProcessDetail CarFuelProcess in _processDetails)
{
UpdateProgressStatus(EnumProcessStatus.PerformStep);
CarFuelProcess.GradeSalaries = EmployeeGradeSalary.Get(gradeSalaryItems, CarFuelProcess.EmployeeID);
if (CarFuelProcess.GradeSalaries.Count == 0) continue;
EmployeeGradeSalary.PrepareDataForCurrentSalary(CarFuelProcess.Employee, CarFuelProcess.GradeSalaries);
}
#endregion Calculate Normal Salary
#region calculate arrear amount
ObjectsTemplate<EmployeeGradeSalary> arrearItems = EmployeeGradeSalary.Service.GetArrearItems();
foreach (CarFuelProcessDetail CarFuelProcess in _processDetails)
CarFuelProcess.ArrearGradeSalaries = EmployeeGradeSalary.Get(arrearItems, CarFuelProcess.EmployeeID);
#endregion calculate arrear amount
UpdateProgressStatus(EnumProcessStatus.End);
}
private void CarFuelItems()
{
try
{
UpdateProgressStatus(EnumProcessStatus.Start);
_CarFuelParameters = CarFuelParameter.Get(EnumStatus.Active);
if (_CarFuelParameters == null || _CarFuelParameters.Count == 0) return;
ObjectsTemplate<CarFuelParameterIndividual> CarFuelIndividuals = CarFuelParameterIndividual.Service.Get(
GlobalFunctions.FirstDateOfMonth(_processMonth),
GlobalFunctions.LastDateOfMonth(_processMonth));
CarFuelParameter paramter = new CarFuelParameter();
ObjectsTemplate<CarFuelParameter> parameters;
foreach (CarFuelProcessDetail detail in _processDetails)
{
UpdateProgressStatus(EnumProcessStatus.PerformStep);
parameters = paramter.ApplicableParameters(detail.Employee, detail, _CarFuelParameters, 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.GradeDefinedCarFuelItem(detail, parameters);
this.IndividualCarFuelItem(detail, CarFuelIndividuals, detail.GradeSalaries);
}
}
catch (Exception ex)
{
throw new ServiceException(ex.Message);
}
}
private void CarFuelItemsLC(ObjectsTemplate<ITEmpHead> oComCars)
{
int ncount = 1;
try
{
UpdateProgressStatus(EnumProcessStatus.Start);
_CarFuelParameters = CarFuelParameter.Get(EnumStatus.Active);
if (_CarFuelParameters == null || _CarFuelParameters.Count == 0) return;
//ObjectsTemplate<CarFuelParameterIndividual> CarFuelIndividuals = CarFuelParameterIndividual.Service.Get(
// GlobalFunctions.FirstDateOfMonth(_processMonth),
// GlobalFunctions.LastDateOfMonth(_processMonth));
CarFuelParameter paramter = new CarFuelParameter();
ObjectsTemplate<CarFuelParameter> parameters;
foreach (CarFuelProcessDetail detail in _processDetails)
{
if (ncount == 102)
ncount = 102;
ITEmpHead car = oComCars.Find(x => x.EmployeeID == detail.EmployeeID && (_processMonth >= x.StartDate && _processMonth <= x.EndDate));
if (car == null) continue;
UpdateProgressStatus(EnumProcessStatus.PerformStep);
parameters = paramter.ApplicableParameters(detail.Employee, detail, _CarFuelParameters,detail.GradeSalaries);
if (parameters == null || parameters.Count == 0) continue;// { throw new ServiceException(" Applicable parameter not found for the employee :" + detail.Employee.EmployeeNo + " and Grade:" + detail.Employee.Grade.Code); }
//this.GradeDefinedCarFuelItem(detail , parameters);
this.IndividualCarFuelItemLC(detail, parameters);
ncount++;
}
}
catch (Exception ex)
{
throw new ServiceException(ex.Message);
}
}
private void Add(CarFuelProcessDetail processDetail, CarFuelProcessDetailItem item)
{
CarFuelProcessDetailItem existItem = processDetail.CarFuelProcessDetailItems.Find(delegate(CarFuelProcessDetailItem fItem) { return fItem.CarFuelItemID == item.CarFuelItemID; });
if (existItem == null)
{
processDetail.CarFuelProcessDetailItems.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 GradeDefinedCarFuelItem(CarFuelProcessDetail detail,
ObjectsTemplate<CarFuelParameter> parameters)
{
double amount = 0, paidAmount = 0;
int paidMonth = 0;
double indvAmnt = 0;
int nNumOfEmp = 0;
foreach (CarFuelParameter parameter in parameters)
{
if (parameter.EntitleType != EnumEntitleType.Grade) continue;
CarFuelProcessDetailItem opdItem = new CarFuelProcessDetailItem();
switch (parameter.CarFuelPeriodicity)
{
case EnumCarFuelPeriodicity.Monthly:
if (parameter.IsEarnedBasic == true)
{
SalaryMonthly omonthlysalary = SalaryMonthly.Get(detail.EmployeeID, _processMonth);
if (omonthlysalary != null)
{
amount = omonthlysalary.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
amount = amount + omonthlysalary.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
amount = amount - omonthlysalary.GetAmount(EnumSalaryGroup.UnauthLeave, EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
}
amount = parameter.GetGradeDefinedAmount(detail.Employee, amount, 0, 1);
}
else
{
EmployeeGradeSalary.PrepareDataForCurrentSalary(detail.Employee, detail.GradeSalaries);
amount = parameter.GetGradeDefinedAmount(detail.Employee, detail.GradeSalaries);
foreach (EmployeeGradeSalary arrearItem in detail.ArrearGradeSalaries)
{
arrearItem.FractionofFromTo = GlobalFunctions.GetFraction(arrearItem.EffectDate, (DateTime)arrearItem.TillDate);
amount = amount + parameter.GetGradeDefinedAmount(detail.Employee, arrearItem);
amount = amount - CarFuelProcess.GetAmountOnRange(detail.Employee, arrearItem.EffectDate, (DateTime)arrearItem.TillDate,
parameter.CarFuelItemID.Integer, parameter.ID.Integer);
amount = GlobalFunctions.Round(amount);
}
}
if (amount > 0)
{
opdItem.NetAmount = GlobalFunctions.Round(amount);
opdItem.ChangeNetAmount = GlobalFunctions.Round(amount);
}
else
{
continue;
}
break;
case EnumCarFuelPeriodicity.OnceOff:
break;
case EnumCarFuelPeriodicity.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 dFromCarFuelMonth, dToCarFuelMonth;
dFromCarFuelMonth = new DateTime(_processMonth.Year, 1, 1);
paidMonth = Convert.ToInt32(_processMonth.Date.Month) - 1;
if (paidMonth <= 0)
dToCarFuelMonth = new DateTime(_processMonth.Year, dFromCarFuelMonth.Date.Month, (GlobalFunctions.LastDateOfMonth(dFromCarFuelMonth)).Date.Day);
else
dToCarFuelMonth = new DateTime(_processMonth.Year, paidMonth, 1);
paidAmount = GlobalFunctions.Round(CarFuelProcess.GetPrevMonthAmount(detail.EmployeeID, parameter.CarFuelItemID, dFromCarFuelMonth, GlobalFunctions.LastDateOfMonth(dToCarFuelMonth)));
if (_processMonth.Month == 12)
{
if (detail.Employee.JoiningDate > Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfYear(dFromCarFuelMonth))
{
int dDays = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", detail.Employee.JoiningDate,
Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfYear(dFromCarFuelMonth)) + 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.CoreV35.Utility.Global.DateFunctions.FirstDateOfYear(dFromCarFuelMonth))
{
int dDays = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", detail.Employee.JoiningDate,
Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfYear(dFromCarFuelMonth)) +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 EnumCarFuelPeriodicity.AveragePayment:
// //find the number of month specific salary item from salary monthly defined in CarFuel 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 = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.AddMonths((parameter.NoOfMonth) * (-1)));
// dToDate = GlobalFunctions.LastDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.AddMonths(-1));
// dFromDate = GlobalFunctions.FirstDateOfMonth(dFromDate);
// SalaryMonthly omonthly = new SalaryMonthly();
// switch (parameter.CarFuelAvgPayType)
// {
// case EnumCarFuelAvgPayType.OT:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Over_Time_Amount, parameter.CarFuelAvgPayItemID.Integer);
// break;
// case EnumCarFuelAvgPayType.Allowance:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, parameter.CarFuelAvgPayItemID.Integer);
// break;
// case EnumCarFuelAvgPayType.Deduction:
// salaryPaidAmount = omonthly.GetAmountOnRange(detail.Employee, dFromDate, dToDate, EnumSalaryGroup.Deductions, EnumSalaryItemCode.Deduction, parameter.CarFuelAvgPayItemID.Integer);
// break;
// default:
// break;
// }
// amount = 0;
// if (parameter.NoOfMonth != 0)
// amount = salaryPaidAmount / (double)parameter.NoOfMonth;
// opdItem.NetAmount = GlobalFunctions.Round(amount);
// opdItem.ChangeNetAmount = opdItem.NetAmount;
// break;
case EnumCarFuelPeriodicity.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
//
nNumOfEmp = parameter.NoOfAplicableEmp;
if (nNumOfEmp != 0)
indvAmnt = parameter.ProvisionAmount / (double)nNumOfEmp;
opdItem.NetAmount = GlobalFunctions.Round(indvAmnt);
opdItem.ChangeNetAmount = GlobalFunctions.Round(indvAmnt);
break;
//case EnumCarFuelPeriodicity.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.CarFuelAvgPayItemID.Integer);
// int paidItem = BonusProcess.GetForNoOfPaid(_processMonth, parameter.CarFuelAvgPayItemID.Integer);
// double provisionedAmount = GlobalFunctions.Round(CarFuelProcess.GetPrevMonthAmount(detail.EmployeeID,
// parameter.CarFuelItemID, new DateTime(_processMonth.Year, 1, 1), GlobalFunctions.LastDateOfMonth(_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.CarFuelAvgPayItemID);
// willProvision = annualBonusPaidinYear + ((bonusParameter.NoOfBasic - paidItem) * detail.Employee.BasicSalary );
// willProvision = willProvision - provisionedAmount;
// willProvision = willProvision / restofMonth;
// }
// else
// {
// willProvision = annualBonusPaidinYear - provisionedAmount;
// }
// opdItem.NetAmount = GlobalFunctions.Round(willProvision);
// opdItem.ChangeNetAmount = GlobalFunctions.Round(willProvision);
// break;
case EnumCarFuelPeriodicity.EarnedLeave:
// Number of employee of the parameter selected grade - not applicable employees
// if gender applicable then remove other gender
// if confirmed checked then remove unconfirmed
//
nNumOfEmp = parameter.NoOfAplicableEmp;
if (nNumOfEmp != 0)
indvAmnt = ((detail.Employee.BasicSalary / 22) * parameter.FlatAmount) / 12;
opdItem.NetAmount = GlobalFunctions.Round(indvAmnt);
opdItem.ChangeNetAmount = GlobalFunctions.Round(indvAmnt);
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;
}
CarFuelItem CarFueltem = _CarFuelItems.GetItem(parameter.CarFuelItem.ID);
opdItem.Description = CarFueltem.Name;
opdItem.CarFuelItemID = parameter.CarFuelItemID;
opdItem.CarFuelType = CarFueltem.CarFuelType;
opdItem.Sequence = CarFueltem.Sequence;
opdItem.Paramter = parameter;
this.Add(detail, opdItem); // add the item in the collection
}
}
public void DeleteCarFuelProcess(DateTime dCarFuelMonth)
{
CarFuelProcess.Undo(dCarFuelMonth);
}
private void IndividualCarFuelItem(CarFuelProcessDetail detail, ObjectsTemplate<CarFuelParameterIndividual> CarFuelIndividuals
, ObjectsTemplate<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<CarFuelParameterIndividual> items = CarFuelIndividuals.FindAll(delegate(CarFuelParameterIndividual item)
{
return item.EmployeeId.Integer == detail.Employee.ID.Integer && item.IndividualType == EnumCarFuelIndivdualType.AppliedToIndividual;
});
foreach (CarFuelParameterIndividual item in items)
{
amount = 0;
CarFuelParameter parameter = _CarFuelParameters.GetItem(item.CarFuelParameterID);
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);
//}
CarFuelProcessDetailItem opdItem = new CarFuelProcessDetailItem();
if (amount > 0)
{
opdItem.NetAmount = GlobalFunctions.Round(amount);
opdItem.ChangeNetAmount = GlobalFunctions.Round(amount);
}
else
{
continue;
}
opdItem.CarFuelItemID = parameter.CarFuelItemID;
CarFuelItem CarFueltem=_CarFuelItems.GetItem(parameter.CarFuelItem.ID);
opdItem.CarFuelType = CarFueltem.CarFuelType;
opdItem.Sequence = CarFueltem.Sequence;
opdItem.Description = CarFueltem.Name;
//opdItem.Paramter = parameter;//new
this.Add(detail, opdItem); // add the item in the collection
}
#endregion Individual Allowance
}
private void IndividualCarFuelItemLC(CarFuelProcessDetail detail, ObjectsTemplate<CarFuelParameter> CarFuelParameter)
{
// currently we are not provisioning any kind of discontinued employee
// but in future we need this.
DateTime dCurrentMonth=Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
double amount = 0;
#region Individual Allowance
amount = 0;
CarFuelParameter parameter =CarFuelParameter.Count>0? CarFuelParameter[0]:new CarFuelParameter();
//amount = parameter.GetIndividualAmount(detail.Employee, _processMonth, item, detail.Employee.BasicSalary, detail.Employee.GrossSalary);
if (parameter == null) return;
EmployeeGradeSalary egs = EmployeeGradeSalary.GetBasicOnDate(detail.EmployeeID, dCurrentMonth);
//amount = (egs.BasicSalary * parameter.PercentOfBasic)/100;
amount = parameter.FlatAmount;
//foreach(EmployeeGradeSalary oItem in gradeSalaries)
//{
// amount = amount + parameter.GetIndividualAmount(detail.Employee, _processMonth, item, detail.Employee.BasicSalary, detail.Employee.GrossSalary, oItem.FractionofFromTo);
//}
CarFuelProcessDetailItem opdItem = new CarFuelProcessDetailItem();
opdItem.NetAmount = GlobalFunctions.Round(amount);
opdItem.ChangeNetAmount = GlobalFunctions.Round(amount);
opdItem.CarFuelItemID = parameter.CarFuelItemID;
CarFuelItem CarFueltem = _CarFuelItems.GetItem(parameter.CarFuelItem.ID);
opdItem.CarFuelType = CarFueltem.CarFuelType;
opdItem.Sequence = CarFueltem.Sequence;
opdItem.Description = CarFueltem.Name;
//opdItem.Paramter = parameter;//new
this.Add(detail, opdItem); // add the item in the collection
// }
#endregion Individual Allowance
}
}
public class CarFuelProcessStatus
{
public CarFuelProcessStatus()
{
_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
}
}