Exemple #1
0
        public void Create_ShouldReturnDto()
        {
            var detail = TaxDetailDto.Create(10000, 20000, 20, "band1", 2000);

            detail.Description.Should().Be("band1");
            detail.Range.Should().Be("Over 10000.00 and less than or equal to 20000.00");
            detail.Tax.Should().Be("2000.00");
            detail.Rate.Should().Be(20);
        }
Exemple #2
0
        public void Create_UppderBoundNull_ShouldReturnRangeStatementWithOverOnly()
        {
            var detail = TaxDetailDto.Create(10000, null, 20, "band1", 2000);

            detail.Description.Should().Be("band1");
            detail.Range.Should().Be("Over 10000.00");
            detail.Tax.Should().Be("2000.00");
            detail.Rate.Should().Be(20);
        }
        public (decimal, List <TaxDetailDto>) GetTax(decimal amount)
        {
            var lowerBound = 0m;
            var total      = 0m;
            var details    = new List <TaxDetailDto>();

            foreach (var taxBand in TaxBands)
            {
                total += taxBand.GetTax(lowerBound, amount);
                details.Add(TaxDetailDto.Create(lowerBound,
                                                taxBand.UpperBound,
                                                taxBand.Rate,
                                                taxBand.Description,
                                                taxBand.GetTax(lowerBound, amount)));
                lowerBound = taxBand.UpperBound.HasValue ? taxBand.UpperBound.Value : 0;
            }

            return(total, details);
        }