public GetTaxationPeriod ( ) : TaxationPeriod? | ||
return | TaxationPeriod? |
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()); }
public virtual bool IsLongTerm(FinYear year) { return (this.Date < year.GetTaxationPeriod().Value.StartDate); }
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; }