private static void CheckTakenLoanStatus(TakenLoan takenLoan) { if (takenLoan.Payments.All(loanPayment => loanPayment.Status == LoanPaymentStatus.Paid || loanPayment.Status == LoanPaymentStatus.PaidWithDelay)) { takenLoan.Status = TakenLoanStatus.Paid; } }
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 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 TakeLoan(LoanRequest loanRequest) { if (loanRequest.Status != LoanRequestStatus.ApprovedByAllApprovers) { return; } loanRequest.Status = LoanRequestStatus.Approved; this.mailService.SendMessage(EmailTemplateType.ApproveCreditRequest, loanRequest.Client, loanRequest); TakenLoan takenLoan = CreateTakenLoanForClient(loanRequest); Account account = loanRequest.Client.PrimaryAccount; account.Amount += takenLoan.Amount; this.AddLoanPayments(takenLoan); this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(loanRequest.Client); }
private void ReCalcualteTakenLoanFine(TakenLoan takenLoan, DateTime date) { takenLoan.Payments.ForEach(x => this.ReCalculatePayment(x, date, takenLoan.ProductLoan)); }
private BaseCreditPlanBusinessLogicEntity MapCreditPlanLogicEntityFromLoanProduct(TakenLoan loanProduct) { return(this.MapCreditPlanLogicEntityFromLoanProduct( loanProduct.MaturityInMonth, loanProduct.Amount, loanProduct.ProductLoan.Percentage, loanProduct.ProductLoan.Type)); }
public IEnumerable <decimal> GetMonthlyPayments(TakenLoan takenLoan) { return(this.GetMonthlyPayments(new Collection <TakenLoan> { takenLoan }).First().Value); }
private void ProceedTakenLoans(TakenLoan takenLoans, DateTime date, Client client) { takenLoans.Payments.ForEach(x => this.ProceedPayment(x, date, client)); }