internal static double GetAdditionalCompensation(EmployeesCareersHistoryBLL Employee, SalaryDetailsBLL Salary, double RemainingYearsCountInService, double YearsCountInService) { var RankCategory = Employee.EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID; if (RankCategory == (int)RanksCategoriesEnum.Employee || RankCategory == (int)RanksCategoriesEnum.User) { if (YearsCountInService >= 20) // 20 years { return(RemainingYearsCountInService * Salary.Benefits.BasicSalary * 2); } else { return(AdditionalCompensationInSomeCases); } } else if (RankCategory == (int)RanksCategoriesEnum.ContractualSaudis || RankCategory == (int)RanksCategoriesEnum.SaudiLabor || RankCategory == (int)RanksCategoriesEnum.ContractualExpats) { if (YearsCountInService >= 25) // 25 years { return(RemainingYearsCountInService * Salary.TotalSalary * 2); } else { return(AdditionalCompensationInSomeCases); } } return(0); }
public virtual Result Update() { Result result = null; #region Checking new transfer record date must be less than 'Join Date' of hiring record EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID); if (HiringRecord != null && HiringRecord.JoinDate.Date >= this.TransferDate.Date) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = TransfersValidationEnum.RejectedBecauseOfTransferDateIsLessThanHiringDateDate.ToString(); return(result); } #endregion #region Checking the transfer record is proceede or not bool IsDone = this.IsAlreadyProcessed(this.TransferID); if (IsDone) { result = new Result(); result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = TransfersValidationEnum.RejectedBecauseOfAlreadyProcessed.ToString(); return(result); } #endregion return(result); }
public List <SalaryDetailsBLL> GetSalaryDetails(string EmployeeCodeNo) { try { List <SalaryDetailsBLL> SalaryDetailsList = new List <SalaryDetailsBLL>(); List <EmployeesCareersHistory> EmployeesBLLs = string.IsNullOrEmpty(EmployeeCodeNo) ? new EmployeesCareersHistoryDAL().GetActiveEmployeesCareersHistory() : new EmployeesCareersHistoryDAL().GetActiveEmployeesCareersHistory(EmployeeCodeNo);//.Take(200).ToList();//.Where(x=> x.EmployeesCodes.EmployeeCodeNo == EmployeeCodeNo).ToList(); List <EmployeesAllowancesBLL> Allowances = string.IsNullOrEmpty(EmployeeCodeNo) ? new EmployeesAllowancesBLL().GetEmployeesAllowances() : new EmployeesAllowancesBLL().GetEmployeesAllowances(EmployeeCodeNo); List <GovernmentFundsBLL> GovernmentFunds = string.IsNullOrEmpty(EmployeeCodeNo) ? new GovernmentFundsBLL().GetGovernmentFunds() : new GovernmentFundsBLL().GetGovernmentFunds(EmployeeCodeNo); List <BasicSalariesBLL> BasicSalariesDefination = new BasicSalariesBLL().GetBasicSalaries(); List <RanksBLL> Ranks = new RanksBLL().GetRanks(); foreach (var item in EmployeesBLLs) { SalaryDetailsBLL SalaryDetail = new SalaryDetailsBLL(); EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(item); EmployeeCareerHistory.EmployeeCode.EmployeeCurrentJob = EmployeeCareerHistory; SalaryDetail = this.GetSalaryDetailsByEmployeeCodeNo(EmployeeCareerHistory.EmployeeCode, Allowances, GovernmentFunds, BasicSalariesDefination, Ranks); SalaryDetail.Employee = EmployeeCareerHistory; SalaryDetailsList.Add(SalaryDetail); } return(SalaryDetailsList); } catch (Exception) { throw; } }
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)); }
public EmployeesCareersHistoryBLL MapEmployeeCareerHistory(EmployeesCareersHistory EmployeeCareerHistory) { try { EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = null; if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = EmployeeCareerHistory.EmployeeCareerHistoryID, CareerHistoryType = new CareersHistoryTypesBLL().MapCareerHistoryType(EmployeeCareerHistory.CareersHistoryTypes), CareerDegree = new CareersDegreesBLL().MapCareerDegree(EmployeeCareerHistory.CareersDegrees), OrganizationJob = new OrganizationsJobsBLL().MapOrganizationJob(EmployeeCareerHistory.OrganizationsJobs), EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = EmployeeCareerHistory.EmployeeCodeID, EmployeeCodeNo = EmployeeCareerHistory.EmployeesCodes.EmployeeCodeNo, Employee = new EmployeesBLL().MapEmployee(EmployeeCareerHistory.EmployeesCodes.Employees) }, JoinDate = EmployeeCareerHistory.JoinDate, TransactionStartDate = EmployeeCareerHistory.TransactionStartDate, TransactionEndDate = EmployeeCareerHistory.TransactionEndDate, IsActive = EmployeeCareerHistory.IsActive, CreatedDate = EmployeeCareerHistory.CreatedDate, }; } return(EmployeeCareerHistoryBLL); } catch (Exception ex) { throw ex; } }
public EmployeesCareersHistoryBLL GetHiringRecordByEmployeeCareerHistoryID(int EmployeeCareerHistoryID) { int EmployeeCodeID = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(EmployeeCareerHistoryID).EmployeeCode.EmployeeCodeID; EmployeesCareersHistoryBLL Obj = new EmployeesCodesBLL().GetCareerHistoryByEmployeeCodeID(EmployeeCodeID).FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID.Equals(EmployeeCodeID) && x.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)); return(Obj); }
public override Result Edit() { this.EmployeeCareerHistory = this.GetByVacationID(this.VacationID).EmployeeCareerHistory; // to get EmployeeCodeID Result result = new Result(); #region Validation for vacation creation during probation period EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { // probation period = hiring date + 1 year DateTime ProbationEndDate = HiringRecord.ProbationEndDate;//.JoinDate.AddYears(1).AddDays(-10); if (ProbationEndDate > this.VacationStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString(); return(result); } } #endregion #region Validation for balanace //result = IsBalanceValid(this.VacationID); //if (result != null) // return result; if (this.VacationPeriod > this.VacationBalance) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString(); return(result); } #endregion #region Validation for dates if (this.VacationStartDate > DateTime.Now) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfInvalidStartDate.ToString(); return(result); } #endregion #region base validation result = base.Edit(); #endregion return(result); }
//public List<EmployeesCareersHistoryBLL> GetDeservedEmployeesInPromotion(int RankID, DateTime PromotionEndDate, int DaysCount) //{ // List<EmployeesCareersHistoryBLL> DeservedEmployeesBLLList = new List<EmployeesCareersHistoryBLL>(); // List<EmployeesCareersHistory> DeservedEmployeesList = new EmployeesCareersHistoryDAL().GetActiveEmployeesByRankID(RankID).Where(x => PromotionEndDate >= x.JoinDate.AddDays(DaysCount)).ToList(); // foreach (var item in DeservedEmployeesList) // { // DeservedEmployeesBLLList.Add(new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(item)); // } // return DeservedEmployeesBLLList; //} // public EmployeesCareersHistoryBLL GetDeservedEmployeeInPromotionByEmployeeCodeID(int EmployeeCodeID, DateTime PromotionEndDate, int DaysCount) // { //reutthis.GetEmployeeCurrentJob(EmployeeCodeID) // } public EmployeesCareersHistoryBLL Get(OrganizationsJobsBLL OrganizationJob, CareersHistoryTypesEnum CareerHistoryType, EmployeesCodesBLL EmployeeCode) { EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistoryDAL().GetByOrganizationJobIDEmployeeCodeIDCareerHistoryTypeID(OrganizationJob.OrganizationJobID, (int)CareerHistoryType, EmployeeCode.EmployeeCodeID); EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = null; if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeeCareerHistory); } return(EmployeeCareerHistoryBLL); }
public EmployeesCareersHistoryBLL GetEmployeeCurrentJob(int EmployeeCodeID) { EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistoryDAL().GetActiveJobByEmployeeCodeID(EmployeeCodeID); EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL(); if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeeCareerHistory); } return(EmployeeCareerHistoryBLL); }
public EmployeesCareersHistoryBLL GetByEmployeeCareerHistoryID(int EmployeeCareerHistoryID) { EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistoryDAL().GetEmployeesCareersHistoryByEmployeeCareerHistoryID(EmployeeCareerHistoryID); EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL(); if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeeCareerHistory); } return(EmployeeCareerHistoryBLL); }
public override Result Add() { try { Result result = new Result(); //bool IsValid = false; #region Validation for vacation creation during probation period EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { // probation period = hiring date + 1 year DateTime ProbationEndDate = HiringRecord.ProbationEndDate;//.JoinDate.AddYears(1).AddDays(-10); if (ProbationEndDate > this.VacationStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString(); return(result); } } #endregion //#region Validation for balanace //IsValid = this.VacationPeriod > this.VacationRemainingBalance ? false : true; //if (!IsValid) //{ // result = new Result(); // result.Entity = null; // result.EnumType = typeof(VacationsValidationEnum); // result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString(); // return result; //} //#endregion #region base validation result = base.Add(); //if (result != null) // return result; #endregion return(result); } catch { throw; } }
public Result IncreaseCareerDegree(EmployeesCareersHistoryBLL EmpCareerHistory) { try { Result result = new Result(); int newCareerDegree = EmpCareerHistory.CareerDegree.CareerDegreeID + 1; #region Check newCareerDegree Exist In CareerDegree table. if (!new CareersDegreesBLL().GetCareersDegrees().Exists(c => c.CareerDegreeID == newCareerDegree)) { result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfCareerDegreeOutOfRange.ToString(); return(result); } #endregion // checking if new career degree & rank has 'basic salary' exists or not, if not exists skip if (EmpCareerHistory.OrganizationJob != null && EmpCareerHistory.OrganizationJob.Rank != null) { BasicSalariesBLL BasicSalary = new BasicSalariesBLL().GetBasicSalary(EmpCareerHistory.OrganizationJob.Rank.RankID, newCareerDegree); if (BasicSalary.BasicSalary <= 0) { result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfCareerDegreeOutOfRange.ToString(); return(result); } } #region Update record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = EmpCareerHistory.EmployeeCareerHistoryID, CareerDegreeID = newCareerDegree, LastUpdatedBy = EmpCareerHistory.LoginIdentity != null ? EmpCareerHistory.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, }; new EmployeesCareersHistoryDAL().UpdateCareerDegree(EmployeeCareerHistory); #endregion result.Entity = EmpCareerHistory; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
public virtual Result Update() { Result result = new Result(); result.EnumType = typeof(AllowanceValidationEnum); EmployeesAllowances EmployeeAllowance = new EmployeesAllowances(); EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID); //if ((new JobsAllowancesBLL()).IsAllowedAllowanceForJob(EmployeeCareerHistory.OrganizationJob.Job.JobID, this.Allowance.AllowanceID) == AllowanceAllowEnum.NotAllowedBecauseOfNotAllowedForJob) // not in jobAllowance table //{ // result.EnumMember = AllowanceValidationEnum.RejectedBecauseOfNotAllowedForJob.ToString(); //} if ((new AllowancesBLL()).IsAllowanceActive(this.Allowance.AllowanceID) == AllowanceAllowEnum.NotAllowedBecauseOfStoped) // allowance inactive { result.EnumMember = AllowanceValidationEnum.RejectedBecauseOfStoped.ToString(); } //else if ((new JobsAllowancesBLL()).IsJobAllowanceActive(EmployeeCareerHistory.OrganizationJob.Job.JobID, this.Allowance.AllowanceID) == AllowanceAllowEnum.NotAllowedBecauseOfStopedForJob) // job inactive //{ // result.EnumMember = AllowanceValidationEnum.RejectedBecauseOfStopedForJob.ToString(); //} else { result.Entity = this; result.EnumMember = AllowanceValidationEnum.Done.ToString(); } if (result.EnumMember == AllowanceValidationEnum.Done.ToString()) { EmployeeAllowance.EmployeeAllowanceID = this.EmployeeAllowanceID; EmployeeAllowance.AllowanceID = this.Allowance.AllowanceID; EmployeeAllowance.EmployeeCareerHistoryID = this.EmployeeCareerHistory.EmployeeCareerHistoryID; EmployeeAllowance.AllowanceStartDate = this.AllowanceStartDate; EmployeeAllowance.IsActive = this.IsActive; EmployeeAllowance.LastUpdatedDate = DateTime.Now; EmployeeAllowance.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; this.EmployeeAllowanceID = new EmployeesAllowancesDAL().Update(EmployeeAllowance); if (this.EmployeeAllowanceID != 0) { result.Entity = this; result.EnumMember = AllowanceValidationEnum.Done.ToString(); } } return(result); }
public EmployeesCareersHistoryBLL GetEmployeePreviousJob(int EmployeeCodeID) { EmployeesCareersHistoryBLL CurrentJob = this.GetEmployeeCurrentJob(EmployeeCodeID); RanksBLL PreviousRank = new RanksBLL().GetPreviousRankByRankID(CurrentJob.OrganizationJob.Rank.RankID); EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistoryDAL().GetByEmployeeCodeIDRankID(EmployeeCodeID, PreviousRank.RankID); EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL(); if (EmployeeCareerHistory != null) { EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeeCareerHistory); } return(EmployeeCareerHistoryBLL); }
internal static double GetNormalVacationCompensation(EmployeesCareersHistoryBLL Employee, SalaryDetailsBLL Salary, int RemainingNormalVacationBalance) { var RankCategory = Employee.EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RankCategoryID; if (RankCategory == (int)RanksCategoriesEnum.Employee || RankCategory == (int)RanksCategoriesEnum.User) { var DaysWillBeCalculatedBasedOnIt = RemainingNormalVacationBalance <= MaxNormalVacationBalanceForNormalEmployee ? RemainingNormalVacationBalance : MaxNormalVacationBalanceForNormalEmployee; return(DaysWillBeCalculatedBasedOnIt * (Salary.Benefits.BasicSalary / DaysInUmAlquraMonth)); } else if (RankCategory == (int)RanksCategoriesEnum.ContractualSaudis || RankCategory == (int)RanksCategoriesEnum.SaudiLabor || RankCategory == (int)RanksCategoriesEnum.ContractualExpats) { return(RemainingNormalVacationBalance * (Salary.TotalSalary / DaysInUmAlquraMonth)); } return(0); }
public virtual Result Add() { Result result = null; #region checking new transfer record date must be less than 'Join Date' of hiring record EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID); if (HiringRecord != null && HiringRecord.JoinDate.Date >= this.TransferDate.Date) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = TransfersValidationEnum.RejectedBecauseOfTransferDateIsLessThanHiringDateDate.ToString(); return(result); } #endregion return(result); }
public virtual OrganizationsStructuresBLL GetCurrentManagerOfEmployee(int EmployeeCareerHistoryID) { try { BaseAssigningsBLL ActiveAssigning = new BaseAssigningsBLL().GetEmployeeActiveAssigning(EmployeeCareerHistoryID); if (ActiveAssigning != null) { return(((InternalAssigningBLL)ActiveAssigning).Organization); } else { string ManagerCodeNo = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(EmployeeCareerHistoryID).EmployeeCode.EmployeeCodeNo; List <OrganizationsStructuresBLL> AllOrganizationsForManager = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(ManagerCodeNo); return(AllOrganizationsForManager.FirstOrDefault().ParentOrganization); } } catch (Exception ex) { throw ex; } }
public virtual Result Add() { Result result = new Result(); result.EnumType = typeof(InsteadDeportationValidationEnum); EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID); InsteadDeportations InsteadDeportation = new InsteadDeportations(); InsteadDeportation.EmployeeCareerHistoryID = this.EmployeeCareerHistory.EmployeeCareerHistoryID; InsteadDeportation.DeportationDate = this.DeportationDate; InsteadDeportation.Amount = this.Amount; InsteadDeportation.Note = this.Note; InsteadDeportation.CreatedDate = DateTime.Now; InsteadDeportation.CreatedBy = this.LoginIdentity.EmployeeCodeID; this.InsteadDeportationID = new InsteadDeportationsDAL().Insert(InsteadDeportation); if (this.InsteadDeportationID != 0) { result.Entity = this; result.EnumMember = AllowanceValidationEnum.Done.ToString(); } return(result); }
private Result IsValid() { Result result = null; #region Validation of Date if (this.StartDate > this.EndDate) { result = new Result(); result.Entity = this; result.EnumType = typeof(TeachersValidationEnum); result.EnumMember = TeachersValidationEnum.RejectedBecauseOfEndDateShouldNotBeLessThanStartDate.ToString(); return(result); } #endregion #region Validation for vacation before hiring or not EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { if (HiringRecord.JoinDate > this.StartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(TeachersValidationEnum); result.EnumMember = TeachersValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString(); return(result); } } #endregion #region Validaion for conflict with Other Process //return CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, this.StartDate, this.EndDate); #endregion return(result); }
/// <summary> /// it will be called by windows service to disactive employee based on transfer date /// </summary> /// <returns></returns> public virtual Result StartProcess() { try { Result result = new Result(); List <BaseTransfersBLL> TransfersNotProcessed = this.GetTransfersNotProcessed(); foreach (var item in TransfersNotProcessed) { CareersHistoryTypesEnum CareerHistoryTypeEnum = item.TransferType.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithJob) ? CareersHistoryTypesEnum.TransfareWithJob : CareersHistoryTypesEnum.TransfareWithoutJob; if (DateTime.Now.Date >= item.TransferDate.Date) { #region Adding new record with new career history type (Transfare With Job) in career history of employees // check if the job was is exists or not EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().Get(item.EmployeeCareerHistory.OrganizationJob, CareerHistoryTypeEnum, item.EmployeeCareerHistory.EmployeeCode); if (EmployeeCareerHistory == null) { result = new EmployeesCareersHistoryBLL() { EmployeeCode = item.EmployeeCareerHistory.EmployeeCode, OrganizationJob = item.EmployeeCareerHistory.OrganizationJob, CareerHistoryType = new CareersHistoryTypesBLL() { CareerHistoryTypeID = (int)CareerHistoryTypeEnum }, CareerDegree = item.EmployeeCareerHistory.CareerDegree, JoinDate = item.TransferDate, TransactionStartDate = item.TransferDate, IsActive = false, LoginIdentity = item.CreatedBy, }.Add(); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } else { #region Disactive all career hsitory of employee new EmployeesCareersHistoryBLL() { LoginIdentity = item.CreatedBy }.DeactivateAllCareerHistoryOfEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); #endregion } } #endregion #region Disactive employee result = new EmployeesCodesBLL() { LoginIdentity = item.CreatedBy }.DeactivateEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion #region Disactive his job in case of transfer type is "Transfare with his job" if (item.TransferType.TransferTypeID == (int)TransfersTypesEnum.TransferEmployeeWithJob) { result = new OrganizationsJobsBLL() { LoginIdentity = item.CreatedBy }.Transferring(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } } #endregion #region Set his job as job vacant in case of transfer type is "Transfare without his job" if (item.TransferType.TransferTypeID == (int)TransfersTypesEnum.TransferEmployeeWithoutJob) { result = new OrganizationsJobsBLL() { LoginIdentity = item.CreatedBy }.SetJobAsVacant(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID); } #endregion #region Update is procees to true result = new BaseTransfersBLL() { LoginIdentity = item.CreatedBy }.MarkIsProcessToDone(item.TransferID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion } } return(result); } catch (Exception ex) { throw ex; } }
public virtual Result Update() { try { Result result = null; #region Validation for vacation creation during probation period EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { // probation period = hiring date + 1 year DateTime ProbationEndDate = HiringRecord.ProbationEndDate;//.JoinDate.AddYears(1).AddDays(-10); if (ProbationEndDate > this.DeductionStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString(); return(result); } } #endregion #region Validation Loan Ammount if (this.MonthlyDeductionAmount > this.TotalDeductionAmount) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfMonthlyDeductionAmountShouldNotGreaterThanTotalDeductionAmount.ToString(); return(result); } #endregion #region Validation Deactivation this.IsActive = new GovernmentFundsBLL().GetByGovernmentFundID(this.GovernmentFundID).IsActive; if (this.IsActive == false) { result = new Result(); result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfAlreadyDeactivated.ToString(); return(result); } #endregion GovernmentFunds GovernmentFund = new GovernmentFunds(); GovernmentFund.GovernmentFundID = this.GovernmentFundID; GovernmentFund.EmployeeCodeID = this.EmployeeCode.EmployeeCodeID; GovernmentFund.GovernmentDeductionTypeID = this.GovernmentDeductionType.GovernmentDeductionTypeID; GovernmentFund.GovernmentFundTypeID = this.GovernmentFundType.GovernmentFundTypeID; GovernmentFund.LoanNo = this.LoanNo; GovernmentFund.LoanDate = this.LoanDate; GovernmentFund.DeductionStartDate = this.DeductionStartDate; GovernmentFund.MonthlyDeductionAmount = this.MonthlyDeductionAmount; GovernmentFund.TotalDeductionAmount = this.TotalDeductionAmount; GovernmentFund.SponserToIDNo = this.GovernmentDeductionType.GovernmentDeductionTypeID == Convert.ToInt16(GovernmentDeductionsTypesEnum.Sponser) ? this.SponserToIDNo : null; GovernmentFund.SponserToName = this.GovernmentDeductionType.GovernmentDeductionTypeID == Convert.ToInt16(GovernmentDeductionsTypesEnum.Sponser) ? this.SponserToName : null; GovernmentFund.ContractNo = this.ContractNo; GovernmentFund.BankIPAN = this.BankIPAN; GovernmentFund.KSACityID = this.KSACity.KSACityID; GovernmentFund.LastUpdatedDate = DateTime.Now; GovernmentFund.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; int UpdateResult = new GovernmentFundsDAL().Update(GovernmentFund); if (UpdateResult != 0) { result = new Result(); result.Entity = this; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
/// <summary> /// This function called by Windows services and schedule to run on daily basis /// This function to get all EOS records from EOStable with isprocessed null/0 and EOSDate is <= Current Date /// Following action is performed: /// 1 - Create Employee Career History record for EOS type /// 2 - Deactivate all Employee Career History records of each EOS record /// 3 - Deactivate employee /// 4 - Set Job as Vacant /// 5 - Mark isProcessed = 1 after successful of above 4 steps /// </summary> /// <returns></returns> public virtual Result StartProcess() { try { Result result = new Result(); List <EndOfServicesBLL> EndOfServicesNotProcessed = this.GetEndOfServicesNotProcessed(); foreach (EndOfServicesBLL item in EndOfServicesNotProcessed) { if (DateTime.Now.Date >= item.EndOfServiceDate.Date) { #region Adding new record with new career history type End of service EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().Get(item.EmployeeCareerHistory.OrganizationJob, CareersHistoryTypesEnum.EndOfService, item.EmployeeCareerHistory.EmployeeCode); if (EmployeeCareerHistory == null) { result = new EmployeesCareersHistoryBLL() { EmployeeCode = item.EmployeeCareerHistory.EmployeeCode, OrganizationJob = item.EmployeeCareerHistory.OrganizationJob, CareerHistoryType = new CareersHistoryTypesBLL() { CareerHistoryTypeID = (int)CareersHistoryTypesEnum.EndOfService }, CareerDegree = item.EmployeeCareerHistory.CareerDegree, JoinDate = item.EndOfServiceDate, TransactionStartDate = item.EndOfServiceDate, IsActive = false, LoginIdentity = item.CreatedBy, }.Add(); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } else { #region Deactivate all career history of employee new EmployeesCareersHistoryBLL() { LoginIdentity = item.CreatedBy }.DeactivateAllCareerHistoryOfEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); #endregion } } #endregion #region Deactivate employee result = new EmployeesCodesBLL() { LoginIdentity = item.CreatedBy }.DeactivateEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion #region Set his job as job vacant result = new OrganizationsJobsBLL() { LoginIdentity = item.CreatedBy }.SetJobAsVacant(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID); #endregion #region Update is process to true result = new EndOfServicesBLL() { LoginIdentity = item.CreatedBy }.MarkIsProcessToDone(item.EndOfServiceID); if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString()) { return(result); } #endregion } } return(result); } catch (Exception ex) { throw ex; } }
public Result Add() { try { Result result = new Result(); EmployeesCareersHistoryBLL HiringRecord = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #region Check about is hiring exists before or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { if (HiringRecord != null) { result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfAlreadyHiringBefore.ToString(); return(result); } } #endregion #region TASK 260 : check new employee career history record date must be less than 'Join Date' of hiring record if (this.CareerHistoryType.CareerHistoryTypeID != (int)CareersHistoryTypesEnum.Hiring) { if (HiringRecord != null && HiringRecord.JoinDate.Date >= this.JoinDate.Date) { result.Entity = HiringRecord; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfJoinDateMustBeLessThanHiringRecordJoinDate.ToString(); return(result); } } #endregion #region Create new record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCodeID = this.EmployeeCode.EmployeeCodeID, CareerHistoryTypeID = this.CareerHistoryType.CareerHistoryTypeID, CareerDegreeID = this.CareerDegree.CareerDegreeID, OrganizationJobID = this.OrganizationJob.OrganizationJobID, JoinDate = this.JoinDate.Date, TransactionStartDate = this.JoinDate.Date, IsActive = false, CreatedBy = this.LoginIdentity.EmployeeCodeID, CreatedDate = DateTime.Now }; EmployeeCareerHistory.EmployeeCareerHistoryID = new EmployeesCareersHistoryDAL().Insert(EmployeeCareerHistory); #endregion #region Change current job ChangeCurrentJobByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #endregion #region TASK 310: Break last assigning //EmployeesCareersHistoryBLL LastActiveCareerHistory = new EmployeesCareersHistoryBLL().GetEmployeeCurrentJob(this.EmployeeCode.EmployeeCodeID); //if (LastActiveCareerHistory != null && LastActiveCareerHistory.EmployeeCareerHistoryID > 0) //{ new BaseAssigningsBLL() { LoginIdentity = this.LoginIdentity } .BreakLastAssigning(this.EmployeeCode.EmployeeCodeID, EmployeeCareerHistory.JoinDate, AssigningsReasonsEnum.CreatedNewCareerHistory); //} #endregion result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch (Exception ex) { throw ex; } }
public override Result Add() { try { Result result = base.Add(); if (result != null) { return(result); } int EmployeeCodeID = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID; DateTime StartDate = this.AssigningStartDate; DateTime EndDate = this.AssigningEndDate ?? DateTime.Now.Date; #region Validaion for conflict with lender EmployeesCareersHistoryBLL EmployeesCareersHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID); //if (EmployeesCareersHistory != null && EmployeesCareersHistory.EmployeeCareerHistoryID > 0) // EmployeeCodeID = EmployeesCareersHistory.EmployeeCode.EmployeeCodeID; List <LendersBLL> LendersBLLList = new LendersBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate); if (LendersBLLList.Count() != 0) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithLender.ToString(); return(result); } #endregion #region Validaion for conflict with StopWorks List <StopWorksBLL> StopWorksBLLList = new StopWorksBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate); if (StopWorksBLLList.Count() != 0) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString(); return(result); } #endregion #region Validaion for conflict with scholarship List <BaseScholarshipsBLL> BaseScholarshipsBLLList = new BaseScholarshipsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate); if (BaseScholarshipsBLLList.Count() != 0) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString(); return(result); } #endregion #region Validaion for conflict with External Assigning List <ExternalAssigningBLL> ExternalAssigningBLLList = new ExternalAssigningBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate); if (ExternalAssigningBLLList.Count() != 0) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithExternalAssigning.ToString(); return(result); } #endregion result = new Result(); Assignings assigning = DALInstance; assigning.JobID = this.Job.JobID; assigning.ManagerCodeID = this.Manager != null ? this.Manager.EmployeeCodeID : (int?)null; assigning.OrganizationID = this.Organization.OrganizationID; assigning.CreatedBy = this.LoginIdentity.EmployeeCodeID; this.AssigningID = new AssigningsDAL().Insert(assigning); if (this.AssigningID != 0) { result.Entity = this; result.EnumType = typeof(AssigningsValidationEnum); result.EnumMember = AssigningsValidationEnum.Done.ToString(); } return(result); } catch (Exception ex) { throw ex; } }
public override Result Add() { try { Result result = new Result(); #region Validation for vacation creation during probation period EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { // probation period = hiring date + 1 year DateTime ProbationEndDate = HiringRecord.ProbationEndDate;//.JoinDate.AddYears(1).AddDays(-10); if (ProbationEndDate > this.VacationStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString(); return(result); } } #endregion #region Validation for balanace result = IsBalanceValid(); if (result != null) { return(result); } #endregion #region Validation for vacation start date and end date according to sportsseason this.SportsSeason = new SportsSeasonsBLL().GetBySportsSeasonID(this.SportsSeason.SportsSeasonID); if (SportsSeason != null) { if ((this.VacationStartDate < this.SportsSeason.SportsSeasonStartDate && this.VacationEndDate < this.SportsSeason.SportsSeasonEndDate) || (this.VacationStartDate < this.SportsSeason.SportsSeasonStartDate && this.VacationEndDate > this.SportsSeason.SportsSeasonEndDate) || (this.VacationStartDate > this.SportsSeason.SportsSeasonStartDate && this.VacationEndDate > this.SportsSeason.SportsSeasonEndDate)) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.RejectedBecauseOfInvalidSportsDates.ToString(); return(result); } } if (SportsSeason == null) { result = new Result(); result.Entity = null; result.EnumType = typeof(VacationsValidationEnum); result.EnumMember = VacationsValidationEnum.SportsSeasonDoesNotExist.ToString(); return(result); } #endregion #region base validation result = base.Add(); //if (result != null) // return result; #endregion return(result); } catch { throw; } }
public virtual int AddHiringNewEmployee(EmployeesBLL EmployeesBLL, EmployeesCodesBLL EmployeesCodesBLL, EmployeesCareersHistoryBLL EmployeesCareersHistoryBLL, EmployeesQualificationsBLL EmployeesQualificationsBLL, ContractorsBasicSalariesBLL ContractorsBasicSalariesBLL, List <EmployeesAllowancesBLL> EmployeesAllowancesBLLLst) { try { EmployeesDAL employeeDal = new EmployeesDAL(); Employees employee = new Employees() { EmployeeIDNo = this.EmployeeIDNo, FirstNameAr = this.FirstNameAr, MiddleNameAr = this.MiddleNameAr, GrandFatherNameAr = this.GrandFatherNameAr, FifthNameAr = this.FifthNameAr, LastNameAr = this.LastNameAr, FirstNameEn = this.FirstNameEn, MiddleNameEn = this.MiddleNameEn, GrandFatherNameEn = this.GrandFatherNameEn, FifthNameEn = this.FifthNameEn, LastNameEn = this.LastNameEn, EmployeeBirthDate = (DateTime)this.EmployeeBirthDate.Value.Date, EmployeeBirthPlace = this.EmployeeBirthPlace, EmployeeMobileNo = this.EmployeeMobileNo, EmployeePassportNo = this.EmployeePassportNo, EmployeeEMail = this.EmployeeEMail, EmployeeIDIssueDate = this.EmployeeIDIssueDate != null ? (DateTime)this.EmployeeIDIssueDate.Value.Date : (DateTime?)null, EmployeePassportSource = this.EmployeePassportSource, EmployeePassportIssueDate = this.EmployeePassportIssueDate != null ? (DateTime)this.EmployeePassportIssueDate.Value.Date : (DateTime?)null, EmployeePassportEndDate = this.EmployeePassportEndDate != null ? (DateTime)this.EmployeePassportEndDate.Value.Date : (DateTime?)null, EmployeeIDExpiryDate = this.EmployeeIDExpiryDate, EmployeeIDCopyNo = this.EmployeeIDCopyNo, EmployeeIDIssuePlace = this.EmployeeIDIssuePlace, DependentCount = this.DependentCount, MaritalStatusID = this.MaritalStatus.MaritalStatusID, GenderID = this.Gender.GenderID, NationalityID = this.Nationality.CountryID, CreatedDate = DateTime.Now, CreatedBy = this.LoginIdentity.EmployeeCodeID, }; EmployeesCodes employeesCode = new EmployeesCodes() { EmployeeCodeNo = EmployeesCodesBLL.EmployeeCodeNo, EmployeeTypeID = EmployeesCodesBLL.EmployeeType.EmployeeTypeID, IsActive = true, CreatedDate = DateTime.Now, CreatedBy = this.LoginIdentity.EmployeeCodeID }; EmployeesCareersHistory employeeCareerHistory = new EmployeesCareersHistory() { CareerHistoryTypeID = EmployeesCareersHistoryBLL.CareerHistoryType.CareerHistoryTypeID, CareerDegreeID = EmployeesCareersHistoryBLL.CareerDegree.CareerDegreeID, OrganizationJobID = EmployeesCareersHistoryBLL.OrganizationJob.OrganizationJobID, JoinDate = EmployeesCareersHistoryBLL.JoinDate.Date, TransactionStartDate = EmployeesCareersHistoryBLL.JoinDate.Date, IsActive = true, CreatedBy = this.LoginIdentity.EmployeeCodeID, CreatedDate = DateTime.Now }; EmployeesQualifications employeeQualification = new EmployeesQualifications(); employeeQualification.QualificationDegreeID = EmployeesQualificationsBLL.QualificationDegree.QualificationDegreeID; employeeQualification.QualificationID = EmployeesQualificationsBLL.Qualification.QualificationID; employeeQualification.GeneralSpecializationID = EmployeesQualificationsBLL.GeneralSpecialization.GeneralSpecializationID; employeeQualification.ExactSpecializationID = EmployeesQualificationsBLL.ExactSpecialization.ExactSpecializationID == 0 ? (int?)null : EmployeesQualificationsBLL.ExactSpecialization.ExactSpecializationID; employeeQualification.UniSchName = EmployeesQualificationsBLL.UniSchName; employeeQualification.Department = EmployeesQualificationsBLL.Department; employeeQualification.FullGPA = EmployeesQualificationsBLL.FullGPA; employeeQualification.GPA = EmployeesQualificationsBLL.GPA; employeeQualification.StudyPlace = EmployeesQualificationsBLL.StudyPlace; employeeQualification.GraduationDate = EmployeesQualificationsBLL.GraduationDate; employeeQualification.GraduationYear = EmployeesQualificationsBLL.GraduationYear; employeeQualification.Percentage = EmployeesQualificationsBLL.Percentage; employeeQualification.QualificationTypeID = EmployeesQualificationsBLL.QualificationType.QualificationTypeID == 0 ? (int?)null : EmployeesQualificationsBLL.QualificationType.QualificationTypeID; employeeQualification.CreatedDate = DateTime.Now; employeeQualification.CreatedBy = this.LoginIdentity.EmployeeCodeID; ContractorsBasicSalaries contractorBasicSalary = new ContractorsBasicSalaries(); contractorBasicSalary.BasicSalary = ContractorsBasicSalariesBLL.BasicSalary; contractorBasicSalary.TransfareAllowance = ContractorsBasicSalariesBLL.TransfareAllowance; contractorBasicSalary.CreatedDate = DateTime.Now; contractorBasicSalary.CreatedBy = this.LoginIdentity.EmployeeCodeID; List <EmployeesAllowances> employeesAllowancesList = new List <EmployeesAllowances>(); foreach (var EmployeeAllowanceBLL in EmployeesAllowancesBLLLst) { employeesAllowancesList.Add(new EmployeesAllowances() { AllowanceID = EmployeeAllowanceBLL.Allowance.AllowanceID, AllowanceStartDate = EmployeeAllowanceBLL.AllowanceStartDate, IsActive = EmployeeAllowanceBLL.IsActive, CreatedBy = this.LoginIdentity.EmployeeCodeID, CreatedDate = DateTime.Now }); } employee.EmployeesCodes = new List <EmployeesCodes>(); employee.EmployeesCodes.Add(employeesCode); employeesCode.EmployeesCareersHistory = new List <EmployeesCareersHistory>(); employeesCode.EmployeesCareersHistory.Add(employeeCareerHistory); employeesCode.EmployeesQualifications = new List <EmployeesQualifications>(); employeesCode.EmployeesQualifications.Add(employeeQualification); #region check if the new employee is contractor then add financial advantages to him OrganizationsJobsBLL OrganizationsJobsBLL = new OrganizationsJobsBLL().GetByOrganizationJobID(employeeCareerHistory.OrganizationJobID); if (OrganizationsJobsBLL.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualExpats || OrganizationsJobsBLL.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis) { employeesCode.ContractorsBasicSalaries = new List <ContractorsBasicSalaries>(); employeesCode.ContractorsBasicSalaries.Add(contractorBasicSalary); employeeCareerHistory.EmployeesAllowances = employeesAllowancesList; } #endregion employeeDal.Insert(employee); return(this.EmployeeID); } catch { throw; } }
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; } }
public Result Update() { try { Result result = new Result(); #region Validation to check if EmployeeCareerHistory Exist in PromotionsRecordsEmployees as NewEmployeeCareerHistory or CurrentEmployeeCareerHistory //check if OrganizationJob Exist in PromotionsRecordsJobsVacancies as PromotionRecordJobVacancyID // Then Can't update OrganizationID,RankID,JobID List <PromotionsRecordsEmployeesBLL> PromotionsRecordsEmployeesList = new PromotionsRecordsEmployeesBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistoryID); if (PromotionsRecordsEmployeesList.Count != 0) { result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfExistsInPromotionsRecordsEmployees.ToString(); return(result); } #endregion #region Check about is hiring exists before or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { EmployeesCareersHistoryBLL Hr = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (Hr != null) { if (Hr.EmployeeCareerHistoryID != this.EmployeeCareerHistoryID) { result.Entity = Hr; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfAlreadyHiringBefore.ToString(); return(result); } } } #endregion #region TASK 260 : check new employee career history record date must be less than 'Join Date' of hiring record if (this.CareerHistoryType.CareerHistoryTypeID != (int)CareersHistoryTypesEnum.Hiring) { EmployeesCareersHistoryBLL oo = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (oo != null && oo.JoinDate.Date >= this.JoinDate.Date) { result.Entity = oo; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfJoinDateMustBeLessThanHiringRecordJoinDate.ToString(); return(result); } } #endregion #region if the record is hiring ... Check about there is vacation transactions before new hiring date or not if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring)) { bool IsVacationExists = new BaseVacationsBLL().IsEmployeeVacationExistsBeforeDate(this.EmployeeCode.EmployeeCodeID, this.JoinDate.Date); if (IsVacationExists) { //result.Entity = Hr; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.RejectedHiringDateUpdatingBecauseOfAlreadyActionsBefore.ToString(); return(result); } } #endregion #region Update record EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory() { EmployeeCareerHistoryID = this.EmployeeCareerHistoryID, CareerHistoryTypeID = this.CareerHistoryType.CareerHistoryTypeID, CareerDegreeID = this.CareerDegree.CareerDegreeID, OrganizationJobID = this.OrganizationJob.OrganizationJobID, JoinDate = this.JoinDate.Date, TransactionStartDate = this.JoinDate.Date, LastUpdatedBy = this.LoginIdentity != null ? this.LoginIdentity.EmployeeCodeID : (int?)null, LastUpdatedDate = DateTime.Now, IsActive = this.IsActive, }; new EmployeesCareersHistoryDAL().Update(EmployeeCareerHistory); #endregion #region Change current job ChangeCurrentJobByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); #endregion result.Entity = this; result.EnumType = typeof(CareersHistoryValidationEnum); result.EnumMember = CareersHistoryValidationEnum.Done.ToString(); return(result); } catch { throw; } }
public virtual Result Edit() { Result result = IsValid(); if (result != null) { return(result); } #region validate for Scholarship already extended or not if (new ScholarshipsDetailsBLL().GetScholarshipDetailsByScholarshipID(this.ScholarshipID).Count() > 1) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString(); return(result); } #endregion #region validate for vacation before hiring or not EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.Employee.EmployeeCodeID); if (HiringRecord != null) { if (HiringRecord.JoinDate > this.ScholarshipStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(ScholarshipsValidationEnum); result.EnumMember = ScholarshipsValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString(); return(result); } } #endregion #region validate for Conflict With Other Process result = CommonHelper.IsNoConflictWithOtherProcess(this.Employee.EmployeeCodeID, this.ScholarshipStartDate, this.ScholarshipEndDate); if (result != null) { // we should exclude this scholarship from validation if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString()) { List <BaseScholarshipsBLL> BaseScholarshipsBLLList = new EmployeesCodesBLL().GetScholarshipsByEmployeeCodeID(this.Employee.EmployeeCodeID) .Where( x => x.IsCanceled == false && x.ScholarshipID != this.ScholarshipID && ( (ScholarshipStartDate >= x.ScholarshipStartDate && ScholarshipStartDate <= x.ScholarshipEndDate) || (ScholarshipEndDate >= x.ScholarshipStartDate && ScholarshipEndDate <= x.ScholarshipEndDate) || (ScholarshipStartDate >= x.ScholarshipStartDate && ScholarshipEndDate <= x.ScholarshipEndDate) || (ScholarshipEndDate <= x.ScholarshipEndDate && ScholarshipEndDate >= x.ScholarshipEndDate)) ) .ToList(); if (BaseScholarshipsBLLList.Count() != 0) { result = new Result(); result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum); result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString(); return(result); } else { result = null; } } //return result; } #endregion if (result != null) { return(result); } result = this.EditScholarship(); return(result); }
///// <summary> ///// Dated : 24-08-2020 : getting ContractualSaudi TransfareAllowance from ContractorBasicSalary Table ///// </summary> ///// <param name="EmployeeCode"></param> ///// <returns></returns> //private SalaryDetailsBLL GetSalaryDetailsBenefitsByEmployeeCodeNo(EmployeesCodesBLL EmployeeCode) //{ // try // { // double FirstDegreeBasicSalary = 0, CurrentDegreeBasicSalary = 0; // double BasicSalary = 0, TransfareAllowance = 0, TotalAllowances = 0; // SalaryDetailsBLL SalaryDetails = new SalaryDetailsBLL(); // //EmployeesCodesBLL EmployeeCode = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo); // if (EmployeeCode != null) // { // EmployeesCareersHistoryBLL Employee = EmployeeCode.EmployeeCurrentJob; // if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.Employee) // BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; // else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.User) // BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; // else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.SaudiLabor) // BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; // else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis) // BasicSalary = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).BasicSalary; // else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualExpats) // BasicSalary = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).BasicSalary; // else // BasicSalary = 0; // // Dated : 24-08-2020 : getting ContractualSaudi TransfareAllowance from ContractorBasicSalary Table // if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis) // TransfareAllowance = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).TransfareAllowance; // else // TransfareAllowance = new RanksBLL().GetByRankID(Employee.OrganizationJob.Rank.RankID).TransfareAllowance; // SalaryDetails.Benefits = new SalaryBenefits() // { // BasicSalary = BasicSalary, // TransfareAllowance = TransfareAllowance, // EmployeesAllowances = new EmployeesCodesBLL().GetActiveAllownacessByEmployeeCodeID(EmployeeCode.EmployeeCodeID), // }; // // some allowances should be calcualted based on current basic salary of employee, and some should be calculated based on basic salary of first degree of employee current rank // FirstDegreeBasicSalary = new BasicSalariesBLL().GetBasicSalary(EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankID, 1).BasicSalary; // CurrentDegreeBasicSalary = SalaryDetails.Benefits.BasicSalary; // foreach (var item in SalaryDetails.Benefits.EmployeesAllowances) // { // if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Fixed)) // SalaryDetails.Benefits.TotalAllowances = TotalAllowances + item.Allowance.AllowanceAmount; // else if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Percentage)) // { // if (item.Allowance.AllowanceCalculationType.AllowanceCalculationTypeID == Convert.ToInt16(AllowancesCalculationTypesEnum.BasedOnBasicSalaryOfFirstDegree)) // TotalAllowances = TotalAllowances + ((item.Allowance.AllowanceAmount / 100) * FirstDegreeBasicSalary); // else // TotalAllowances = TotalAllowances + ((item.Allowance.AllowanceAmount / 100) * CurrentDegreeBasicSalary); // } // } // SalaryDetails.Benefits.TotalAllowances = TotalAllowances; // } // return SalaryDetails; // } // catch // { // throw; // } //} //private SalaryDetailsBLL GetSalaryDetailsDeductionsByEmployeeCodeNo(EmployeesCodesBLL EmployeeCode, double BasicSalary) //{ // try // { // SalaryDetailsBLL SalaryDetails = new SalaryDetailsBLL(); // //EmployeesCodesBLL EmployeeCode = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo); // SalaryDetails.Deductions = new SalaryDeductions() // { // //RetirmentDeduction = Math.Round(new BasicSalariesBLL().GetBasicSalary(EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankID, EmployeeCode.EmployeeCurrentJob.CareerDegree.CareerDegreeID).BasicSalary * .09, 2) // RetirmentDeduction = Math.Round(BasicSalary * EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankCategory.RetirementPercentage / 100, 2), // //TakafulDeductions = new TakafulDeductionsBLL().GetActiveTakafulDeductions(EmployeeCode.Employee.EmployeeID), // TakafulDeductions = new List<Deduction>(), // GovernmentFundsDeductions = new GovernmentFundsBLL().GetActiveGovernmentFundsByEmployeeCodeID(EmployeeCode.EmployeeCodeID), // }; // SalaryDetails.Deductions.TotalDeductions = SalaryDetails.Deductions.RetirmentDeduction + // double.Parse(SalaryDetails.Deductions.TakafulDeductions.Sum(x => x.DeductionAmount).ToString()) + // SalaryDetails.Deductions.GovernmentFundsDeductions.Sum(x => x.MonthlyDeductionAmount); // return SalaryDetails; // } // catch // { // throw; // } //} ///// <summary> ///// This is to calculate employee net salary, formula of net salary : ///// (BasicSalary + TransfareAllowance + TotalAllowances) - (RetirmentDeduction + TakafulDeduction + GovernmentFundsDeductions) ///// </summary> ///// <param name="EmployeeCodeNo"></param> ///// <returns></returns> //public SalaryDetailsBLL GetSalaryDetailsByEmployeeCodeNo(string EmployeeCodeNo) //{ // try // { // EmployeesCodesBLL EmployeeCode = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo); // SalaryDetailsBLL SalaryDetails = new SalaryDetailsBLL(); // SalaryDetails.Benefits = SalaryDetails.GetSalaryDetailsBenefitsByEmployeeCodeNo(EmployeeCode).Benefits; // SalaryDetails.Deductions = SalaryDetails.GetSalaryDetailsDeductionsByEmployeeCodeNo(EmployeeCode, SalaryDetails.Benefits.BasicSalary).Deductions; // //#region Total Allowances // ////only Active allowances // //double TotalAllowances = 0; // //double FirstDegreeBasicSalary = 0; // //double CurrentDegreeBasicSalary = 0; // //foreach (var item in SalaryDetails.Benefits.EmployeesAllowances) // //{ // // if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Fixed)) // // TotalAllowances = TotalAllowances + item.Allowance.AllowanceAmount; // // else if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Percentage)) // // { // // if(item.Allowance.AllowanceCalculationType.AllowanceCalculationTypeID == Convert.ToInt16(AllowancesCalculationTypesEnum.BasedOnBasicSalaryOfFirstDegree)) // // TotalAllowances = TotalAllowances + ((item.Allowance.AllowanceAmount / 100) * FirstDegreeBasicSalary); // // else // // TotalAllowances = TotalAllowances + ((item.Allowance.AllowanceAmount / 100) * CurrentDegreeBasicSalary); // // } // //} // //#endregion // #region Net salary // SalaryDetails.NetSalary = Math.Round((SalaryDetails.Benefits.BasicSalary + // SalaryDetails.Benefits.TransfareAllowance + // SalaryDetails.Benefits.TotalAllowances) - // (SalaryDetails.Deductions.TotalDeductions), 2); // #endregion // return SalaryDetails; // } // catch // { // throw; // } //} /// <summary> /// Dated : 24-08-2020 : getting ContractualSaudi TransfareAllowance from ContractorBasicSalary Table /// </summary> /// <param name="EmployeeCode"></param> /// <returns></returns> private SalaryDetailsBLL GetSalaryDetailsBenefitsByEmployeeCodeNo(EmployeesCodesBLL EmployeeCode, List <EmployeesAllowancesBLL> Allowances, List <BasicSalariesBLL> BasicSalaries, List <RanksBLL> Ranks) { try { double FirstDegreeBasicSalary = 0, CurrentDegreeBasicSalary = 0; double BasicSalary = 0, TransfareAllowance = 0, TotalAllowances = 0; SalaryDetailsBLL SalaryDetails = new SalaryDetailsBLL(); if (EmployeeCode != null) { EmployeesCareersHistoryBLL Employee = EmployeeCode.EmployeeCurrentJob; if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.Employee) { BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; } else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.User) { BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; } else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.SaudiLabor) { BasicSalary = new BasicSalariesBLL().GetBasicSalary(Employee.OrganizationJob.Rank.RankID, Employee.CareerDegree.CareerDegreeID).BasicSalary; } else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis) { BasicSalary = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).BasicSalary; } else if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualExpats) { BasicSalary = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).BasicSalary; } else { BasicSalary = 0; } // Dated : 24-08-2020 : getting ContractualSaudi TransfareAllowance from ContractorBasicSalary Table if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID == (int)RanksCategoriesEnum.ContractualSaudis) { TransfareAllowance = new ContractorsBasicSalariesBLL().GetByEmployeeCodeID(EmployeeCode.EmployeeCodeID).TransfareAllowance; } else { TransfareAllowance = Ranks.FirstOrDefault(x => x.RankID == Employee.OrganizationJob.Rank.RankID).TransfareAllowance; } SalaryDetails.Benefits = new SalaryBenefits() { BasicSalary = BasicSalary, TransfareAllowance = TransfareAllowance, EmployeesAllowances = Allowances.Where(x => x.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID == EmployeeCode.EmployeeCodeID).ToList(), }; // some allowances should be calcualted based on current basic salary of employee, and some should be calculated based on basic salary of first degree of employee current rank if (Employee.OrganizationJob.Rank.RankCategory.RankCategoryID != (int)RanksCategoriesEnum.ContractualExpats && Employee.OrganizationJob.Rank.RankCategory.RankCategoryID != (int)RanksCategoriesEnum.ContractualSaudis) { BasicSalariesBLL basicSalary = BasicSalaries.FirstOrDefault(x => x.Rank.RankID == EmployeeCode.EmployeeCurrentJob.OrganizationJob.Rank.RankID && x.CareerDegree.CareerDegreeID == 1); FirstDegreeBasicSalary = basicSalary != null ? basicSalary.BasicSalary : 0; } CurrentDegreeBasicSalary = SalaryDetails.Benefits.BasicSalary; foreach (var item in SalaryDetails.Benefits.EmployeesAllowances) { if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Fixed)) { TotalAllowances += item.Allowance.AllowanceAmount; } else if (item.Allowance.AllowanceAmountType.AllowanceAmountTypeID == Convert.ToInt16(AllowancesAmountTypesEnum.Percentage)) { if (item.Allowance.AllowanceCalculationType.AllowanceCalculationTypeID == Convert.ToInt16(AllowancesCalculationTypesEnum.BasedOnBasicSalaryOfFirstDegree)) { TotalAllowances += ((item.Allowance.AllowanceAmount / 100) * FirstDegreeBasicSalary); } else { TotalAllowances += ((item.Allowance.AllowanceAmount / 100) * CurrentDegreeBasicSalary); } } } SalaryDetails.Benefits.TotalAllowances = Math.Round(TotalAllowances, 2); //SalaryDetails.TotalSalary = SalaryDetails.Benefits.BasicSalary + SalaryDetails.Benefits.TotalAllowances + SalaryDetails.Benefits.TransfareAllowance; } return(SalaryDetails); } catch { throw; } }