Ejemplo n.º 1
0
 private List<TaxSlab> GetAppropriateTaxSlabs(User taxPayer)
 {
     if (taxPayer.IsFemale()){
         return _femaleTaxSlabs;
     }
     return _maleTaxSlabs;
 }
Ejemplo n.º 2
0
        public void ShouldSaveAndLoadTaxStatement()
        {
            IRepository repository = new Repository();
            var password = new Password { PasswordString = "abc" };
            var email = new EmailAddress("*****@*****.**");
            var taxPayer= new User(email, password);

            taxPayer.FromMetro = true;
            taxPayer.RentPaid = 8000.00;

            AnnualSalary salary = new AnnualSalary() { Basic = 10000, Epf = 2000, Hra = 6000, Id = "salary", ProfessionalTax = 200, SpecialAllowance = 5000, TaxDedeuctedAtSource = 5000};
            TaxStatement taxStatement = new TaxStatement(salary, taxPayer);

            DonationsUnder80G donationsUnder80G = new DonationsUnder80G();
            var halfExemptDonation = new HalfExemptDonation(20000);
            donationsUnder80G.AddDonation(halfExemptDonation);
            var fullyExemptDonation = new FullyExemptDonation(10000);
            donationsUnder80G.AddDonation(fullyExemptDonation);
            taxStatement.DonationsUnder80G = donationsUnder80G;
            repository.Save(taxStatement);

            List<TaxStatement> taxStatements = repository.LoadAll<TaxStatement>();
            var loadedTaxStatement = taxStatements.FirstOrDefault(stmt => stmt.Id == taxStatement.Id);
            Assert.IsNotNull(loadedTaxStatement);
            Assert.IsNotNull(loadedTaxStatement.TaxPayer);
            Assert.IsTrue(taxStatement.GetDonationsUnder80G().Contains(halfExemptDonation));
            Assert.IsTrue(taxStatement.GetDonationsUnder80G().Contains(fullyExemptDonation));
        }
Ejemplo n.º 3
0
        public void MustCalculateNetPayableTaxWithAnnualSalaryOtherIncomesAndChapter6Investments()
        {
            var taxPayer = new User(50000, true, Gender.Female);

            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
            {
                Basic = 810000.50,
                Hra = 1000,
                ProfessionalTax = 100,
                SpecialAllowance = 10
            };

            OtherIncomes otherIncomes = new OtherIncomes();
            otherIncomes.Add(new OtherIncomeItem("Income from Interest", 4000.0));
            otherIncomes.Add(new OtherIncomeItem("Income from House Rent", 8000.0));

            Chapter6Investments investments = new Chapter6Investments();
            investments.Add(new LifeInsurance(50000));
            investments.Add(new Elss(60000));

            TaxStatement stmt = new TaxStatement(asal, taxPayer);
            stmt.HousingLoanInterest = new HousingLoanInterest(10000);
            stmt.OtherIncomes = otherIncomes;
            stmt.Chapter6Investments = investments;

            Assert.AreEqual(120473,
                stmt.CalculateNetPayableTax(), 2);
        }
Ejemplo n.º 4
0
        private void ValidateTaxComponents(double taxableIncome, User taxPayer)
        {
            if (taxPayer == null)
                throw new ArgumentException("Tax payer details not available");

            if (taxableIncome <= 0)
                throw new ArgumentException("Invalid taxable income");
        }
Ejemplo n.º 5
0
        public void ShouldNotRegisterUserIfNotUnique()
        {
            var repository = new Mock<IRepository>();

            var password = new Password {PasswordString = "abc"};
            var user = new User(new EmailAddress("*****@*****.**"), password, repository.Object);

            repository.Setup(rep => rep.LoadByEmailId(user.EmailAddress)).Returns(user);

            Assert.Throws<DuplicateUserException>(user.Register);
        }
Ejemplo n.º 6
0
 public void ShouldCalculateHraExemption()
 {
     var taxPayer = new User(50000, true, Gender.Male);
     var annualSalary = new AnnualSalary
                            {
                                Basic = 100000,
                                Hra = 40000,
                                ProfessionalTax = 100,
                                SpecialAllowance = 10
                            };
     Assert.AreEqual(40000, annualSalary.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid));
 }
Ejemplo n.º 7
0
        public void ShouldRegisterUserIfUnique()
        {
            var repository = new Mock<IRepository>();

            var password = new Password {PasswordString = "abc"};
            var user = new User(new EmailAddress("*****@*****.**"), password, repository.Object);

            repository.Setup(rep => rep.LoadByEmailId(user.EmailAddress)).Returns(() => (User) null);
            repository.Setup(rep => rep.Save(user));

            user.Register();

            repository.VerifyAll();
        }
Ejemplo n.º 8
0
        public double ComputeTax(double taxableIncome, User taxPayer)
        {
            ValidateTaxComponents(taxableIncome, taxPayer);
            var slabsInUse = GetAppropriateTaxSlabs(taxPayer);
            var tax = 0.00;
            foreach (var slab in slabsInUse){
                tax += slab.GetTax(taxableIncome);
                taxableIncome = taxableIncome - slab.SlabValue;
                if (taxableIncome <= 0)
                    break;
            }

            return tax;
        }
Ejemplo n.º 9
0
 public void MustCalculateNetPayableTaxWithAnnualSalaryAndDeductions()
 {
     var taxPayer = new User(0, true, Gender.Female);
     TaxSlabs ts = TaxSlabs.GetInstance();
     AnnualSalary asal = new AnnualSalary
                            {
                                Basic = 600000,
                                Hra = 100000
                            };
     TaxStatement stmt = new TaxStatement(asal,taxPayer);
     DonationsUnder80G donationsUnder80G = new DonationsUnder80G();
     donationsUnder80G.AddDonation(new FullyExemptDonation(1000));
     stmt.DonationsUnder80G = donationsUnder80G;
     Assert.AreEqual(116700.0, stmt.CalculateNetPayableTax(),0.01);
 }
Ejemplo n.º 10
0
        public void ComputeTaxShouldDeductTDSValueFromTheNetTaxPayableValue()
        {
            var taxPayer = new User(50000, true, Gender.Female);
            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
            {
                Basic = 200000.50,
                Hra = 1000,
                ProfessionalTax = 100,
                SpecialAllowance = 10,
                TaxDedeuctedAtSource = 1000
            };
            TaxStatement stmt = new TaxStatement(asal, taxPayer);

            Assert.AreEqual(891.04,stmt.CalculateNetPayableTax(), 2);
        }
Ejemplo n.º 11
0
        public void MustCalculateNetPayableTaxWithAnnualSalaryAndOtherIncomes()
        {
            var taxPayer = new User(50000, true, Gender.Female);
            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
                                   {
                                       Basic = 200000.50,
                                       Hra = 1000,
                                       ProfessionalTax = 100,
                                       SpecialAllowance = 10
                                   };
            TaxStatement stmt = new TaxStatement(asal,taxPayer);

            OtherIncomes otherIncomes = new OtherIncomes();
            otherIncomes.Add(new OtherIncomeItem("Income from Interest", 4000.0));
            otherIncomes.Add(new OtherIncomeItem("Income from House Rent", 8000.0));
            stmt.OtherIncomes = otherIncomes;

            double totalIncome = asal.GetTaxableSalary() + otherIncomes.CalculateTotalAmount();

            Assert.AreEqual(3091,
                stmt.CalculateNetPayableTax(),2);
        }
Ejemplo n.º 12
0
        public void MustCalculateNetPayableTaxWithAnnualSalaryOtherIncomesAndChapter6Investments()
        {
            var taxPayer = new User(50000, true, Gender.Female);
            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
                                   {
                                       Basic = 800000.50,
                                       Hra = 1000,
                                       ProfessionalTax = 100,
                                       SpecialAllowance = 10
                                   };

            OtherIncomes otherIncomes = new OtherIncomes();
            otherIncomes.Add(new OtherIncomeItem("Income from Interest", 4000.0));
            otherIncomes.Add(new OtherIncomeItem("Income from House Rent", 8000.0));

            Chapter6Investments investments = new Chapter6Investments();
            investments.Add(new LifeInsurance(50000));
            investments.Add(new Elss(60000));

            TaxStatement stmt = new TaxStatement(asal,taxPayer);
            stmt.OtherIncomes = otherIncomes;
            stmt.Chapter6Investments = investments;

            double totalIncome = ((asal.GetTaxableSalary() + otherIncomes.CalculateTotalAmount())
                                  -
                                  (asal.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid)));

            double totalInvestments = (asal.Epf + investments.GetTotal());

            totalIncome -= totalInvestments <= Chapter6Investments.Cap
                 ? totalInvestments
                 : Chapter6Investments.Cap;

            Assert.AreEqual(120473,
                stmt.CalculateNetPayableTax(),2);
        }
Ejemplo n.º 13
0
 public void MustCalculateNetPayableTaxWithOnlyAnnualSalary()
 {
     var taxPayer = new User(50000, true, Gender.Female);
     TaxSlabs ts = TaxSlabs.GetInstance();
     AnnualSalary asal = new AnnualSalary
                            {
                                Basic = 200000.50,
                                Hra = 1000,
                                ProfessionalTax = 100,
                                SpecialAllowance = 10
                            };
     TaxStatement stmt = new TaxStatement(asal,taxPayer);
     Assert.AreEqual(1891.05d, stmt.CalculateNetPayableTax());
 }
Ejemplo n.º 14
0
 public TaxStatement(AnnualSalary annualSalary, User taxPayer)
 {
     AnnualSalary = annualSalary;
     TaxPayer = taxPayer;
 }
Ejemplo n.º 15
0
 public void ShouldBeAbleToGetRentPaid()
 {
     var taxPayer = new User(50000, true, Gender.Male);
     Assert.AreEqual(50000, taxPayer.RentPaid);
 }
Ejemplo n.º 16
0
        public void ShouldSaveTheInvestmentAlongWithTaxStatement()
        {
            var taxPayer = new User(0, true, Gender.Female);
            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
            {
                Basic = 600000,
                Hra = 100000
            };
            TaxStatement stmt = new TaxStatement(asal, taxPayer);
            stmt.Chapter6Investments=  new Chapter6Investments();
            LifeInsurance LICInvestment=new LifeInsurance(10000);
            stmt.Chapter6Investments.Add(LICInvestment);
            LICInvestment.TaxStatement = stmt;

            Repository taxStatementRepo=new Repository();
            taxStatementRepo.Save(stmt);

            Assert.AreEqual(LICInvestment.GetAmount(), taxStatementRepo.GetInvestmentDetails(stmt.Id).GetAmount());
        }
Ejemplo n.º 17
0
 public void ShouldReturnRemtPaidAdjustedToBasicAsHraExemptionWhenItIsMinimumOfAllTaxComponents()
 {
     var taxPayer = new User(30000, true, Gender.Male);
     var annualSalary = new AnnualSalary
                            {
                                Basic = 100000,
                                Hra = 60000,
                                ProfessionalTax = 100,
                                SpecialAllowance = 10
                            };
     Assert.AreEqual(20000, annualSalary.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid));
 }
Ejemplo n.º 18
0
 public void ShouldBeAbleToCheckIfTaxPayeeIsFromMetro()
 {
     var taxPayer = new User(50000, true, Gender.Male);
     Assert.True(taxPayer.FromMetro);
 }
Ejemplo n.º 19
0
        private double CalculateGrossIncome(User taxPayer)
        {
            double retAmt = AnnualSalary.GetTaxableSalary();

            retAmt -= GetHousingLoanInterestAmount();

            if (OtherIncomes != null)
                retAmt += OtherIncomes.CalculateTotalAmount();

            retAmt -= (AnnualSalary.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid) +
                AnnualSalary.ProfessionalTax);

            retAmt -= DonationsUnder80G.GetDeduction();

            return retAmt;
        }
Ejemplo n.º 20
0
        public void ShouldReturnFortyPercentageOfBasicAsHraExemptionWhenItIsMinimumOfAllTaxComponentsAndPayerIsFromMetro()
        {
            var taxPayer = new User(65000, false, Gender.Male);
            var annualSalary = new AnnualSalary
                                   {
                                       Basic = 100000,
                                       Hra = 60000,
                                       ProfessionalTax = 100,
                                       SpecialAllowance = 10
                                   };

            Assert.AreEqual(40000, annualSalary.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid));
        }
Ejemplo n.º 21
0
 public void ShouldNotCalculateHraExemptionIfHraComponentIsNotAvailable()
 {
     var taxPayer = new User(30000, true, Gender.Male);
     var annualSalary = new AnnualSalary
                            {
                                Basic = 100000,
                                Hra = 0,
                                ProfessionalTax = 100,
                                SpecialAllowance = 10
                            };
     Assert.Throws<Exception>(() => annualSalary.CalculateHraExemption(taxPayer.FromMetro, taxPayer.RentPaid));
 }
Ejemplo n.º 22
0
        public void ShouldSaveAndLoadUser()
        {
            IRepository repository = new Repository();

            var password = new Password { PasswordString = "abc" };
            var email = new EmailAddress("*****@*****.**");
            var user = new User(email, password);

            user.FromMetro = true;
            user.RentPaid = 8000.00;

            user.Repository = repository;

            user.Register();

            User actualUser = repository.LoadByEmailId(email);

            Assert.IsNotNull(actualUser);
            Assert.AreEqual(email, actualUser.EmailAddress);
            Assert.AreEqual(user.FromMetro, actualUser.FromMetro);
            Assert.AreEqual(user.RentPaid, actualUser.RentPaid);
        }
Ejemplo n.º 23
0
 public void ShouldReturnTrueIfTaxPayerIsFemale()
 {
     User taxPayer = new User(0, false, Gender.Female);
     Assert.True(taxPayer.IsFemale());
 }