private BaseCreditPlanBusinessLogicEntity MapCreditPlanLogicEntityFromLoanProduct(TakenLoan loanProduct)
 {
     return this.MapCreditPlanLogicEntityFromLoanProduct(
         loanProduct.MaturityInMonth,
         loanProduct.Amount,
         loanProduct.ProductLoan.Percentage,
         loanProduct.ProductLoan.Type);
 }
 public ClientCreditModel(TakenLoan takenLoan)
 {
     Contract.Requires<NullReferenceException>(takenLoan.IsNotNull());
     this.CreditPlanName = takenLoan.ProductLoan.Name;
     this.ExpirationDate = takenLoan.TakeDate.AddMonths(takenLoan.MaturityInMonth);
     if (takenLoan.Payments.Any())
     {
         var nextPayment = takenLoan.Payments.OrderBy(x => x.Date).First(x => x.Date > DateTime.Today);
         this.NextPaymentDate = nextPayment.Date;
         this.NextPaymentAmout = nextPayment.Amount.ToGBString();
     }
     this.Description = takenLoan.ProductLoan.Description;
 }
 private static void CheckTakenLoanStatus(TakenLoan takenLoan)
 {
     if (takenLoan.Payments.All(loanPayment => loanPayment.Status == LoanPaymentStatus.Paid || loanPayment.Status == LoanPaymentStatus.PaidWithDelay))
     {
         takenLoan.Status = TakenLoanStatus.Paid;
     }
 }
 private void AddLoanPayments(TakenLoan takenLoan)
 {
     var payments = creditManager.GetMonthlyPayments(takenLoan);
     var date = DateTime.Now.Date.AddMonths(1);
     foreach (var payment in payments)
     {
         if (payment != 0)
         {
             takenLoan.Payments.Add(this.CreatePayment(payment, date));
         }
         date = date.AddMonths(1);
     }
 }
 private static TakenLoan CreateTakenLoanForClient(LoanRequest loanRequest)
 {
     var takenLoan = new TakenLoan
                         {
                             Amount = loanRequest.Amount,
                             MaturityInMonth = loanRequest.Months,
                             ProductLoan = loanRequest.LoanProduct,
                             TakeDate = DateTime.UtcNow,
                             Payments = new Collection<LoanPayment>(),
                             Status = TakenLoanStatus.Active
                         };
     loanRequest.Client.TakenLoans.Add(takenLoan);
     return takenLoan;
 }
 private void ProceedTakenLoans(TakenLoan takenLoans, DateTime date, Client client)
 {
     takenLoans.Payments.ForEach(x => this.ProceedPayment(x, date, client));
 }
 private void ReCalcualteTakenLoanFine(TakenLoan takenLoan, DateTime date)
 {
     takenLoan.Payments.ForEach(x => this.ReCalculatePayment(x, date, takenLoan.ProductLoan));
 }
 public IEnumerable<decimal> GetMonthlyPayments(TakenLoan takenLoan)
 {
     return this.GetMonthlyPayments(new Collection<TakenLoan> { takenLoan }).First().Value;
 }