Ejemplo n.º 1
0
        public void NotValidDataException0_0( )
        {
            PayrollService.Server.PayrollService        payrollService        = new Server.PayrollService( );
            PayrollService.Models.PayrollServiceContext payrollServiceContext = new Models.PayrollServiceContext( );
            PayrollServiceController payrollServiceController = new PayrollServiceController(payrollService, payrollServiceContext);

            Utility.PayrollCalculateInput payrollCalculateInput = new Utility.PayrollCalculateInput( )
            {
                CountryCode = "DE",
                HourlyRate  = 0,
                HoursWorked = 0
            };
            Task <IHttpActionResult> iHttpActionResult = payrollServiceController.GetTaxRole(payrollCalculateInput);

            Assert.IsNotNull(iHttpActionResult.Result);
            PayrollResponse payrollResponse = ((System.Web.Http.Results.OkNegotiatedContentResult <PayrollService.Utility.PayrollResponse>)iHttpActionResult.Result).Content as PayrollResponse;

            Assert.AreEqual(payrollResponse.Message, "Data is not valid");
        }
Ejemplo n.º 2
0
        public void GetTaxRoleForSpainWithRate50_20( )
        {
            PayrollService.Server.PayrollService        payrollService        = new Server.PayrollService( );
            PayrollService.Models.PayrollServiceContext payrollServiceContext = new Models.PayrollServiceContext( );
            PayrollServiceController payrollServiceController = new PayrollServiceController(payrollService, payrollServiceContext);

            Utility.PayrollCalculateInput payrollCalculateInput = new Utility.PayrollCalculateInput( )
            {
                CountryCode = "SP",
                HourlyRate  = 20,
                HoursWorked = 50
            };
            Task <IHttpActionResult> iHttpActionResult = payrollServiceController.GetTaxRole(payrollCalculateInput);

            PayrollResponse payrollResponse = ((System.Web.Http.Results.OkNegotiatedContentResult <PayrollService.Utility.PayrollResponse>)iHttpActionResult.Result).Content as PayrollResponse;

            Assert.IsNotNull(payrollResponse);
            Assert.AreEqual(payrollResponse.Message, "true");
            Assert.AreEqual(payrollResponse.NetSalary, 650);
            Assert.AreEqual(payrollResponse.TaxesDeductions, 350);
            Assert.AreEqual(payrollResponse.GrossSalary, 1000);
        }
Ejemplo n.º 3
0
        public static async Task <PayrollResponse> GetPayroll(PayrollServiceContext _payrollServiceContext, Server.PayrollService _payrollService, PayrollCalculateInput payrollCalculateInput)
        {
            PayrollResponse payrollResponse = new PayrollResponse( );

            Country        country  = CountryServer.Get(_payrollServiceContext, _payrollService, payrollCalculateInput.CountryCode);
            List <TaxRole> taxRoles = new List <TaxRole>( );

            if (country != null)
            {
                taxRoles = await _payrollServiceContext.TaxRoles.Where(i => i.CountryId == country.Id).ToListAsync( );

                double taxesDeductions = 0;
                if (payrollCalculateInput.HourlyRate <= 0 || payrollCalculateInput.HoursWorked <= 0)
                {
                    payrollResponse.Message = "Data is not valid";
                    return(payrollResponse);
                }
                double grossSalary = Server.PayrollService.GetPayrollResponse(taxRoles, payrollCalculateInput, out taxesDeductions);
                if (taxesDeductions == 0)
                {
                    payrollResponse.Message = "Tax Role Not Found";
                    return(payrollResponse);
                }
                payrollResponse.CountryCode     = payrollCalculateInput.CountryCode = country.Code;
                payrollResponse.GrossSalary     = grossSalary;
                payrollResponse.NetSalary       = grossSalary - taxesDeductions;
                payrollResponse.TaxesDeductions = taxesDeductions;
                payrollResponse.Message         = "true";
            }
            else
            {
                payrollResponse.Message = "Country Code is not exists...";
            }

            return(payrollResponse);
        }
        public async Task <IHttpActionResult> GetTaxRole(PayrollCalculateInput payrollCalculateInput)
        {
            PayrollResponse payrollResponse = await Middle.Payroll.GetPayroll(_payrollServiceContext, _payrollService, payrollCalculateInput);

            return(Ok(payrollResponse));
        }