/// <summary> /// Processes the extra repayment. /// </summary> /// <param name="balance">The balance.</param> /// <param name="extraRepaymentAmount">The extra repayment amount.</param> /// <param name="currentDate">The current date.</param> /// <param name="result">The result.</param> private double ProcessExtraRepayment(double balance, double extraRepaymentAmount, DateTime currentDate, LoanCalculationOutput result) { if(balance >= extraRepaymentAmount) { // add extra repay transaction (if amount is more than 0) balance -= extraRepaymentAmount; LoanTransaction transaction = new LoanTransaction(currentDate, TransactionType.ExtraRepayment, extraRepaymentAmount, 0.0d, balance); result.Transactions.Add(transaction); } return (balance); }
/// <summary> /// Processes the minimum repayment. /// </summary> /// <param name="balance">The balance.</param> /// <param name="context">The context.</param> /// <param name="currentDate">The current date.</param> /// <param name="monthlyInterest">The monthly interest.</param> /// <param name="result">The result.</param> private double ProcessMinRepayment(double balance, double minRepaymentAmount, DateTime currentDate, double monthlyInterest, LoanCalculationOutput result) { // add min repay transaction if ((balance + monthlyInterest) <= minRepaymentAmount) { double finalRepayment = 0.0d; balance += monthlyInterest; finalRepayment = balance; balance -= finalRepayment; LoanTransaction transaction = new LoanTransaction(currentDate, TransactionType.FinalRepayment, finalRepayment, 0.0d, balance); result.Transactions.Add(transaction); } else { balance -= minRepaymentAmount; LoanTransaction transaction = new LoanTransaction(currentDate, TransactionType.MinimumRepayment, minRepaymentAmount, 0.0d, balance); result.Transactions.Add(transaction); } return (balance); }
/// <summary> /// Processes the end of month. /// </summary> /// <param name="currentDate">The current date.</param> /// <param name="monthlyInterest">The monthly interest.</param> /// <param name="balance">The balance.</param> /// <param name="result">The result.</param> private double ProcessEndOfMonth(DateTime currentDate, double monthlyInterest, double balance, LoanCalculationOutput result) { // add interest charged transaction balance += monthlyInterest; // calculate the total interest paid result.TotalInterestPaid += monthlyInterest; LoanTransaction transaction = new LoanTransaction(currentDate, TransactionType.InterestCharged, 0.0d, monthlyInterest, balance); result.Transactions.Add(transaction); return (balance); }