internal static double GetEndOfServiceCompensation(EmployeesCareersHistoryBLL Employee, EmployeesCareersHistoryBLL HiringRecord, SalaryDetailsBLL Salary, EndOfServicesCasesEnum Reason)
        {
            double Compensation = 0.0;
            var    RankCategory = Employee.EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID;

            if (RankCategory == (int)RanksCategoriesEnum.Employee || RankCategory == (int)RanksCategoriesEnum.User)
            {
                if (Reason == EndOfServicesCasesEnum.Death || Reason == EndOfServicesCasesEnum.Resignation || Reason == EndOfServicesCasesEnum.Retirement || Reason == EndOfServicesCasesEnum.Termination)
                {
                    return(Salary.Benefits.BasicSalary * 6);
                }
                else
                {
                    return(Salary.Benefits.BasicSalary * 4);
                }
            }

            else if (RankCategory == (int)RanksCategoriesEnum.ContractualSaudis || RankCategory == (int)RanksCategoriesEnum.SaudiLabor || RankCategory == (int)RanksCategoriesEnum.ContractualExpats)
            {
                double YearsCount = CompensationCalculationsForMICEmployees.GetServicePeriodByUmAlquraYears(HiringRecord.JoinDate);
                if (Reason == EndOfServicesCasesEnum.Death || Reason == EndOfServicesCasesEnum.Resignation || Reason == EndOfServicesCasesEnum.Retirement || Reason == EndOfServicesCasesEnum.Termination)
                {
                    Compensation = CommonHelper.CalculateEndOfServiceCompensation(Salary.TotalSalary, YearsCount);
                }
                else
                {
                    // later we will calcuate it
                    Compensation = 0;
                }
            }

            return(Math.Round(Compensation, 2));
        }
示例#2
0
        internal static double GetEndOfServiceCompensation(DateTime?HiringDate, double TotalSalary, EndOfServicesCasesEnum Reason)
        {
            double Compensation = 0.0;

            double YearsCount = CompensationCalculationsForMICEmployees.GetServicePeriodByUmAlquraYears(HiringDate.Value.Date);

            if (Reason == EndOfServicesCasesEnum.Death || Reason == EndOfServicesCasesEnum.Resignation || Reason == EndOfServicesCasesEnum.Retirement || Reason == EndOfServicesCasesEnum.Termination)
            {
                Compensation = CommonHelper.CalculateEndOfServiceCompensation(TotalSalary, YearsCount);
            }
            else
            {
                // later we will calcuate it
                Compensation = 0;
            }

            return(Math.Round(Compensation, 2));
        }
示例#3
0
        public List <EmployeesBenefitsAfterEndOfServiceBLL> GetEmployeesBenefits(string EmployeeCodeNo)
        {
            try
            {
                List <EmployeesBenefitsAfterEndOfServiceBLL> EmployeesBenefitsBLLList = new List <EmployeesBenefitsAfterEndOfServiceBLL>();
                List <SalaryDetailsBLL>        SalaryDetailsList          = new List <SalaryDetailsBLL>();
                List <EmployeesCareersHistory> ActiveEmployeesList        = string.IsNullOrEmpty(EmployeeCodeNo) ? new EmployeesCareersHistoryDAL().GetActiveEmployeesCareersHistory().ToList() : new EmployeesCareersHistoryDAL().GetActiveEmployeesCareersHistory(EmployeeCodeNo).ToList();
                List <EmployeesCareersHistory> EmployeesHiringRecordsList = string.IsNullOrEmpty(EmployeeCodeNo) ? new EmployeesCareersHistoryDAL().GetHiringRecordsForEmployees().ToList() : new EmployeesCareersHistoryDAL().GetHiringRecordsForEmployees(EmployeeCodeNo).ToList();
                List <EmployeesAllowancesBLL>  AllowancesList             = string.IsNullOrEmpty(EmployeeCodeNo) ? new EmployeesAllowancesBLL().GetEmployeesAllowances().ToList() : new EmployeesAllowancesBLL().GetEmployeesAllowances(EmployeeCodeNo);
                //List<EmployeesAllowancesBLL> AllowancesList = new List<EmployeesAllowancesBLL>();
                List <GovernmentFundsBLL> GovernmentFundsList     = string.IsNullOrEmpty(EmployeeCodeNo) ? new GovernmentFundsBLL().GetGovernmentFunds() : new GovernmentFundsBLL().GetGovernmentFunds(EmployeeCodeNo);
                List <BasicSalariesBLL>   BasicSalariesDefination = new BasicSalariesBLL().GetBasicSalaries();
                List <RanksBLL>           Ranks = new RanksBLL().GetRanks();
                List <EmployeesNormalVacationsBalances> EmployeesNormalVacationsBalancesList = new EmployeesNormalVacationsBalancesDAL().GetNormalVacationsBalances();

                foreach (var item in ActiveEmployeesList)
                {
                    EmployeesBenefitsAfterEndOfServiceBLL EmployeeBenefitsAfterEndOfServiceBLL = new EmployeesBenefitsAfterEndOfServiceBLL();
                    EmployeesCareersHistoryBLL            EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(item);
                    EmployeeCareerHistory.EmployeeCode.EmployeeCurrentJob = EmployeeCareerHistory;

                    EmployeeBenefitsAfterEndOfServiceBLL.EmployeeCareerHistory = EmployeeCareerHistory;
                    EmployeeBenefitsAfterEndOfServiceBLL.SalaryDetails         = new SalaryDetailsBLL().GetSalaryDetailsByEmployeeCodeNo(EmployeeCareerHistory.EmployeeCode,
                                                                                                                                         AllowancesList,
                                                                                                                                         GovernmentFundsList,
                                                                                                                                         BasicSalariesDefination,
                                                                                                                                         Ranks);
                    EmployeeBenefitsAfterEndOfServiceBLL.SalaryDetails.Employee = EmployeeCareerHistory;

                    #region NormalVacationBalanceCompensation
                    EmployeesNormalVacationsBalances ee = EmployeesNormalVacationsBalancesList.FirstOrDefault(x => x.EmployeeCodeID == EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
                    if (ee is null)
                    {
                        ee = new EmployeesNormalVacationsBalances();
                    }
                    EmployeeBenefitsAfterEndOfServiceBLL.TotalRemainingBalance = ee.TotalRemainingBalance;
                    EmployeeBenefitsAfterEndOfServiceBLL.RemainingNormalVacationBalanceCompensation = Math.Round(CompensationCalculationsForMICEmployees.GetNormalVacationCompensation(EmployeeCareerHistory,
                                                                                                                                                                                       EmployeeBenefitsAfterEndOfServiceBLL.SalaryDetails,
                                                                                                                                                                                       ee.TotalRemainingBalance), 2);
                    #endregion

                    #region EndOfServiceCompensation
                    EmployeeBenefitsAfterEndOfServiceBLL.EmployeeHiringRecord     = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeesHiringRecordsList.FirstOrDefault(x => x.EmployeeCodeID == item.EmployeeCodeID));
                    EmployeeBenefitsAfterEndOfServiceBLL.ServicePeriod            = CompensationCalculationsForMICEmployees.GetServicePeriodByUmAlquraYears(EmployeeBenefitsAfterEndOfServiceBLL.EmployeeHiringRecord != null ? EmployeeBenefitsAfterEndOfServiceBLL.EmployeeHiringRecord.JoinDate.Date : (DateTime?)null).ToString();
                    EmployeeBenefitsAfterEndOfServiceBLL.EndOfServiceCompensation = CompensationCalculationsForMICEmployees.GetEndOfServiceCompensation(EmployeeBenefitsAfterEndOfServiceBLL.EmployeeCareerHistory,
                                                                                                                                                        EmployeeBenefitsAfterEndOfServiceBLL.EmployeeHiringRecord,
                                                                                                                                                        EmployeeBenefitsAfterEndOfServiceBLL.SalaryDetails,
                                                                                                                                                        Enums.EndOfServicesCasesEnum.Retirement);
                    #endregion

                    #region AdditionalCompensation
                    EmployeeBenefitsAfterEndOfServiceBLL.RemainingYearsCountInService = CompensationCalculationsForMICEmployees.GetRemainingYearsInService(item.EmployeesCodes.Employees.EmployeeBirthDate != null ? item.EmployeesCodes.Employees.EmployeeBirthDate : (DateTime?)null);

                    EmployeeBenefitsAfterEndOfServiceBLL.AdditionalCompensation = CompensationCalculationsForMICEmployees.GetAdditionalCompensation(EmployeeBenefitsAfterEndOfServiceBLL.EmployeeCareerHistory,
                                                                                                                                                    EmployeeBenefitsAfterEndOfServiceBLL.SalaryDetails,
                                                                                                                                                    EmployeeBenefitsAfterEndOfServiceBLL.RemainingYearsCountInService,
                                                                                                                                                    double.Parse(EmployeeBenefitsAfterEndOfServiceBLL.ServicePeriod));
                    #endregion

                    EmployeesBenefitsBLLList.Add(EmployeeBenefitsAfterEndOfServiceBLL);
                }
                return(EmployeesBenefitsBLLList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }