Exemple #1
0
        public TaxResponse Calculate(TaxRequestDto taxRequest)
        {
            var employmentType = taxRequest.EmploymentType;
            var taxService     = EmploymentTypeSelector.Get(employmentType);
            var totalTax       = taxService.Calculate(taxRequest);

            return(new TaxResponse {
                TotalTax = decimal.Round(totalTax, 2)
            });
        }
        public valid_request_contract(double dayRate, int daysPerYear, bool includesSuper, double tax)
        {
            _tax = tax;

            var taxRequest = new TaxRequestDto
            {
                DaysPerYear    = daysPerYear,
                EmploymentType = EmploymentType.Contract,
                Salary         = (decimal)dayRate,
                IncludesSuper  = includesSuper
            };

            var json = JsonConvert.SerializeObject(taxRequest, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

            _response = Client.PostAsync("api/tax/calculate", stringContent).Result;
        }
Exemple #3
0
        public PmsResponseDto UpdateTax([FromBody] TaxRequestDto request)
        {
            if (request == null || request.Tax == null || request.Tax.Id <= 0)
            {
                throw new PmsException("Tax can not be updated.");
            }

            var response = new PmsResponseDto();

            if (_iPmsLogic.UpdateTax(request.Tax))
            {
                response.ResponseStatus    = PmsApiStatus.Success.ToString();
                response.StatusDescription = "Record(s) saved successfully.";
            }
            else
            {
                response.ResponseStatus    = PmsApiStatus.Failure.ToString();
                response.StatusDescription = "Operation failed.Please contact administrator.";
            }
            return(response);
        }
Exemple #4
0
        public decimal Calculate(TaxRequestDto request)
        {
            decimal yearlySalaryWithoutSuper;

            if (request.IncludesSuper.HasValue && request.IncludesSuper == true)
            {
                // x + 9.5 % of x = salary
                // x + 0.095x = salary
                // 1.095x = salary
                // x = salary / 1.095
                var dayRateWithoutSuper = request.Salary.Value / 1.095m;
                yearlySalaryWithoutSuper = dayRateWithoutSuper * request.DaysPerYear.Value;
            }
            else
            {
                yearlySalaryWithoutSuper = request.DaysPerYear.Value * request.Salary.Value;
            }

            var taxBrackets = _taxBracketService.GetTaxBrackets();

            return(Helper.CalculateAnnualTax(yearlySalaryWithoutSuper, taxBrackets));
        }
Exemple #5
0
        public decimal Calculate(TaxRequestDto request)
        {
            var currentSalary = request.Salary;

            return(CalculateAnnualTax(currentSalary.Value));
        }