/// <summary> /// Pulls an XmlNode from the LineItem /// </summary> public String ToXml() { return("<LineItem>\n" + " <Date>" + this.m_Date.ToShortDateString() + "</Date>\n" + " <Amount>" + this.m_Amount.ToString() + "</Amount>\n" + " <UnitPeriods>" + this.m_Span.Periods.ToString() + "</UnitPeriods>\n" + " <OddDays>" + this.m_Span.OddDays.ToString() + "</OddDays>\n" + " <NumberOccurrences>" + this.m_Occurences.ToString() + "</NumberOccurrences>\n" + " <Recurrence>" + DateTimeCalculations.GetUnitPeriodString(this.m_Recurrence) + "</Recurrence>\n" + " <PVIF>" + this.m_PVIF.ToString() + "</PVIF>\n" + " <PresentValue>" + this.m_PresentValue.ToString() + "</PVIF>\n" + " <Balance>" + this.m_Balance.ToString() + "</Balance>\n" + "</LineItem>"); }
/// <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); } }
public String ToXml() { System.Text.StringBuilder sb = new StringBuilder(); sb.AppendLine("<LineItems>"); sb.AppendLine(" <APR>" + this.m_APR.ToString() + "</APR>"); sb.AppendLine(" <CommonPeriod>" + DateTimeCalculations.GetUnitPeriodString(this.m_CommonPeriod) + "</CommonPeriod>"); sb.AppendLine(" <PeriodsPerYear>" + this.m_PeriodsPerYear.ToString() + "</PeriodsPerYear>"); sb.AppendLine(" <DaysPerPeriod>" + this.m_DaysPerPeriod.ToString() + "</DaysPerPeriod>"); sb.AppendLine(" <StartDate>" + this.m_StartDate.ToShortDateString() + "</StartDate>"); sb.AppendLine(" <FinalBalance>" + this.m_FinalBalance.ToString() + "</FinalBalance>"); for (int i = 0; i < this.m_Items.Count; i++) { LineItem li = (LineItem)this.m_Items[i]; sb.Append(li.ToXml()); } sb.AppendLine("</LineItems>"); return(sb.ToString()); }
/// <summary> /// Finished Adding Line Items, must be used prior to adding to APR /// </summary> public void MarkComplete() { this.Sort(); //And now we calculate the Unit Period this.m_CommonPeriod = DateTimeCalculations.CalculateCommonPeriod(this); this.m_DaysPerPeriod = DateTimeCalculations.DaysPerPeriod(this.m_CommonPeriod); this.m_PeriodsPerYear = DateTimeCalculations.PeriodsPerYear(this.m_CommonPeriod); //Mark all line items as complete for (int i = 0; i < this.m_Items.Count; i++) { LineItem li = (LineItem)this.m_Items[i]; li.Complete(); } m_Completed = true; }
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); }