public void GetNIUpperRate_ThrowsException_WhenNoConfigForDate()
        {
            var date = new DateTime(1899, 1, 1);

            //Act
            Exception ex = Assert.Throws <MissingConfigurationException>(() => ConfigValueLookupHelper.GetNIUpperRate(_configOptions, date));
        }
Esempio n. 2
0
        public async Task <BasicAwardCalculationResponseDTO> PerformBasicAwardCalculationAsync(
            BasicAwardCalculationRequestModel data,
            IOptions <ConfigLookupRoot> options)
        {
            DateTime date = DateTime.Today;

            var taxRate     = ConfigValueLookupHelper.GetTaxRate(options, date);
            var niThreshold = ConfigValueLookupHelper.GetNIThreshold(options, date);

            var     niUpperThreshold = ConfigValueLookupHelper.GetNIUpperThreshold(options, date);
            var     niRate           = ConfigValueLookupHelper.GetNIRate(options, date);
            var     niUpperRate      = ConfigValueLookupHelper.GetNIUpperRate(options, date);
            decimal taxDeducted      = Math.Round(await data.BasicAwardAmount.GetTaxDeducted(taxRate, data.IsTaxable), 2);
            decimal niDeducted       = Math.Round(await data.BasicAwardAmount.GetNIDeducted(niThreshold, niUpperThreshold, niRate, niUpperRate, data.IsTaxable), 2);

            var response = new BasicAwardCalculationResponseDTO()
            {
                GrossEntitlement     = Math.Round(data.BasicAwardAmount, 2),
                IsTaxable            = data.IsTaxable,
                TaxDeducted          = taxDeducted,
                NIDeducted           = niDeducted,
                NetEntitlement       = Math.Round(data.BasicAwardAmount, 2) - taxDeducted - niDeducted,
                PreferentialClaim    = 0m,
                NonPreferentialClaim = Math.Round(data.BasicAwardAmount, 2)
            };

            return(await Task.FromResult(response));
        }
        public void GetNIUpperRate_Returns_CorrectNIRate_ForGiven_date(
            DateTime someDate, decimal expectedNIRate)
        {
            //Arrange
            //Act
            var result = ConfigValueLookupHelper.GetNIUpperRate(_configOptions, someDate);

            //Assert
            result.Should().Be(expectedNIRate);
        }