Ejemplo n.º 1
0
        /// <summary>
        /// Gets a Date based on a given period in the Loan Lifecycle.
        /// </summary>
        internal static DateTime GetDateFromPeriod(PeriodSpan Span, DateTime StartDate, UnitPeriod CommonPeriod)
        {
            DateTime dtReturn;

            try
            {
                if (CommonPeriod.periodType == UnitPeriodType.Monthly)
                {
                    dtReturn = StartDate.AddMonths(CommonPeriod.numPeriods * Span.Periods).AddDays(Span.OddDays);
                }
                else if (CommonPeriod.periodType == UnitPeriodType.Yearly)
                {
                    dtReturn = StartDate.AddYears(CommonPeriod.numPeriods * Span.Periods).AddDays(Span.OddDays);
                }
                else if (CommonPeriod.periodType == UnitPeriodType.Weekly)
                {
                    dtReturn = StartDate.AddDays(CommonPeriod.numPeriods * Span.Periods * 7).AddDays(Span.OddDays);
                }
                else
                {
                    dtReturn = StartDate.AddDays(CommonPeriod.numPeriods * Span.Periods);
                }
                return(dtReturn);
            }
            catch (Exception ex)
            {
                ApplicationException newex = new ApplicationException("Exception in DateTimeCalculations.GetDateFromPeriod", ex);
                throw(newex);
            }
        }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 internal static double GetPVIF(PeriodSpan span, double APR, double PeriodsPerYear, double DaysPerPeriod)
 {
     return((double)(1 / (Math.Pow((1 + (APR / PeriodsPerYear)), (double)span.Periods) * (1 + ((span.OddDays / DaysPerPeriod) * (APR / PeriodsPerYear))))));
 }