Example #1
0
 /// <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);
 }
Example #2
0
 /// <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);
 }
Example #3
0
 /// <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);
 }
Example #4
0
 /// <summary>
 /// Builds the sign text for a tower level.
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="currentLevel">Current level.</param>
 /// <param name="year">Year.</param>
 /// <param name="month">Month.</param>
 /// <param name="groupedTransactions">Grouped transactions.</param>
 /// <param name="lastTransaction">Last transaction.</param>
 /// <param name="level">Level.</param>
 private void BuildSignTextForTowerLevel(LoanContext context, int currentLevel, int year, int month, IEnumerable<LoanTransaction> groupedTransactions, LoanTransaction lastTransaction, GameObject level)
 {
     DateTime timePoint = new DateTime (year, month, 1);
     string date = timePoint.ToString ("MMM yyyy");
     string balance = lastTransaction.Balance.ToString ("c0");
     WoodenSignController signController = level.transform.FindChild (Constants.CHILD_WOODEN_SIGN).GetComponent<WoodenSignController> ();
     signController.SetMonthBalanceText (string.Format ("{0}\n{1}", date, balance));
     string transactions = string.Empty;
     foreach (LoanTransaction tx in groupedTransactions) {
         transactions += ConvertTransactionType (tx.Type);
         transactions += tx.Debit > 0 ? " -" : " +";
         transactions += tx.Debit > 0 ? tx.Debit.ToString ("c0") : tx.Credit.ToString ("c0");
         transactions += "\n";
     }
     signController.SetTransactionsText (transactions);
     if (context.TargetEndDate.Year == year && context.TargetEndDate.Month == month) {
         signController.ChangMaterial (RedWoodenSignMaterial);
     } else {
         signController.ResetMaterial();
     }
 }