public ContractorsBasicSalariesBLL GetByEmployeeCodeID(int EmployeeCodeID) { ContractorsBasicSalaries ContractorBasicSalary = new ContractorsBasicSalariesDAL().GetByEmployeeCodeID(EmployeeCodeID); ContractorsBasicSalariesBLL Obj = new ContractorsBasicSalariesBLL(); if (ContractorBasicSalary == null) { Obj.BasicSalary = 0; Obj.TransfareAllowance = 0; } else { Obj.BasicSalary = ContractorBasicSalary.BasicSalary; Obj.TransfareAllowance = ContractorBasicSalary.TransfareAllowance.HasValue ? ContractorBasicSalary.TransfareAllowance.Value : 0; } return(Obj); }
public ContractorsBasicSalariesBLL GetByContractorBasicSalaryID(int ContractorBasicSalaryID) { try { ContractorsBasicSalariesBLL ContractorBasicSalaryBLL = null; ContractorsBasicSalaries ContractorsBasicSalary = new ContractorsBasicSalariesDAL().GetByContractorBasicSalaryID(ContractorBasicSalaryID); if (ContractorsBasicSalary != null) { ContractorBasicSalaryBLL = new ContractorsBasicSalariesBLL().MapContractorBasicSalary(ContractorsBasicSalary); } return(ContractorBasicSalaryBLL); } catch { throw; } }
internal ContractorsBasicSalariesBLL MapContractorBasicSalary(ContractorsBasicSalaries ContractorBasicSalary) { try { ContractorsBasicSalariesBLL ContractorBasicSalaryBLL = null; if (ContractorBasicSalary != null) { ContractorBasicSalaryBLL = new ContractorsBasicSalariesBLL() { ContractorBasicSalaryID = ContractorBasicSalary.ContractorBasicSalaryID, EmployeeCode = new EmployeesCodesBLL().MapEmployeeCode(ContractorBasicSalary.EmployeesCodes), BasicSalary = ContractorBasicSalary.BasicSalary, TransfareAllowance = ContractorBasicSalary.TransfareAllowance.HasValue ? ContractorBasicSalary.TransfareAllowance.Value : 0, CreatedDate = ContractorBasicSalary.CreatedDate.HasValue ? ContractorBasicSalary.CreatedDate.Value : DateTime.Now, //CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(ContractorBasicSalary.CreatedByNav) }; } return(ContractorBasicSalaryBLL); } 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) //{ // 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; } }
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; } }