/// <summary>
 /// Gets the unadjusted calculation date schedule.
 /// </summary>
 /// <param name="effectiveDate">The effective date.</param>
 /// <param name="terminationDate">The termination date.</param>
 /// <param name="regularPeriodStartDate">The regular period start date.</param>
 /// <param name="periodFrequency">The period frequency.</param>
 /// <param name="stubPeriodType">Type of the stub period.</param>
 /// <returns></returns>
 public List <CalculationPeriod> GetUnadjustedCalculationDateSchedule(DateTime effectiveDate, DateTime terminationDate, DateTime regularPeriodStartDate, CalculationPeriodFrequency periodFrequency, StubPeriodTypeEnum?stubPeriodType)
 {
     CalculationPeriodDates = null;
     PeriodInterval         = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
     _effectiveDate         = effectiveDate;
     _termDate      = terminationDate;
     RollConvention = periodFrequency.rollConvention;
     _unadjustedDateScheduleList = CalculationPeriodHelper.GenerateUnadjustedCalculationDates(effectiveDate, terminationDate, regularPeriodStartDate, periodFrequency, stubPeriodType);
     return(_unadjustedDateScheduleList);
 }
 /// <summary>
 /// Gets the unadjusted calculation date schedule.
 /// </summary>
 /// <param name="effectiveDate">The effective date.</param>
 /// <param name="periodToTerminationDate">The period to termination date.</param>
 /// <param name="periodFrequency">The period frequency.</param>
 /// <returns></returns>
 public List <CalculationPeriod> GetUnadjustedCalculationDateSchedule(DateTime effectiveDate, CalculationPeriodFrequency periodToTerminationDate, CalculationPeriodFrequency periodFrequency)
 {
     CalculationPeriodDates = null;
     PeriodInterval         = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
     _effectiveDate         = effectiveDate;
     _termDate      = PeriodInterval.Add(effectiveDate);
     RollConvention = periodFrequency.rollConvention;
     _unadjustedDateScheduleList = CalculationPeriodHelper.GenerateUnadjustedCalculationDates(effectiveDate, periodToTerminationDate, periodFrequency);
     return(_unadjustedDateScheduleList);
 }
 /// <summary>
 /// Gets the unadjusted calculation date schedule.
 /// </summary>
 /// <param name="calculationPeriodDates">The calculation period dates.</param>
 /// <returns></returns>
 public List <CalculationPeriod> GetUnadjustedCalculationDateSchedule(CalculationPeriodDates calculationPeriodDates)
 {
     CalculationPeriodDates = calculationPeriodDates;
     PeriodInterval         = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(calculationPeriodDates.calculationPeriodFrequency);
     _effectiveDate         = XsdClassesFieldResolver.CalculationPeriodDatesGetEffectiveDate(calculationPeriodDates).unadjustedDate.Value;
     _termDate      = XsdClassesFieldResolver.CalculationPeriodDatesGetTerminationDate(calculationPeriodDates).unadjustedDate.Value;
     RollConvention = calculationPeriodDates.calculationPeriodFrequency.rollConvention;
     _unadjustedDateScheduleList = CalculationPeriodHelper.GenerateUnadjustedCalculationDates(_effectiveDate, _termDate, calculationPeriodDates);
     return(_unadjustedDateScheduleList);
 }
        public void LongFinalStubSpecifiedButNoStub()
        {
            DateTime                   startDate       = new DateTime(2007, 01, 5);
            DateTime                   endDate         = new DateTime(2012, 01, 5);
            RollConventionEnum         rollConvention  = RollConventionEnum.Item5;
            CalculationPeriodFrequency periodFrequency = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            CalculationPeriodSchedule  cps             = new CalculationPeriodSchedule();
            Period periodInterval = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
            List <CalculationPeriod> unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateSchedule(startDate, endDate, periodInterval, rollConvention, StubPeriodTypeEnum.LongFinal);

            Assert.AreEqual(unadjustedCalcPeriods.Count, 20);
            Assert.IsFalse(cps.HasFinalStub);
            Assert.IsFalse(cps.HasInitialStub);
        }
        public void ShortFinalStubSpecifiedFromTermination()
        {
            DateTime                   startDate       = new DateTime(2007, 01, 5);
            DateTime                   endDate         = new DateTime(2010, 01, 5);
            RollConventionEnum         rollConvention  = RollConventionEnum.Item12;
            CalculationPeriodFrequency periodFrequency = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            Period periodInterval             = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
            CalculationPeriodSchedule cps     = new CalculationPeriodSchedule();
            DateTime lastRegularPeriodEndDate = new DateTime(2009, 8, 12);
            List <CalculationPeriod> unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateScheduleFromTermDate(startDate, endDate, periodInterval, lastRegularPeriodEndDate, rollConvention, StubPeriodTypeEnum.ShortFinal);

            Assert.AreEqual(unadjustedCalcPeriods.Count, 13);
            Assert.IsTrue(cps.HasFinalStub);
            Assert.IsTrue(cps.HasInitialStub);
            Assert.IsTrue(CalculationPeriodHelper.IsShortStub(unadjustedCalcPeriods[unadjustedCalcPeriods.Count - 1], cps.PeriodInterval));
        }