Пример #1
0
        /// <summary>
        /// Projects how long it will take to repay all loans with a fixed monthly payment.
        /// </summary>
        /// <param name="b">Loans to estimate repayment completion date for.</param>
        /// <param name="avgMonthlyPayment">Amount to pay each month</param>
        /// <param name="firstPayment">Date of the first payment</param>
        /// <returns>Last payment date for the loans</returns>
        public static DateTime EstimateRepaymentCompletionDate(LoanBundle b, decimal avgMonthlyPayment, DateTime firstPayment)
        {
            if (avgMonthlyPayment <= 0)
            {
                return(DateTime.MaxValue);
            }

            return(b.EstimateRepaymentCompletionDate(avgMonthlyPayment, firstPayment));
        }
Пример #2
0
        /// <summary>
        /// Given a total amount to pay in to all loans, displays a recommended amount that should be paid into each <see cref="Loan"/> based on the <see cref="IRepaymentStrategy"/> specified in the <paramref name="bundle"/>.
        /// </summary>
        /// <param name="bundle">Loans & RepaymentStrategy to use to calculate recommended payments.</param>
        /// <param name="totalFunds">Total amount to pay in to all loans for this payment period.</param>
        /// <returns></returns>
        public static void GetCurrentRecommendedPaymentAmount(LoanBundle bundle, decimal totalFunds)
        {
            var now             = DateTime.Now;
            var allocations     = bundle.GetRecommendedPaymentAmounts(totalFunds, now);
            var recommendations = bundle.Loans.ToDictionary(k => k, v => allocations[v.Id]);

            Console.WriteLine("Recommended Payments on " + now.ToString());
            DisplayRecommendedLoanPayment(recommendations);
        }