Beispiel #1
0
        }         // CreateCosmeOffers

        private void CreateOfferForNonStandardSource(
            LoanSourceName loanSource,
            string sourceName,
            decimal interestRate,
            decimal collectionRate,
            decimal preferableInterestRate
            )
        {
            decimal air;
            decimal apr;

            decimal setupFee = GetSetupFeeForNonStandardLoan(interestRate, collectionRate, out air, out apr);

            bool isPreferable = interestRate == preferableInterestRate;

            var model = new PricingSourceModel {
                LoanSource   = loanSource,
                Source       = sourceName,
                InterestRate = interestRate,
                SetupFee     = setupFee,
                AIR          = air,
                APR          = apr,
                IsPreferable = isPreferable
            };

            Model.PricingSourceModels.Add(model);
        }         // CreateOfferForNonStandardSource
Beispiel #2
0
        public OfferCalculator Calculate()
        {
            var calculatorModel = InitCalcualtorModel();

            if (calculatorModel == null)
            {
                return(this);
            }

            var calculator = new PricingModelCalculator(this.customerID, calculatorModel)
            {
                ThrowExceptionOnError = false,
                CalculateApr          = false,
                TargetLoanSource      = (LoanSourceName)this.loanSourceID
            };

            calculator.Execute();

            if (!string.IsNullOrWhiteSpace(calculator.Error))
            {
                this.log.Warn("Calculator error: {0}", calculator.Error);
                return(this);
            }             // if

            PricingSourceModel calculatorOutput = (calculatorModel.PricingSourceModels == null)
                                ? null
                                : calculatorModel.PricingSourceModels.FirstOrDefault(
                r => r.IsPreferable && ((int)r.LoanSource == this.loanSourceID)
                );

            if (calculatorOutput == null)
            {
                this.log.Warn("Calculator output not found for loan source '{0}'.", this.loanSourceID);
                return(this);
            }             // if

            InterestRate = calculatorOutput.InterestRate;
            SetupFee     = calculatorOutput.SetupFee;

            Success = true;

            if ((this.minInterestRate <= InterestRate) && (InterestRate <= this.maxInterestRate))
            {
                return(this);
            }

            if ((this.minSetupFee == this.maxSetupFee) || !this.aspireToMinSetupFee)
            {
                InterestRate = this.minInterestRate;
            }
            else
            {
                InterestRate = this.maxInterestRate;
            }

            return(this);
        }         // Calculate
Beispiel #3
0
        }         // DisplayFormulaTerm

        private void CompareResults()
        {
            PricingSourceModel primary = Model.PricingSourceModels
                                         .FirstOrDefault(m => m.LoanSource == LoanSourceName.Standard && m.IsPreferable);

            PricingSourceModel verification = VerificationModel.PricingSourceModels
                                              .FirstOrDefault(m => m.LoanSource == LoanSourceName.Standard && m.IsPreferable);

            if ((primary == null) && (verification == null))
            {
                Log.Msg("Match in offer calculation: both primary & verification flows did not produce any model.");
                return;
            }             // if

            if ((primary != null) && (verification == null))
            {
                Log.Warn("Mismatch in offer calculation: primary flow has produced an output while verification has not.");
                Log.Debug("Primary output: interest rate = {0}.", primary.InterestRate.ToString("P3"));
                return;
            }             // if

            if ((primary == null))
            {
                Log.Warn("Mismatch in offer calculation: verification flow has produced an output while primary has not.");
                Log.Debug("Verification output: interest rate = {0}.", verification.InterestRate.ToString("P3"));
                return;
            }             // if

            if (Math.Abs(primary.InterestRate - verification.InterestRate) < 0.001M)
            {
                Log.Msg(
                    "Match in offer calculation: both primary & verification flows produced interest rate {0}.",
                    primary.InterestRate.ToString("P3")
                    );
            }
            else
            {
                Log.Warn(
                    "Mismatch in offer calculation: " +
                    "primary flow has produced interest rate {0}, " +
                    "verification flow produced interest rate {1}.",
                    primary.InterestRate.ToString("P3"),
                    verification.InterestRate.ToString("P3")
                    );
            }     // if
        }         // CompareResults