|
namespace BusinessRules.Evolution_Four
{
/// <summary>
/// USA Investor Tax Engine Domain Domain object specific to states tax rules.
/// </summary>
internal class UsaIncomeTaxEngine : IncomeTaxEngine
{
#region Methods
/// <summary>
/// Calculates the tax rate.
/// </summary>
/// <returns>
/// Returns a double representing the tax liability for the investor.
/// </returns>
public override Calculation<Investor> CalculateTaxRate()
{
return delegate(Investor investor)
{
double income = investor.Income;
if (income >= 0.0 && income <= 7550.99)
return 0.10;
else if (income >= 7551.00 && income <= 30650.99)
return 0.15;
else if (income >= 30651.00 && income <= 74200.99)
return 0.25;
else if (income >= 74201.00 && income <= 154800.99)
return 0.28;
else if (income >= 154801.00 && income <= 336550.99)
return 0.33;
else
return 0.35;
};
}
/// <summary>
/// Calculates the tax liability.
/// </summary>
/// <returns>
/// Returns a double representing the tax rate for the investor.
/// </returns>
public override Calculation<Investor> CalculateTaxLiability()
{
return delegate(Investor investor)
{
double taxLiability = 0.0;
double income = investor.Income;
if (income > 7550.99)
{
taxLiability += 7550.99 * 0.10;
}
if (income >= 0.0 && income <= 7550.99)
{
taxLiability += income * 0.10;
}
if (income > 30650.99)
{
taxLiability += (30650.99 - 7551.00) * 0.15;
}
if (income >= 7551.00 && income <= 30650.99)
{
taxLiability += (income - 7551.00) * 0.15;
}
if (income > 74200.99)
{
taxLiability += (74200.99 - 30651.00) * 0.25;
}
if (income >= 30651.00 && income <= 74200.99)
{
taxLiability += (income - 30651.00) * 0.25;
}
if (income > 154800.99)
{
taxLiability += (154800.99 - 74201.00) * 0.28;
}
if (income >= 74201.00 && income <= 154800.99)
{
taxLiability += (income - 74201.00) * 0.28;
}
if (income > 336550.99)
{
taxLiability += (336550.99 - 154801.00) * 0.33;
}
if (income >= 154801.00 && income <= 336550.99)
{
taxLiability += (income - 154801.00) * 0.33;
}
if (income > 336551.00)
{
taxLiability += (income - 336551.00) * 0.35;
}
return taxLiability;
};
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.