Exemplo n.º 1
0
        public void ShouldGetTheTaxationPeriodForFinYear()
        {
            int curYear = DateTime.Today.Year;
            int nextYear = DateTime.Today.Year + 1;
            int prevYear = curYear - 1;

            var finYear = new FinYear(curYear);
            var taxationPeriod = new FinYear.TaxationPeriod(new DateTime(curYear, 4, 1),
                                                            new DateTime(nextYear, 3, 31));
            Assert.AreEqual(taxationPeriod, finYear.GetTaxationPeriod());

            var finYearPrev = new FinYear(prevYear);
            var prevtaxationPeriod = new FinYear.TaxationPeriod(new DateTime(prevYear, 4, 1),
                                                                new DateTime(curYear, 3, 31));
            Assert.AreEqual(prevtaxationPeriod, finYearPrev.GetTaxationPeriod());
        }
Exemplo n.º 2
0
 public void CalcShortTermCapitalGainTax(FinYear year)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 public ShortTermTaxCalculator(List<Transaction> transactions, FinYear yearForStcg)
 {
     Transactions = transactions;
     YearForStcg = yearForStcg;
 }
Exemplo n.º 4
0
 public virtual bool IsLongTerm(FinYear year)
 {
     return (this.Date < year.GetTaxationPeriod().Value.StartDate);
 }
Exemplo n.º 5
0
        public List<Transaction> GetTransactionBalance()
        {
            int leftOverBuys = 0;
            FinYear theYearBefore = new FinYear(YearForStcg.StartYear-1);
            Instrument theBuyInstrument = Transactions[0].Instrument;

            for (int i = 0; i < Transactions.Count;)
            {
                if (Transactions[i].Date.CompareTo(theYearBefore.GetTaxationPeriod().Value.StartDate) > 0)
                {
                    break;
                }
                if (Transactions[i].GetType() == typeof(BuyTransaction))
                 {
                     leftOverBuys += Transactions[i].Quantity;
                     Transactions.Remove(Transactions[i]);

                 }
                else if (Transactions[i].GetType() == typeof(SellTransaction))
                {
                    leftOverBuys -= Transactions[i].Quantity;
                    Transactions.Remove(Transactions[i]);

                }

            }
            BuyTransaction theBuyToAppendToList = new BuyTransaction(new DateTime(2008, 06, 01), theBuyInstrument, leftOverBuys, new Price(0),0, 0);

            if (theBuyToAppendToList.Quantity > 0)
            {
                //             Transactions.Insert(0, theBuyToAppendToList);

                for (int i = 0; i < Transactions.Count;i++)
                {
                    if (Transactions[i].GetType() == typeof (SellTransaction))
                    {
                       leftOverBuys -= Transactions[i].Quantity;
                       if(leftOverBuys<0)
                       {
                           Transactions[i].Quantity = -leftOverBuys;
                           break;
                       }
                       else if(leftOverBuys>0)
                       {
                           Transactions.Remove(Transactions[i]);
                           i--;
                       }
                    }
                }
            }
            return Transactions;
        }