private static void CheckTakenLoanStatus(TakenLoan takenLoan)
 {
     if (takenLoan.Payments.All(loanPayment => loanPayment.Status == LoanPaymentStatus.Paid || loanPayment.Status == LoanPaymentStatus.PaidWithDelay))
     {
         takenLoan.Status = TakenLoanStatus.Paid;
     }
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
 }
Beispiel #7
0
 private BaseCreditPlanBusinessLogicEntity MapCreditPlanLogicEntityFromLoanProduct(TakenLoan loanProduct)
 {
     return(this.MapCreditPlanLogicEntityFromLoanProduct(
                loanProduct.MaturityInMonth,
                loanProduct.Amount,
                loanProduct.ProductLoan.Percentage,
                loanProduct.ProductLoan.Type));
 }
Beispiel #8
0
 public IEnumerable <decimal> GetMonthlyPayments(TakenLoan takenLoan)
 {
     return(this.GetMonthlyPayments(new Collection <TakenLoan> {
         takenLoan
     }).First().Value);
 }
Beispiel #9
0
 private void ProceedTakenLoans(TakenLoan takenLoans, DateTime date, Client client)
 {
     takenLoans.Payments.ForEach(x => this.ProceedPayment(x, date, client));
 }