Ejemplo n.º 1
0
        }         // LoadMainStrategyExecutedBefore

        private int CapOffer(MedalResult medal)
        {
            Log.Info("Finalizing and capping offer");

            int offeredCreditLine = medal.RoundOfferedAmount();

            bool isHomeOwnerAccordingToLandRegistry = DB.ExecuteScalar <bool>(
                "GetIsCustomerHomeOwnerAccordingToLandRegistry",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CustomerId", this.customerID)
                );

            if (isHomeOwnerAccordingToLandRegistry)
            {
                Log.Info("Capped for home owner according to land registry");
                offeredCreditLine = Math.Min(offeredCreditLine, MaxCapHomeOwner);
            }
            else
            {
                Log.Info("Capped for not home owner");
                offeredCreditLine = Math.Min(offeredCreditLine, MaxCapNotHomeOwner);
            }             // if

            return(offeredCreditLine);
        }         // CapOffer
Ejemplo n.º 2
0
        public WriteDecisionDown(
            string outerContextDescription,
            int underwriterID,
            int customerID,
            long cashRequestID,
            long nlCashRequestID,
            int offerValidForHours,
            AutoDecisionResponse autoDecisionResponse,
            MedalResult medal,
            bool overrideApprovedRejected,
            int experianConsumerScore
            ) : base(
                outerContextDescription,
                underwriterID,
                cashRequestID,
                nlCashRequestID,
                offerValidForHours,
                autoDecisionResponse
                )
        {
            this.customerID = customerID;
            this.medal      = medal;
            this.overrideApprovedRejected = overrideApprovedRejected;
            this.experianConsumerScore    = experianConsumerScore;

            this.outcome          = "'not executed'";
            WriteDecisionOutput   = null;
            CashRequestWasWritten = false;
        }         // constructor
Ejemplo n.º 3
0
 public DispatchNotifications(
     string outerContextDescription,
     bool isSilentlyApproved,
     StrategiesMailer mailer,
     MedalResult medal,
     CustomerDetails customerDetails,
     AutoDecisionResponse autoDecisionResponse,
     OfferResult offerResult,
     Guid?approvalTrailUniqueID,
     string silentEmailRecipient,
     string silentEmailSenderName,
     string silentEmailSenderAddress
     ) : base(outerContextDescription)
 {
     this.isSilentlyApproved = isSilentlyApproved;
     this.mailer             = mailer;
     this.medal                    = medal;
     this.customerDetails          = customerDetails;
     this.autoDecisionResponse     = autoDecisionResponse;
     this.offerResult              = offerResult;
     this.approvalTrailUniqueID    = approvalTrailUniqueID;
     this.silentEmailRecipient     = silentEmailRecipient;
     this.silentEmailSenderName    = silentEmailSenderName;
     this.silentEmailSenderAddress = silentEmailSenderAddress;
 }         // constructor
Ejemplo n.º 4
0
        }         // SetAdditionalCustomerData

        protected ABackdoorSimpleDetails(
            int homeOwnerCap,
            int notHomeOwnerCap,
            int customerID,
            DecisionActions decision,
            int delay,
            bool ownsProperty,
            decimal requestedAmount,
            bool gradeMode = false
            )
        {
            this.customerID      = customerID;
            Decision             = decision;
            Delay                = delay;
            this.ownsProperty    = ownsProperty;
            this.homeOwnerCap    = homeOwnerCap;
            this.notHomeOwnerCap = notHomeOwnerCap;

            Medal       = null;
            OfferResult = null;

            int appAmount = (int)(requestedAmount / 1000m);

            ApprovedAmount = MedalResult.RoundOfferedAmount(gradeMode ? appAmount * 1000 : Cap(appAmount * 1000));
        }         // constructor
Ejemplo n.º 5
0
 public Approval(
     string outerContextDescription,
     bool avoidAutomaticDecision,
     bool enabled,
     int customerID,
     long cashRequestID,
     long nlCashRequestID,
     string tag,
     bool customerStatusIsEnabled,
     bool customerStatusIsWarning,
     bool autoRejectionEnabled,
     bool autoRerejectionEnabled,
     int proposedAmount,
     MedalResult medal,
     AutoRejectionOutput autoRejectionOutput,
     bool customerIsAlibaba
     ) : base(
         outerContextDescription,
         avoidAutomaticDecision,
         enabled,
         customerID,
         cashRequestID,
         nlCashRequestID,
         tag,
         customerStatusIsEnabled,
         customerStatusIsWarning,
         autoRejectionEnabled,
         autoRerejectionEnabled
         )
 {
     this.proposedAmount      = proposedAmount;
     this.medal               = medal;
     this.autoRejectionOutput = autoRejectionOutput;
     this.customerIsAlibaba   = customerIsAlibaba;
 }         // constructor
Ejemplo n.º 6
0
        protected virtual bool CalculateMedalAndOffer()
        {
            Grsp = null;

            var loader = new LoadOfferRanges(this.customerID, null, DateTime.UtcNow, DB, Log).Execute();

            Medal = new MedalResult(
                this.customerID,
                null,
                loader.Success ? null : "Failed to load grade range + sub-product."
                )
            {
                CalculationTime      = DateTime.UtcNow,
                MedalClassification  = EZBob.DatabaseLib.Model.Database.Medal.NoClassification,
                MedalType            = Strategies.MedalCalculations.MedalType.NoMedal,
                OfferedLoanAmount    = ApprovedAmount,
                AnnualTurnover       = ApprovedAmount,
                TotalScoreNormalized = 0,
            };

            if (loader.Success)
            {
                Grsp = loader.GradeRangeSubproduct;
            }

            OfferResult = new OfferResult {
                CustomerId          = this.customerID,
                CalculationTime     = DateTime.UtcNow,
                Amount              = ApprovedAmount,
                MedalClassification = EZBob.DatabaseLib.Model.Database.Medal.NoClassification,
                FlowType            = AutoDecisionFlowTypes.Internal,
                GradeID             = null,
                SubGradeID          = null,
                CashRequestID       = this.cashRequestID,
                NLCashRequestID     = this.nlCashRequestID,

                ScenarioName = "Back door - no offer",
                Period       = (Grsp != null) ? Grsp.Term(this.requestedLoan.RequestedTerm) : 15,
                LoanTypeId   = (Grsp != null) ? Grsp.LoanTypeID : 1,
                LoanSourceId = (Grsp != null) ? Grsp.LoanSourceID : 1,
                InterestRate = 0,
                SetupFee     = 0,
                Message      = (Grsp != null) ? "Failed to load grade range + sub-product." : null,
                IsError      = Grsp == null,
                IsMismatch   = false,
                HasDecision  = false,
            };

            return(loader.Success);
        }         // CalculateMedalAndOffer
Ejemplo n.º 7
0
 public ExternalNotifier(
     StrategiesMailer mailer,
     int customerId,
     MedalResult medal,
     CustomerDetails customerDetails,
     AutoDecisionResponse autoDecisionResponse,
     bool sendToCustomer,
     ASafeLog log
     )
 {
     this.mailer               = mailer;
     this.customerId           = customerId;
     this.medal                = medal;
     this.customerDetails      = customerDetails;
     this.autoDecisionResponse = autoDecisionResponse;
     this.sendToCustomer       = sendToCustomer;
     this.log = log.Safe();
 }         // constructor
Ejemplo n.º 8
0
        }         // SetTag

        public override void Execute()
        {
            Log.Debug("Executing for customer '{0}'...", this.customerID);

            LoadMainStrategyExecutedBefore();

            if (!this.mainStrategyExecutedBefore)
            {
                Log.Debug("Not executing: main strategy has never run before for customer '{0}'.", this.customerID);
                return;
            }             // if

            SafeReader sr = DB.GetFirst(
                "LoadLastCustomerCashRequest",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CustomerID", this.customerID)
                );

            if (sr.IsEmpty)
            {
                Log.Debug(
                    "Not running silent automation for customer {0}: there is no available cash request.",
                    this.customerID
                    );

                return;
            }             // if

            this.cashRequestID = sr["CashRequestID"];

            this.nlCashRequestID = sr["NLCashRequestID"];

            ForceNhibernateResync.ForCustomer(this.customerID);

            Log.Debug(
                "Executing silent reject for customer '{0}' using cash request 'o {1}/n {2}'...",
                this.customerID,
                this.cashRequestID,
                this.nlCashRequestID
                );

            LoadCompanyAndMonthlyPayment(DateTime.UtcNow);

            var rejectAgent = new Ezbob.Backend.Strategies.AutoDecisionAutomation.AutoDecisions.Reject.LogicalGlue.Agent(
                new AutoRejectionArguments(
                    this.customerID,
                    CompanyID,
                    this.cashRequestID,
                    this.nlCashRequestID,
                    Tag,
                    DateTime.UtcNow,
                    DB,
                    Log
                    )
                )
            {
                CompareTrailsQuietly = true,
            };

            rejectAgent.MakeAndVerifyDecision();

            MedalResult medal = CalculateMedal();

            int offeredCreditLine = CapOffer(medal);

            Log.Debug(
                "Executing silent approve for customer '{0}' using cash request '{1}', nlCashRequest '{2}'...",
                this.customerID,
                this.cashRequestID,
                this.nlCashRequestID
                );

            var approveAgent = new Ezbob.Backend.Strategies.AutoDecisionAutomation.AutoDecisions.Approval.LogicalGlue.Agent(
                new AutoApprovalArguments(
                    this.customerID,
                    this.cashRequestID,
                    this.nlCashRequestID,
                    offeredCreditLine,
                    (AutomationCalculator.Common.Medal)medal.MedalClassification,
                    (AutomationCalculator.Common.MedalType)medal.MedalType,
                    (AutomationCalculator.Common.TurnoverType?)medal.TurnoverType,
                    rejectAgent.Output.FlowType,
                    rejectAgent.Output.ErrorInLGData,
                    Tag,
                    DateTime.UtcNow,
                    DB,
                    Log
                    )
                )
            {
                CompareTrailsQuietly = true,
            }.Init();

            approveAgent.MakeAndVerifyDecision();

            if (this.caller == Callers.AddMarketplace)
            {
                bool isRejected = !rejectAgent.WasMismatch && rejectAgent.Trail.HasDecided;
                bool isApproved = !approveAgent.WasMismatch && (
                    (
                        (rejectAgent.Output.FlowType == AutoDecisionFlowTypes.LogicalGlue) &&
                        approveAgent.Trail.HasDecided
                    ) || (
                        (rejectAgent.Output.FlowType != AutoDecisionFlowTypes.LogicalGlue) &&
                        (approveAgent.Trail.RoundedAmount > 0)
                        )
                    );

                if (!isRejected && isApproved)
                {
                    ExecuteMain();
                }
                else
                {
                    Log.Debug(
                        "Not running auto decision for customer {0} using cash request 'o {3}/n {4}': " +
                        "no potential ({1} and {2}).",
                        this.customerID,
                        isRejected ? "rejected" : "not rejected",
                        isApproved ? "approved" : "not approved",
                        this.cashRequestID,
                        this.nlCashRequestID
                        );
                }         // if
            }             // if

            Log.Debug("Complete for customer '{0}'.", this.customerID);
        }         // Execute
Ejemplo n.º 9
0
        }         // PreventMainStrategy

        public SilentAutomation SetMedal(MedalResult medal)
        {
            this.medalToUse = medal;
            return(this);
        }         // SetMedal