public PayrollServiceController(
     PayrollService.Server.PayrollService payrollService,
     PayrollService.Models.PayrollServiceContext payrollServiceContext
     )
 {
     _payrollService        = payrollService;
     _payrollServiceContext = payrollServiceContext;
 }
Example #2
0
        public static Country Get(PayrollServiceContext _payrollServiceContext, PayrollService _payrollService, string code)
        {
            Country country = null;

            if (_payrollServiceContext.Countries.Any(i => i.Code == code))
            {
                country = _payrollServiceContext.Countries.FirstOrDefault(i => i.Code == code);
            }

            return(country);
        }
Example #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);
        }
Example #4
0
 public Payroll(PayrollServiceContext payrollServiceContext)
 {
     _payrollServiceContext = payrollServiceContext;
 }