Exemplo n.º 1
0
        /// <summary>
        /// Gets the loan source.
        /// </summary>
        /// <param name="loanKind">Kind of the loan.</param>
        /// <returns></returns>
        public LoanSource GetLoanSource(LoanKind loanKind)
        {
            using (var sqlConnection = GetOpenedSqlConnection()) {
                using (SqlCommand sqlCommand = new SqlCommand("GetLoanSource", sqlConnection)) {
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter("@LoanSourceID", SqlDbType.Int));
                    sqlCommand.Parameters["@LoanSourceID"].Value = (int)loanKind;

                    SqlDataReader reader          = sqlCommand.ExecuteReader();
                    LoanSource    customerDetails = CreateModel <LoanSource>(reader);

                    return(customerDetails);
                }
            }
        }
Exemplo n.º 2
0
        public JsonResult ChangeCreditLine(
            long id,
            int productID,
            int productTypeID,
            int productSubTypeID,
            int loanType,
            int loanSource,
            double amount,
            decimal interestRate,
            int repaymentPeriod,
            string offerStart,
            string offerValidUntil,
            bool allowSendingEmail,
            int discountPlan,
            decimal?brokerSetupFeePercent,
            decimal?manualSetupFeePercent,
            bool isCustomerRepaymentPeriodSelectionAllowed,
            int isLoanTypeSelectionAllowed,
            bool spreadSetupFee,
            bool feesManuallyUpdated
            )
        {
            CashRequest cr = this.cashRequestsRepository.Get(id);

            if (cr.Id <= 0)
            {
                log.Error("No cash request found");
                return(Json(true));
            }             // if

            new Transactional(() => {
                LoanType loanT    = this.loanTypes.Get(loanType);
                LoanSource source = this.loanSources.Get(loanSource);

                cr.LoanType = loanT;

                int step = CurrentValues.Instance.GetCashSliderStep;
                int sum  = (int)Math.Round(amount / step, MidpointRounding.AwayFromZero) * step;
                cr.ManagerApprovedSum      = sum;
                cr.LoanSource              = source;
                cr.InterestRate            = interestRate;
                cr.RepaymentPeriod         = repaymentPeriod;
                cr.ApprovedRepaymentPeriod = cr.RepaymentPeriod;
                cr.OfferStart              = FormattingUtils.ParseDateWithCurrentTime(offerStart);
                cr.OfferValidUntil         = FormattingUtils.ParseDateWithCurrentTime(offerValidUntil);

                cr.BrokerSetupFeePercent = brokerSetupFeePercent;
                cr.ManualSetupFeePercent = manualSetupFeePercent;
                cr.UwUpdatedFees         = feesManuallyUpdated;

                cr.EmailSendingBanned = !allowSendingEmail;
                cr.LoanTemplate       = null;

                cr.IsLoanTypeSelectionAllowed = isLoanTypeSelectionAllowed;
                cr.IsCustomerRepaymentPeriodSelectionAllowed = isCustomerRepaymentPeriodSelectionAllowed;

                cr.DiscountPlan      = this.discounts.Get(discountPlan);
                cr.SpreadSetupFee    = spreadSetupFee;
                cr.ProductSubTypeID  = productSubTypeID;
                Customer c           = cr.Customer;
                c.OfferStart         = cr.OfferStart;
                c.OfferValidUntil    = cr.OfferValidUntil;
                c.ManagerApprovedSum = sum;

                this.cashRequestsRepository.SaveOrUpdate(cr);
                this.customerRepository.SaveOrUpdate(c);
            }).Execute();

            var decision = this.serviceClient.Instance.AddDecision(this.context.UserId, cr.Customer.Id, new NL_Decisions {
                UserID         = this.context.UserId,
                DecisionTime   = DateTime.UtcNow,
                DecisionNameID = (int)DecisionActions.Waiting,
                Notes          = "Waiting; oldCashRequest: " + cr.Id
            }, cr.Id, null);

            // TODO: save feesManuallyUpdated in new loan structure (EZ-4829)

            log.Info("NL decisionID: {0}, oldCashRequestID: {1}, Error: {2}", decision.Value, cr.Id, decision.Error);

            NL_OfferFees offerFee = new NL_OfferFees()
            {
                LoanFeeTypeID          = (int)NLFeeTypes.SetupFee,
                Percent                = manualSetupFeePercent ?? 0,
                OneTimePartPercent     = 1,
                DistributedPartPercent = 0
            };

            if (cr.SpreadSetupFee != null && cr.SpreadSetupFee == true)
            {
                offerFee.LoanFeeTypeID          = (int)NLFeeTypes.ServicingFee;
                offerFee.OneTimePartPercent     = 0;
                offerFee.DistributedPartPercent = 1;
            }
            NL_OfferFees[] ofeerFees = { offerFee };

            var offer = this.serviceClient.Instance.AddOffer(this.context.UserId, cr.Customer.Id, new NL_Offers {
                DecisionID = decision.Value,
                LoanTypeID = loanType,
                RepaymentIntervalTypeID = (int)DbConstants.RepaymentIntervalTypes.Month,
                LoanSourceID            = loanSource,
                StartTime             = FormattingUtils.ParseDateWithCurrentTime(offerStart),
                EndTime               = FormattingUtils.ParseDateWithCurrentTime(offerValidUntil),
                RepaymentCount        = repaymentPeriod,
                Amount                = (decimal)amount,
                MonthlyInterestRate   = interestRate,
                CreatedTime           = DateTime.UtcNow,
                BrokerSetupFeePercent = brokerSetupFeePercent ?? 0,
                Notes                             = "offer from ChangeCreditLine, ApplicationInfoController",
                DiscountPlanID                    = discountPlan,
                IsLoanTypeSelectionAllowed        = isLoanTypeSelectionAllowed == 1,
                IsRepaymentPeriodSelectionAllowed = isCustomerRepaymentPeriodSelectionAllowed,
                SendEmailNotification             = allowSendingEmail,
                ProductSubTypeID                  = productSubTypeID
                                                    // SetupFeeAddedToLoan = 0 // default 0 TODO EZ-3515
                                                    // InterestOnlyRepaymentCount =
                                                    //IsAmountSelectionAllowed = 1 default 1 always allowed
            }, ofeerFees);

            log.Info("NL--- offerID: {0}, decisionID: {1} oldCashRequestID: {2}, Error: {3}", offer.Value, decision.Value, cr.Id, offer.Error);


            log.Debug("update offer for customer {0} all the offer is changed", cr.Customer.Id);

            return(Json(true));
        }         // ChangeCreditLine