public bool CreateLoanProduct(LoanProduct loanProduct)
 {
     loanProduct.Status = LoanProductStatus.Draft;
     this.gangsterBankUnitOfWork.LoanProductsRepository.CreateOrUpdate(loanProduct);
     //this.gangsterBankUnitOfWork.LoanProductsRequirmentsRepository.CreateOrUpdate(loanProduct.Requirements);
     return true;
 }
 public void ChangeLoanProductStatus(LoanProduct loanProduct, LoanProductStatus newStatus)
 {
     Contract.Requires<ArgumentNullException>(loanProduct.IsNotNull());
     this.VerifyLoanProductCreationWorkflow(loanProduct, newStatus);
     loanProduct.Status = newStatus;
     this.gangsterBankUnitOfWork.LoanProductsRepository.CreateOrUpdate(loanProduct);
 }
 private void ReCalculatePayment(LoanPayment payment, DateTime date, LoanProduct product)
 {
     if (payment.Date < date)
     {
         payment.Fine += product.FineDayPercentage * payment.Amount;
     }
 }
        public void CreateLoanRequest(Client client, LoanProduct loanProduct, decimal amount, int months)
        {
            Contract.Requires<ArgumentNullException>(client.IsNotNull());
            Contract.Requires<ArgumentNullException>(loanProduct.IsNotNull());

            VerifyWorkFlow(client, loanProduct);
            LoanRequest loanRequest = LoanRequest.Create(client, loanProduct, amount, months);
            this.TryApproveAndTakeLoanOnCreation(loanRequest);

            this.gangsterBankUnitOfWork.LoanRequestsRepository.CreateOrUpdate(loanRequest);
        }
Beispiel #5
0
 public void Update(LoanProduct product)
 {
     this.IsDeleted        = product.IsDeleted;
     this.MinAmount        = product.MinAmount;
     this.Percentage       = product.Percentage;
     this.MinPeriodInMonth = product.MinPeriodInMonth;
     this.MaxPeriodInMonth = product.MaxPeriodInMonth;
     this.Name             = product.Name;
     this.Description      = product.Description;
     this.Type             = product.Type;
     this.Status           = product.Status;
     this.Requirements.Update(product.Requirements);
     this.FineDayPercentage = product.FineDayPercentage;
     this.AdvancedRepaymentFirstPossibleMonth = product.AdvancedRepaymentFirstPossibleMonth;
     this.AdvancedRepaymentFinePercentage     = product.AdvancedRepaymentFinePercentage;
 }
Beispiel #6
0
        public static LoanRequest Create(
            Client client,
            LoanProduct loanProduct,
            decimal amount,
            int monthes)
        {
            Contract.Requires <ArgumentNullException>(client.IsNotNull());
            Contract.Requires <ArgumentNullException>(loanProduct.IsNotNull());
            Contract.Requires <ArgumentOutOfRangeException>(amount > 0);
            Contract.Requires <ArgumentOutOfRangeException>(monthes > 0);

            var loanRequest = new LoanRequest
            {
                Client      = client,
                LoanProduct = loanProduct,
                Status      = LoanRequestStatus.Requested,
                Amount      = amount,
                Months      = monthes,
                ApprovedBy  = new List <IdentityRoleEntity>()
            };

            return(loanRequest);
        }
Beispiel #7
0
 public void Update(LoanProduct product)
 {
     this.IsDeleted = product.IsDeleted;
     this.MinAmount = product.MinAmount;
     this.Percentage = product.Percentage;
     this.MinPeriodInMonth = product.MinPeriodInMonth;
     this.MaxPeriodInMonth = product.MaxPeriodInMonth;
     this.Name = product.Name;
     this.Description = product.Description;
     this.Type = product.Type;
     this.Status = product.Status;
     this.Requirements.Update(product.Requirements);
     this.FineDayPercentage = product.FineDayPercentage;
     this.AdvancedRepaymentFirstPossibleMonth = product.AdvancedRepaymentFirstPossibleMonth;
     this.AdvancedRepaymentFinePercentage = product.AdvancedRepaymentFinePercentage;
 }
Beispiel #8
0
 public LoanProduct(LoanProduct product)
 {
     Update(product);
 }
Beispiel #9
0
 public LoanProduct(LoanProduct product)
 {
     Update(product);
 }
        public bool CanHaveStatus(LoanProduct loanProduct, LoanProductStatus status)
        {
            Contract.Requires<ArgumentNullException>(loanProduct != null);
            if (!this.prerequisiteStatuses.ContainsKey(status))
            {
                throw new ArgumentOutOfRangeException("status");
            }

            return this.prerequisiteStatuses[status].Contains(loanProduct.Status);
        }
Beispiel #11
0
 public void Save(LoanProduct loanProduct)
 {
     Contract.Requires<ArgumentNullException>(loanProduct.IsNotNull());
     this.gangsterBankUnitOfWork.LoanProductsRepository.CreateOrUpdate(loanProduct);
 }
 private static void VerifyLoanProductIsNotActive(LoanProduct loanProduct)
 {
     if (loanProduct.Status != LoanProductStatus.Active)
     {
         throw new WorkflowException("Loan product is not active");
     }
 }
Beispiel #13
0
        private void VerifyLoanProductCreationWorkflow(LoanProduct loanProduct, LoanProductStatus newStatus)
        {
            if (!this.LoanProductHasPrerequisiteStatus(loanProduct, newStatus))
            {
                throw new WorkflowException("Loan product doesn't have prerequisite status");
            }

            if (!this.UserIsAllowedToChangeStatus(newStatus))
            {
                throw new WorkflowException("User is not allowed to change the status");
            }
        }
Beispiel #14
0
 private bool LoanProductHasPrerequisiteStatus(LoanProduct loanProduct, LoanProductStatus newStatus)
 {
     return this.loanProductCreationWorkflowConfiguration.CanHaveStatus(loanProduct, newStatus);
 }
 private LoanProductViewModel GetModelFromLoanProduct(LoanProduct loanProduct)
 {
     var model = new LoanProductViewModel
     {
         MinAmount = loanProduct.MinAmount,
         MaxAmount = loanProduct.MaxAmount,
         Percentage = loanProduct.Percentage,
         MinPeriodInMonth = loanProduct.MinPeriodInMonth,
         MaxPeriodInMonth = loanProduct.MaxPeriodInMonth,
         Name = loanProduct.Name,
         Description = loanProduct.Description,
         Type = loanProduct.Type,
         FineDayPercentage = loanProduct.FineDayPercentage,
         AdvancedRepaymentFirstPossibleMonth =
             loanProduct.AdvancedRepaymentFirstPossibleMonth,
         AdvancedRepaymentFinePercentage =
             loanProduct.AdvancedRepaymentFinePercentage,
         LoanProductId = loanProduct.Id,
         Requirements =
             new LoanProductRequirementsViewModel
             {
                 LoanProductRequirementsId = loanProduct.Requirements.Id,
                 MinWorkOnLastJobInMonths
                     =
                     loanProduct
                     .Requirements
                     .MinWorkOnLastJobInMonths,
                 MinSalary =
                     loanProduct
                     .Requirements
                     .MinSalary,
                 NeedEarningsRecord =
                     loanProduct
                     .Requirements
                     .NeedEarningsRecord,
                 NeedGuarantors =
                     loanProduct
                     .Requirements
                     .NeedGuarantors,
                 GuarantorsCount =
                     loanProduct
                     .Requirements
                     .GuarantorsCount,
                 Approvers =
                     loanProduct
                     .Requirements
                     .Approvers.Select(
                         identityRole =>
                         (Role)
                         Enum.Parse(
                             typeof(Role),
                             identityRole
                             .Name))
             }
     };
     return model;
 }
 private LoanProduct MapLoanProduct(LoanProductViewModel model, LoanProduct loanProduct)
 {
     loanProduct.Id = model.LoanProductId;
     loanProduct.MinAmount = model.MinAmount;
     loanProduct.MaxAmount = model.MaxAmount;
     loanProduct.Percentage = model.Percentage;
     loanProduct.MinPeriodInMonth = model.MinPeriodInMonth;
     loanProduct.MaxPeriodInMonth = model.MaxPeriodInMonth;
     loanProduct.Name = model.Name;
     loanProduct.Description = model.Description;
     loanProduct.Type = model.Type;
     loanProduct.Status = LoanProductStatus.Draft;
     loanProduct.FineDayPercentage = model.FineDayPercentage;
     loanProduct.AdvancedRepaymentFirstPossibleMonth = model.AdvancedRepaymentFirstPossibleMonth;
     loanProduct.AdvancedRepaymentFinePercentage = model.AdvancedRepaymentFinePercentage;
     loanProduct.Requirements.Id = model.Requirements.LoanProductRequirementsId;
     loanProduct.Requirements.MinWorkOnLastJobInMonths = model.Requirements.MinWorkOnLastJobInMonths;
     loanProduct.Requirements.MinSalary = model.Requirements.MinSalary;
     loanProduct.Requirements.NeedEarningsRecord = model.Requirements.NeedEarningsRecord;
     loanProduct.Requirements.NeedGuarantors = model.Requirements.NeedGuarantors;
     loanProduct.Requirements.GuarantorsCount = model.Requirements.GuarantorsCount;
     loanProduct.Requirements.Approvers =
         this.userService.GetRoles()
             .Where(x => model.Requirements.Approvers.Select(approver => approver.ToString()).Contains(x.Name))
             .ToList();
     return loanProduct;
 }
 private static void VerifyWorkFlow(Client client, LoanProduct loanProduct)
 {
     VerifyClientIsConfirmed(client);
     VerifyLoanProductIsNotActive(loanProduct);
 }