public bool ValidateEmployeeModel(EmployeeDetailsBo employeeDetailsBo)
        {
            if (employeeDetailsBo.AnnualSalary <= 0 || employeeDetailsBo.SuperRate <= 0)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public IActionResult CalculatedPayslip([FromBody] EmployeeDetailsBo model)
        {
            if (!_payslipGenerationBal.ValidateEmployeeModel(model))
            {
                return(StatusCode(StatusCodes.Status400BadRequest));
            }

            var payslip = _payslipGenerationBal.CalculatedPayslip(model);

            return(Ok(payslip));
        }
Esempio n. 3
0
        public EmployeeDetailsBo EmployeeTestData(double annualIncome, byte superRate, string fName = "john",
                                                  string lName = "Doe")
        {
            var employeeDetailsBo = new EmployeeDetailsBo
            {
                FirstName    = fName,
                LastName     = lName,
                AnnualSalary = annualIncome,
                StartDate    = DateTime.Now,
                SuperRate    = superRate
            };

            return(employeeDetailsBo);
        }
        public PayslipBo CalculatedPayslip(EmployeeDetailsBo model)
        {
            var paySlip = new PayslipBo
            {
                Name = $"{model.FirstName} {model.LastName}",

                GrossIncome = CalculateGrossIncome(model.AnnualSalary),

                IncomeTax = _iPay.CalcTaxableIncome(model.AnnualSalary),

                NetIncome = CalculateNetIncome(CalculateGrossIncome(model.AnnualSalary),
                                               _iPay.CalcTaxableIncome(model.AnnualSalary)),

                SuperAmount = CalculateSuperAmount(model.SuperRate, CalculateGrossIncome(model.AnnualSalary)),

                PayPeriod =
                    $"{model.StartDate.ToString(DateFormat)} - {model.StartDate.AddDays(30).ToString(DateFormat)}"
            };

            return(paySlip);
        }