Exemplo n.º 1
0
        }         // AddDecision

        public NLLongActionResult AddOffer(int userID, int customerID, NL_Offers offer, List <NL_OfferFees> fees = null)
        {
            AddOffer s = new AddOffer(offer, fees);

            s.Context.UserID     = userID;
            s.Context.CustomerID = customerID;
            var amd = ExecuteSync(out s, customerID, userID, offer, fees);

            return(new NLLongActionResult {
                MetaData = amd,
                Value = s.OfferID,
                Error = s.Error
            });
        }         // AddOffer
Exemplo n.º 2
0
		public void AddOffer() {
			GetLastOffer lastOfferstrategy = new GetLastOffer(374);
			lastOfferstrategy.Execute();
			NL_Offers lastOffer = lastOfferstrategy.Offer;
			long crID = 337;
			long decisionID = 23;

			ICashRequestRepository crRep = ObjectFactory.GetInstance<CashRequestRepository>();
			CashRequest	oldCashRequest = crRep.Get(crID);

			lastOffer.DecisionID = decisionID;
			lastOffer.LoanSourceID = oldCashRequest.LoanSource.ID;
			lastOffer.LoanTypeID = oldCashRequest.LoanType.Id;
			lastOffer.RepaymentIntervalTypeID = (int)RepaymentIntervalTypes.Month;
			lastOffer.StartTime = (DateTime)oldCashRequest.OfferStart;
			lastOffer.EndTime = (DateTime)oldCashRequest.OfferValidUntil;
			lastOffer.RepaymentCount = oldCashRequest.ApprovedRepaymentPeriod ?? 0;
			lastOffer.Amount = (decimal)oldCashRequest.ManagerApprovedSum;
			lastOffer.MonthlyInterestRate = oldCashRequest.InterestRate;
			lastOffer.CreatedTime = DateTime.UtcNow;
			lastOffer.BrokerSetupFeePercent = oldCashRequest.BrokerSetupFeePercent;
			lastOffer.Notes = "bbb";
			lastOffer.DiscountPlanID = oldCashRequest.DiscountPlan.Id;
			lastOffer.IsLoanTypeSelectionAllowed = oldCashRequest.IsLoanTypeSelectionAllowed == 1;
			lastOffer.SendEmailNotification = !oldCashRequest.EmailSendingBanned;
			lastOffer.IsRepaymentPeriodSelectionAllowed = oldCashRequest.IsCustomerRepaymentPeriodSelectionAllowed;
			lastOffer.IsAmountSelectionAllowed = true;

			// offer-fees
			NL_OfferFees setupFee = new NL_OfferFees() {
				LoanFeeTypeID = (int)NLFeeTypes.SetupFee,
				Percent = oldCashRequest.ManualSetupFeePercent,
				//OneTimePartPercent = 1, DistributedPartPercent = 0 // default
			};
			if (oldCashRequest.SpreadSetupFee != null && oldCashRequest.SpreadSetupFee == true) {
				setupFee.LoanFeeTypeID = (int)NLFeeTypes.ServicingFee;
				setupFee.OneTimePartPercent = 0;
				setupFee.DistributedPartPercent = 1;
			}
			List<NL_OfferFees> offerFees = new List<NL_OfferFees>() { setupFee };
			//this.m_oLog.Debug("NL: offer: {0}, offerFees: {1}" + "", lastOffer, offerFees);
			AddOffer offerStrategy = new AddOffer(lastOffer, offerFees);
			offerStrategy.Execute();
			Console.WriteLine(offerStrategy.OfferID);
			Console.WriteLine(offerStrategy.Error);
		}
Exemplo n.º 3
0
 public AddOffer(NL_Offers offer, IEnumerable <NL_OfferFees> fees = null)
 {
     this.offer = offer;
     this.fees  = (fees != null) ? fees.Where(f => f.Percent > 0) : null;
 }        //constructor
Exemplo n.º 4
0
        }         // RejectCustomer

        private bool ApproveCustomer(NL_Decisions newDecision)
        {
            LinkOfferToInvestor linkOfferToInvestor = new LinkOfferToInvestor(this.decisionToApply.Customer.ID, this.decisionToApply.CashRequest.ID, this.decisionModel.ForceInvestor, this.decisionModel.InvestorID, this.decisionModel.underwriterID);

            linkOfferToInvestor.Execute();

            Log.Info("ApproveCustomer Decision {0} for Customer {1} cr {2} OP {3} FoundInvestor {4}",
                     this.decisionToApply.CashRequest.UnderwriterDecision,
                     this.decisionToApply.Customer.ID,
                     this.decisionToApply.CashRequest.ID,
                     linkOfferToInvestor.IsForOpenPlatform,
                     linkOfferToInvestor.FoundInvestor);

            if (linkOfferToInvestor.IsForOpenPlatform && !linkOfferToInvestor.FoundInvestor)
            {
                PendingInvestor(newDecision);
                return(false);
            }

            this.decisionToApply.Customer.DateApproved   = this.now;
            this.decisionToApply.Customer.ApprovedReason = this.decisionModel.reason;

            this.decisionToApply.Customer.CreditSum                  = this.currentState.OfferedCreditLine;
            this.decisionToApply.Customer.ManagerApprovedSum         = this.currentState.OfferedCreditLine;
            this.decisionToApply.Customer.NumApproves                = 1 + this.currentState.NumOfPrevApprovals;
            this.decisionToApply.Customer.IsLoanTypeSelectionAllowed = this.currentState.IsLoanTypeSelectionAllowed;

            this.decisionToApply.CashRequest.ManagerApprovedSum = (int)this.currentState.OfferedCreditLine;

            if (!SaveDecision <ManuallyApprove>())
            {
                return(false);
            }

            bool bSendBrokerForceResetCustomerPassword =
                this.currentState.FilledByBroker &&
                (this.currentState.NumOfPrevApprovals == 0);

            bool bSendApprovedUser = !this.currentState.EmailSendingBanned;

            int validForHours = (int)(this.currentState.OfferValidUntil - this.currentState.OfferStart).TotalHours;

            if (bSendBrokerForceResetCustomerPassword && bSendApprovedUser)
            {
                FireToBackground(
                    new ApprovedUser(
                        this.decisionModel.customerID,
                        this.currentState.OfferedCreditLine,
                        validForHours,
                        this.currentState.NumOfPrevApprovals == 0
                        )
                {
                    SendToCustomer = false,
                },
                    e => Warning = "Failed to force reset customer password and send 'approved user' email: " + e.Message
                    );
            }
            else if (bSendApprovedUser)
            {
                FireToBackground(
                    new ApprovedUser(
                        this.decisionModel.customerID,
                        this.currentState.OfferedCreditLine,
                        validForHours,
                        this.currentState.NumOfPrevApprovals == 0
                        ),
                    e => Warning = "Failed to send 'approved user' email: " + e.Message
                    );
            }
            else if (bSendBrokerForceResetCustomerPassword)
            {
                FireToBackground(new BrokerForceResetCustomerPassword(this.decisionModel.customerID));
            }

            newDecision.DecisionNameID = (int)DecisionActions.Approve;

            AddDecision nlAddDecision = new AddDecision(newDecision, this.decisionToApply.CashRequest.ID, null);

            nlAddDecision.Context.CustomerID = this.decisionModel.customerID;
            nlAddDecision.Context.UserID     = this.decisionModel.underwriterID;

            try {
                try {
                    nlAddDecision.Execute();
                    Log.Debug("nl AddDecision {0}, Error: {1}", nlAddDecision.DecisionID, nlAddDecision.Error);

                    // ReSharper disable once CatchAllClause
                } catch (Exception ex) {
                    Log.Error("Failed to add NL_decision. Err: {0}", ex.Message);
                }

                NL_Offers nlOffer = new NL_Offers()
                {
                    DecisionID            = nlAddDecision.DecisionID,
                    CreatedTime           = this.currentState.CreationDate,
                    Amount                = this.currentState.OfferedCreditLine,
                    BrokerSetupFeePercent = this.currentState.BrokerSetupFeePercent,
                    //IsAmountSelectionAllowed = this.currentState.
                    SendEmailNotification = !this.currentState.EmailSendingBanned,
                    StartTime             = this.currentState.OfferStart,
                    EndTime = this.currentState.OfferValidUntil,
                    IsLoanTypeSelectionAllowed = this.currentState.IsLoanTypeSelectionAllowed == 1,
                    Notes = this.decisionToApply.CashRequest.UnderwriterComment + " old cr " + this.decisionToApply.CashRequest.ID,
                    MonthlyInterestRate               = this.currentState.InterestRate,
                    LoanSourceID                      = this.currentState.LoanSourceID,
                    DiscountPlanID                    = this.currentState.DiscountPlanID,
                    LoanTypeID                        = this.currentState.LoanTypeID,
                    RepaymentIntervalTypeID           = (int)RepaymentIntervalTypes.Month,
                    RepaymentCount                    = this.currentState.RepaymentPeriod,  // ApprovedRepaymentPeriod???
                    IsRepaymentPeriodSelectionAllowed = this.currentState.IsCustomerRepaymentPeriodSelectionAllowed
                };

                Log.Debug("Adding nl offer: {0}", nlOffer);

                NL_OfferFees setupFee = new NL_OfferFees()
                {
                    LoanFeeTypeID          = (int)NLFeeTypes.SetupFee,
                    Percent                = this.currentState.ManualSetupFeePercent,
                    OneTimePartPercent     = 1,
                    DistributedPartPercent = 0
                };

                if (this.currentState.SpreadSetupFee)
                {
                    setupFee.LoanFeeTypeID          = (int)NLFeeTypes.ServicingFee;
                    setupFee.OneTimePartPercent     = 0;
                    setupFee.DistributedPartPercent = 1;
                }
                NL_OfferFees[] ofeerFees = { setupFee };

                AddOffer sAddOffer = new AddOffer(nlOffer, ofeerFees);
                sAddOffer.Context.CustomerID = this.decisionToApply.Customer.ID;
                sAddOffer.Context.UserID     = this.decisionModel.underwriterID;

                try {
                    sAddOffer.Execute();
                    Log.Debug("nl offer added: {0}, Error: {1}", sAddOffer.OfferID, sAddOffer.Error);
                    // ReSharper disable once CatchAllClause
                } catch (Exception ex) {
                    Log.Error("Failed to AddOffer. Err: {0}", ex.Message);
                }

                // ReSharper disable once CatchAllClause
            } catch (Exception nlException) {
                Log.Error("Failed to run NL offer/decision Err: {0}", nlException.Message);
            }

            UpdateSalesForceOpportunity(OpportunityStage.s90, model => {
                model.ApprovedAmount  = (int)this.currentState.OfferedCreditLine;
                model.ExpectedEndDate = this.currentState.OfferValidUntil;
            });

            return(true);
        }        // ApproveCustomer