/// <summary> /// Mark the Line Item As Complete. Must only be done by the Line Item Collection /// </summary> internal void Complete() { if (this.m_DateType == DateType.Date) { this.m_Span = DateTimeCalculations.GetNumberPeriods(this.Parent.StartDate, this.m_Date, this.Parent.CommonPeriod); } else { if (this.Parent.CommonPeriod.numPeriods < 1 || this.Parent.CommonPeriod.numPeriods < 1) { throw new ApplicationException("Cannot mark LineItem for completion. A period has been specified, but there is no common period for the Parent LineItemCollection Class"); } this.m_Date = DateTimeCalculations.GetDateFromPeriod(this.m_Span, this.Parent.StartDate, this.Parent.CommonPeriod); } }
internal static double GetPVIFA(DateTime StartDate, DateTime CurrLIDate, UnitPeriod frequency, double APR, double PeriodsPerYear, double DaysPerPeriod, int NumberOccurrences, UnitPeriod CommonPeriod) { StringBuilder sb = new StringBuilder(); int ic = 1; double pvifa = 0.0d; //return value, running tally of PVIF PeriodSpan lastSpan; PeriodSpan currSpan = DateTimeCalculations.GetNumberPeriods(StartDate, CurrLIDate, CommonPeriod); lastSpan.OddDays = 0; lastSpan.Periods = 0; for (int i = 0; i < NumberOccurrences; i++) { //get the PVIF for this current item and add to the pvifa pvifa += GetPVIF(currSpan, APR, PeriodsPerYear, DaysPerPeriod); sb.AppendLine(ic.ToString() + " " + CurrLIDate.ToString() + " " + currSpan.Periods.ToString() + currSpan.OddDays.ToString() + " " + pvifa.ToString()); //TODO... figure out how to determine the recurrence in periods if //periods other than a monthly type or annual are passed in. //Perhaps we should restrict to only dates instead? lastSpan = currSpan; CurrLIDate = DateTimeCalculations.AddPeriodToDate(CurrLIDate, frequency); currSpan = DateTimeCalculations.GetNumberPeriods(StartDate, CurrLIDate, CommonPeriod); } return(pvifa); }