private void SetupCommonComponents() { //set up logging _logger = LogSetup(); _employeeMonthlyPayslipAppContext = new EmployeeMonthlyPayslipAppContext(_logger); // set up type mapper _mapper = InitializeTypeMapper(); // load tax structure _taxStructure = LoadTaxStructure(); }
public IPaySlipDetails GetPaySlip(ITaxStructure taxStructure) { IPaySlipDetails paySlipDetails = null; try { var employee = _mapper.Map <IEmployeeDetails, IEmployee>(_employeeDetails); var salarySlip = SalarySlip.CreateSalarySlip(employee.Salary, taxStructure); salarySlip.TaxPeriod = _employeeDetails.TaxPeriod; employee.SalarySlips.Add(salarySlip); paySlipDetails = _mapper.Map <IEmployee, IPaySlipDetails>(employee); } catch (Exception ex) { _employeeMonthlyPayslipAppContext.AddError( new EmployeeMonthlyPayslipAppError("EmployeePayDetailsService:GetPaySlip", new EmployeeMonthlyPayslipAppException("Error occured while processing pay slip", ex)) ); } return(paySlipDetails); }
public static SalarySlip CreateSalarySlip(ISalary salary, ITaxStructure taxStructure) => new SalarySlip(salary, taxStructure);
private SalarySlip(ISalary salary, ITaxStructure taxStructure) { _salary = salary; _taxStructure = taxStructure; IncomeTax = CalculateIncomeTax(); }