public void CalculateCostOfBenefits_ReturnCostInformations() { //Arrange var _benefitCostCalculator = new Mock <IBenefitCostCalculator>() { CallBase = true }; var _employeeAdapter = new Mock <IEmployeeDataAdapter>(); EmployeeInformation information = Utility.ParseJSONArray <EmployeeInformation>(ReadJsonFromFile("./SampleDataType.json")); EmployeeSalaryInformation _employeeSalary = Utility.ParseJSONArray <EmployeeSalaryInformation>(ReadJsonFromFile("./SampleResult.json")); _employeeAdapter.Setup(x => x.GetByUniqueID("2AC72CB1-2BE1-4E79-BBCB-5763ECB810CB")).Returns(information); _benefitCostCalculator.Setup(y => y.CalculateEmployeeSalary(information)).Returns(_employeeSalary); var controller = new BenefitCostCalculatorController(_employeeAdapter.Object, _benefitCostCalculator.Object); //act var ExppectedResult = (OkObjectResult)controller.Get("2AC72CB1-2BE1-4E79-BBCB-5763ECB810CB"); EmployeeSalaryInformation ExpEmployeeSalary = Utility.ParseJSONArray <EmployeeSalaryInformation>(ExppectedResult.Value.ToString()); //Assert Assert.AreEqual(_employeeSalary.EmployeeFullName, ExpEmployeeSalary.EmployeeFullName); Assert.AreEqual(_employeeSalary.SalaryAfterBenefitDeduction, ExpEmployeeSalary.SalaryAfterBenefitDeduction); }
public EmployeeSalaryInformation CalculateEmployeeSalary(EmployeeInformation inEmployeeInformation) { EmployeeSalaryInformation employeeSalaryInfo = CalculateEmployeeSalary(inEmployeeInformation.Employee); foreach (DependentDTO dependent in inEmployeeInformation.Dependents) { DependentBenefitCostInformation dependentsCostInfo = CalculateDependentBenefitCost(dependent); employeeSalaryInfo.SalaryAfterBenefitDeduction -= dependentsCostInfo.CostOfBenefit; employeeSalaryInfo.dependentsBenifitCostInfo.Add(dependentsCostInfo); } return(employeeSalaryInfo); }
public ActionResult Get(string employeeID) { EmployeeInformation employeeRecord = _employeAdapter.GetByUniqueID(employeeID); if (string.IsNullOrEmpty(employeeRecord.Employee.EmployeeID)) { return(BadRequest(string.Format($"Given EmployeeID: {employeeID} doesnot exist. Please provide the right employeeID"))); } EmployeeSalaryInformation _salary = _benefitCostCalculator.CalculateEmployeeSalary(employeeRecord); string result = JsonConvert.SerializeObject(_salary); return(Ok(result)); }
private void ShowEmployeeDetails() { salaryInformation = new EmployeeSalaryInformation(SelectedEmployee.Id); FormattedDateJoined = $"{salaryInformation.DateJoined:d}"; if (salaryInformation.DateLeft == null) { FormattedDateLeft = "Vertrag ist unbefristet"; } else { FormattedDateLeft = $"{(DateTime)salaryInformation.DateLeft:d}"; } EmployeeSalaryDetails = new ObservableCollection <EmployeeSalaryDetail>(salaryInformation.GetMonthlySalaries()); EmployeeAnnualDetails = new ObservableCollection <EmployeeSalaryDetail>(salaryInformation.GetAnnualSalaries()); RaisePropertyChanged("EmployeeSalaryDetails"); RaisePropertyChanged("EmployeeAnnualDetails"); }
public ActionResult GetEmployeeSalaryInfo([FromBody] object requestBody) { EmployeeInformation employeeRecord = Utilities.Utility.ParseJSONArray <EmployeeInformation>(requestBody.ToString()); var res = _employeAdapter.Post(employeeRecord); if (!res.Contains("successfully inserted data")) { return(BadRequest(string.Format($"Failed to insert new employee"))); } EmployeeSalaryInformation _salary = _benefitCostCalculator.CalculateEmployeeSalary(employeeRecord); string result = JsonConvert.SerializeObject(_salary); return(Ok(result)); }
/// <summary> /// Claculates the Employee cost benefit per enployee /// </summary> /// <param name="employee"></param> /// <returns></returns> private EmployeeSalaryInformation CalculateEmployeeSalary(EmployeeDTO employee) { EmployeeSalaryInformation inEmployeeInfo = new EmployeeSalaryInformation(); inEmployeeInfo.EmployeeFullName = string.Concat(employee.FirstName, " ", employee.LastName); inEmployeeInfo.EmployeeCostOfBeneFit = Utility.RoundUpDecimal((decimal)(employee.CostOfBenefitAnnual / 26)); inEmployeeInfo.SalaryBeforeBenefitDeduction = (decimal)(employee.AnnualSalary / 26); decimal EmployeSalaryAfterDeduction = inEmployeeInfo.SalaryBeforeBenefitDeduction; //Discount for Employee if qualifies if (DoesQualifyForDiscount(employee.FirstName)) { inEmployeeInfo.EmployeeCostOfBeneFit = ApplyDiscountPerPayCheck((decimal)employee.PercentageOfDiscount, (decimal)employee.CostOfBenefitAnnual); } EmployeSalaryAfterDeduction -= inEmployeeInfo.EmployeeCostOfBeneFit; inEmployeeInfo.SalaryAfterBenefitDeduction = Utility.RoundUpDecimal(EmployeSalaryAfterDeduction); return(inEmployeeInfo); }