Click here to Skip to main content
11,630,646 members (78,880 online)
Click here to Skip to main content
Add your own
alternative version

Who cares about Domain Rules?

, 20 Nov 2006 MIT 72K 62 116
With this article, I am evolving a domain problem towards the best possible solution.
domainrules_src.zip
BusinessRules
0 - Procedural_Way
0 - Procedural_Way.smp
ProceduralWay.cd
Tests
1 - Evolution One
1 - Evolution One.smp
EvolutionOne.cd
Tests
2 - Evolution Two
2 - Evolution Two.smp
EvolutionTwo.cd
Tests
3 - Evolution Three
3 - Evolution Three.smp
EvolutionThree.cd
IncomeTaxEngine.cd
Tests
4 - Evolution Four
4 - Evolution Four.smp
EvolutionFour.cd
Tests
5 - Evolution Five
5 - Evolution Five.smp
EvolutionFive.cd
TaxBandGenerator.cd
Tests
bin
Debug
BusinessRules.dll
BusinessRules.dll.lastcodeanalysissucceeded
NMock2.dll
BusinessRules.csproj.user
obj
Debug
BusinessRules.dll
TempPE
Properties
Tools
NMock2.dll
nunit.framework.dll
namespace BusinessRules.Evolution_Three
{
    /// <summary>
    /// Australian Investor Business Rule Domain object specific to australian investors.
    /// </summary>
    internal class AustralianIncomeTaxEngine : IncomeTaxEngine
    {
        #region Methods

        /// <summary>
        /// Calculates the tax rate.
        /// </summary>
        /// <param name="income">The investor.</param>
        /// <returns>
        /// Returns a double representing the tax liability for the investor.
        /// </returns>
        public override double CalculateTaxRate(double income)
        {
            if (income >= 0.0 && income <= 6000.99)
                return 0.0;
            else if (income >= 6001.00 && income <= 25000.99)
                return 0.15;
            else if (income >= 25001.00 && income <= 75000.99)
                return 0.30;
            else if (income >= 75001.00 && income <= 150000.99)
                return 0.40;
            else
                return 0.45;
        }

        /// <summary>
        /// Calculates the tax liability.
        /// </summary>
        /// <param name="income">The investor.</param>
        /// <returns>
        /// Returns a double representing the tax rate for the investor.
        /// </returns>
        public override double CalculateTaxLiability(double income)
        {
            double taxLiability = 0.0;

            if (income >= 6001.00 && income <= 25000.99)
            {
                taxLiability += (income - 6000.99) * 0.15;
            }
            if (income > 25000.99)
            {
                taxLiability += (25000.99 - 6001.00) * 0.15;
            }
            if (income > 75000.99)
            {
                taxLiability += (75000.99 - 25001.00) * 0.30;
            }
            if (income >= 25001.00 && income <= 75000.99)
            {
                taxLiability += (income - 25001.00) * 0.30;
            }
            if (income > 150000.99)
            {
                taxLiability += (150000.99 - 75001.00) * 0.40;
            }
            if (income >= 75001.00 && income <= 150000.99)
            {
                taxLiability += (income - 75001.00) * 0.40;
            }
            if (income > 150000.99)
            {
                taxLiability += (income - 150000.99) * 0.45;
            }
            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.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Maruis Marais
Web Developer
New Zealand New Zealand
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150723.1 | Last Updated 21 Nov 2006
Article Copyright 2006 by Maruis Marais
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid