Ejemplo n.º 1
0
        public void Add(OneDayState odls)
        {
            if ((odls == null) || (this[odls.Date] != null))
            {
                return;
            }

            Dates[odls.Date] = odls;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <param name="openPrincipal"></param>
        /// <param name="previousDay"></param>
        public OneDayState(DateTime d, decimal openPrincipal, OneDayState previousDay)
        {
            //IsReschedulingDay = false;
            //IsBetweenLastPaymentAndReschedulingDay = false;
            Date = d;
            OpenPrincipalForInterest     = openPrincipal;
            OpenPrincipalAfterRepayments = openPrincipal;
            AssignedFees      = 0;
            DailyInterestRate = 0;
            this.previousDay  = previousDay;

            Str = new FormattedData(this);
        }         // constructor
Ejemplo n.º 3
0
 internal FormattedData(OneDayState odls)
 {
     this.odls = odls;
 }
Ejemplo n.º 4
0
        public string ToFormattedString(string rowPrefix)
        {
            const string date = "Date";
            const string openPrincipalForInterest     = "For interest";
            const string openPrincipalAfterRepayments = "After repayments";
            const string dailyInterest     = "Daily accrued interest";
            const string assignedFees      = "Assigned fees";
            const string dailyInterestRate = "Daily interest rate";
            const string currentBalance    = "Current balance";
            const string repaidPrincipal   = "Principal";
            const string repaidInterest    = "Interest";
            const string repaidFees        = "Fees";
            const string ignoredDay        = "Ignored";
            const string notesTitle        = "Notes";

            const string separator = "|";

            int dateLen              = date.Length;
            int openPrincipalLen     = Math.Max(openPrincipalForInterest.Length, openPrincipalAfterRepayments.Length);
            int dailyInterestLen     = dailyInterest.Length;
            int assignedFeeLen       = assignedFees.Length;
            int dailyInterestRateLen = dailyInterestRate.Length;
            int currentBalanceLen    = currentBalance.Length;
            int repaidPrincipalLen   = repaidPrincipal.Length;
            int repaidInterestLen    = repaidInterest.Length;
            int repaidFeeLen         = repaidFees.Length;
            int ignoredDayLen        = ignoredDay.Length;
            int notesLen             = notesTitle.Length;

            foreach (OneDayState dd in Days)
            {
                dateLen              = Math.Max(dateLen, dd.Str.Date.Length);
                openPrincipalLen     = Math.Max(openPrincipalLen, dd.Str.OpenPrincipalForInterest.Length);
                openPrincipalLen     = Math.Max(openPrincipalLen, dd.Str.OpenPrincipalAfterRepayments.Length);
                dailyInterestLen     = Math.Max(dailyInterestLen, dd.Str.DailyInterest.Length);
                assignedFeeLen       = Math.Max(assignedFeeLen, dd.Str.AssignedFees.Length);
                dailyInterestRateLen = Math.Max(dailyInterestRateLen, dd.Str.DailyInterestRate.Length);
                currentBalanceLen    = Math.Max(currentBalanceLen, dd.Str.CurrentBalance.Length);
                repaidPrincipalLen   = Math.Max(repaidPrincipalLen, dd.Str.RepaidPrincipal.Length);
                repaidInterestLen    = Math.Max(repaidInterestLen, dd.Str.RepaidInterest.Length);
                repaidFeeLen         = Math.Max(repaidFeeLen, dd.Str.RepaidFees.Length);
                notesLen             = Math.Max(notesLen, GetNote(dd.Date).Length);
            }             // for each day

            var repaidLen = repaidPrincipalLen + repaidInterestLen + repaidFeeLen + 4 + 2 * separator.Length;

            var openPrincipalHeaderLen = 2 * openPrincipalLen + 1 + 2 * separator.Length;

            var result = new List <string>();

            result.Add(string.Format("{0}{1}{2}{1}", rowPrefix, separator, string.Join(
                                         separator,
                                         OneDayState.FormatField(string.Empty, dateLen),
                                         OneDayState.FormatField("Open principal", -openPrincipalHeaderLen),
                                         OneDayState.FormatField(string.Empty, dailyInterestLen),
                                         OneDayState.FormatField(string.Empty, assignedFeeLen),
                                         OneDayState.FormatField(string.Empty, dailyInterestRateLen),
                                         OneDayState.FormatField(string.Empty, currentBalanceLen),
                                         OneDayState.FormatField("Repaid", -repaidLen),
                                         OneDayState.FormatField(string.Empty, ignoredDayLen),
                                         OneDayState.FormatField(string.Empty, notesLen)
                                         )));

            result.Add(string.Format("{0}{1}{2}{1}", rowPrefix, separator, string.Join(
                                         separator,
                                         OneDayState.FormatField(date, -dateLen),
                                         OneDayState.FormatField(openPrincipalForInterest, -openPrincipalLen),
                                         OneDayState.FormatField(openPrincipalAfterRepayments, -openPrincipalLen),
                                         OneDayState.FormatField(dailyInterest, -dailyInterestLen),
                                         OneDayState.FormatField(assignedFees, -assignedFeeLen),
                                         OneDayState.FormatField(dailyInterestRate, -dailyInterestRateLen),
                                         OneDayState.FormatField(currentBalance, -currentBalanceLen),
                                         OneDayState.FormatField(repaidPrincipal, -repaidPrincipalLen),
                                         OneDayState.FormatField(repaidInterest, -repaidInterestLen),
                                         OneDayState.FormatField(repaidFees, -repaidFeeLen),
                                         OneDayState.FormatField(ignoredDay, -ignoredDayLen),
                                         OneDayState.FormatField(notesTitle, -notesLen)
                                         )));

            foreach (OneDayState dd in Days)
            {
                result.Add(dd.ToFormattedString(
                               rowPrefix,
                               separator,
                               GetNote(dd.Date),
                               -dateLen,
                               openPrincipalLen,
                               dailyInterestLen,
                               assignedFeeLen,
                               dailyInterestRateLen,
                               currentBalanceLen,
                               repaidPrincipalLen,
                               repaidInterestLen,
                               repaidFeeLen,
                               ignoredDayLen,
                               -notesLen
                               ));
            }             // for each day

            return(string.Join("\n", result));
        }         // ToFormattedString