Exemplo n.º 1
0
        protected override StepResults Run()
        {
            if (this.autoRejectionOutput.FlowType == AutoDecisionFlowTypes.Unknown)
            {
                Log.Alert("Illegal flow type specified for {0}, auto decision is aborted.", OuterContextDescription);

                this.outcome = "'failure - illegal flow type'";
                return(StepResults.Failed);
            }             // if

            this.medalAgent.Execute();

            switch (this.autoRejectionOutput.FlowType)
            {
            case AutoDecisionFlowTypes.LogicalGlue:
                CreateLogicalOffer();
                break;

            case AutoDecisionFlowTypes.Internal:
                CreateUnlogicalOffer();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }             // switch

            if (OfferResult != null)
            {
                Log.Msg("Offer proposed for {0}:\n{1}.", OuterContextDescription, OfferResult);
                OfferResult.SaveToDb(DB);
            }             // if

            bool failure =
                (OfferResult == null) ||
                OfferResult.IsError ||
                OfferResult.IsMismatch ||
                !OfferResult.HasDecision ||
                (LoanSourceID <= 0);

            if (failure)
            {
                this.outcome = "'failure'";
                return(StepResults.Failed);
            }             // if

            this.outcome = "'success'";
            return(StepResults.Success);
        }         // Run
Exemplo n.º 2
0
        }         // Outcome

        protected override StepResults Run()
        {
            BackdoorInvestorID = null;

            ABackdoorSimpleDetails backdoorSimpleDetails = CreateBackdoor();

            if (backdoorSimpleDetails == null)
            {
                Log.Debug(
                    "Not using back door simple for {0}: back door code from customer email '{1}' " +
                    "ain't no matches any existing back door regex.",
                    OuterContextDescription,
                    this.customerEmail
                    );

                return(StepResults.NotApplied);
            }             // if

            Log.Debug("Using back door simple for {0} as: {1}.", OuterContextDescription, backdoorSimpleDetails);

            backdoorSimpleDetails.SetAdditionalCustomerData(
                this.cashRequestID,
                this.nlCashRequestID,
                this.smallLoanScenarioLimit,
                this.aspireToMinSetupFee,
                this.typeOfBusiness,
                this.customerOriginID,
                this.requestedLoan,
                this.offerValidHours
                );

            if (!backdoorSimpleDetails.SetResult(AutoDecisionResponse))
            {
                return(StepResults.NotApplied);
            }

            Medal       = backdoorSimpleDetails.Medal;
            OfferResult = backdoorSimpleDetails.OfferResult;

            Medal.SaveToDb(this.cashRequestID, this.nlCashRequestID, this.tag, DB);

            OfferResult.SaveToDb(DB);

            BackdoorLogicApplied = true;

            if (backdoorSimpleDetails.Decision != DecisionActions.Approve)
            {
                return(StepResults.Applied);
            }

            BackdoorSimpleApprove bsa = backdoorSimpleDetails as BackdoorSimpleApprove;

            if (bsa == null)               // Should never happen because of the "if" condition.
            {
                BackdoorLogicApplied = false;
                return(StepResults.NotApplied);
            }             // if

            BackdoorInvestorID = bsa.InvestorID;

            Medal.MedalClassification  = bsa.MedalClassification;
            Medal.OfferedLoanAmount    = bsa.ApprovedAmount;
            Medal.TotalScoreNormalized = 1m;
            Medal.AnnualTurnover       = bsa.ApprovedAmount;

            var glcd = new GetLoanCommissionDefaults(this.cashRequestID, bsa.ApprovedAmount);

            glcd.Execute();

            if (!glcd.IsBrokerCustomer)
            {
                return(StepResults.Applied);
            }

            AutoDecisionResponse.BrokerSetupFeePercent = glcd.Result.BrokerCommission;
            AutoDecisionResponse.SetupFee = glcd.Result.ManualSetupFee;

            return(StepResults.Applied);
        }         // Run