protected override OperationResult <decimal> CalculateTax(decimal annualIncome) { var result = new OperationResult <decimal>(); /* * 1. Get all settings with fromAmount less than the annual Income. These are all the valid bands * 2. The last band will have ToAmount >annualIncome so you will need to use the annualIncome value */ var taxSettings = TaxRateSettings.Where(t => t.FromAmount <= annualIncome) .OrderBy(t => t.FromAmount); var taxAmounts = new List <decimal>(); foreach (var taxSetting in taxSettings) { var maxAmount = (taxSetting.ToAmount ?? annualIncome) < annualIncome ? taxSetting.ToAmount : annualIncome; var taxableAmount = maxAmount.Value - taxSetting.FromAmount; var taxAmount = taxableAmount * (taxSetting.TaxRatePerc / 100.00M); taxAmounts.Add(taxAmount); } result.Response = taxAmounts.Sum(); return(result); }
protected override OperationResult <decimal> CalculateTax(decimal annualIncome) { var result = new OperationResult <decimal> { Response = annualIncome * (TaxRateSettings.First().FlatRatePerc / 100.00M) }; return(result); }
protected override OperationResult <decimal> CalculateTax(decimal annualIncome) { var result = new OperationResult <decimal>(); var taxSetting = TaxRateSettings.First(); if (annualIncome < taxSetting.LowIncomeThreshold) { result.Response = annualIncome * (taxSetting.LowIncomeTaxRatePerc / 100.00M); } else { result.Response = taxSetting.HighIncomeTaxAmount; } return(result); }