Esempio n. 1
0
        public override MedalInputModel GetInputParameters(int customerId, DateTime calculationDate)
        {
            base.GetInputParameters(customerId, calculationDate);

            TurnoverCalculator.ExecuteOnline();

            TurnoverCalculator.Model.PositiveFeedbacks = LoadFeedbacks(customerId);

            return(TurnoverCalculator.Model);
        }         // GetInputParameters
Esempio n. 2
0
        public virtual MedalInputModel GetInputParameters(int customerId, DateTime calculationDate)
        {
            TurnoverCalculator = new TurnoverCalculator(customerId, calculationDate, this.DB, this.Log);
            TurnoverCalculator.Execute();

            var model  = TurnoverCalculator.Model;
            var dbData = TurnoverCalculator.Model.MedalInputModelDb;

            model.BusinessScore = dbData.BusinessScore;

            model.BusinessSeniority = dbData.IncorporationDate.HasValue
                                ? calculationDate.Year - dbData.IncorporationDate.Value.Year
                                : 1;

            if (dbData.IncorporationDate.HasValue && dbData.IncorporationDate.Value > calculationDate.AddYears(-model.BusinessSeniority))
            {
                model.BusinessSeniority--;
            }

            model.ConsumerScore            = dbData.ConsumerScore;
            model.EzbobSeniority           = (decimal)(calculationDate - dbData.RegistrationDate).TotalDays / (365.0M / 12.0M);
            model.FirstRepaymentDatePassed = dbData.FirstRepaymentDate.HasValue && dbData.FirstRepaymentDate.Value < calculationDate;
            model.NumOfEarlyPayments       = dbData.NumOfEarlyPayments;
            model.NumOfLatePayments        = dbData.NumOfLatePayments;
            model.NumOfOnTimeLoans         = dbData.NumOfOnTimeLoans;

            model.MaritalStatus = (string.IsNullOrEmpty(dbData.MaritalStatus))
                                ? MaritalStatus.Other
                                : (MaritalStatus)Enum.Parse(typeof(MaritalStatus), dbData.MaritalStatus);

            model.NetWorth = dbData.ZooplaValue == 0
                                ? 0
                                : (dbData.ZooplaValue - dbData.Mortages) / (decimal)dbData.ZooplaValue;

            model.CapOfferByCustomerScoresTable = new CapOfferByCustomerScoreMatrix(customerId, this.DB);
            model.CapOfferByCustomerScoresTable.Load();

            return(model);
        }         // GetInputParameters
Esempio n. 3
0
        }         // constructor

        /// <summary>
        ///     Determines which medal to calculate and calculates it.
        ///     Which medal type to choose logic:
        ///     https://drive.google.com/open?id=0B1Io_qu9i44SVzVqV19nbnMxRW8&amp;authuser=0
        /// </summary>
        /// <param name="customerId">Customer ID.</param>
        /// <param name="calculationDate">
        ///     Optional. Leave empty to calculate based on current data
        ///     or specify date to calculate medal based on data available on that date.
        /// </param>
        /// <returns>Calculated medal model.</returns>
        public MedalOutputModel GetMedal(int customerId, DateTime calculationDate)
        {
            var turnoverCalc = new TurnoverCalculator(customerId, calculationDate, DB, Log);

            string errorMsg;
            var    type = turnoverCalc.GetMedalType(out errorMsg);

            if (!string.IsNullOrWhiteSpace(errorMsg))
            {
                return(new MedalOutputModel {
                    MedalType = MedalType.NoMedal,
                    Medal = Medal.NoClassification,
                    TurnoverType = null,
                    Error = errorMsg,
                    CustomerId = customerId,
                });
            }             // if

            IMedalCalulator medalCalulator;

            switch (type)
            {
            case MedalType.Limited:
                medalCalulator = new OfflineLImitedMedalCalculator(this.DB, this.Log);
                break;

            case MedalType.NonLimited:
                medalCalulator = new NonLimitedMedalCalculator(this.DB, this.Log);
                break;

            case MedalType.OnlineLimited:
                medalCalulator = new OnlineLImitedMedalCalculator(this.DB, this.Log);
                break;

            case MedalType.SoleTrader:
                medalCalulator = new SoleTraderMedalCalculator(this.DB, this.Log);
                break;

            case MedalType.OnlineNonLimitedNoBusinessScore:
                medalCalulator = new OnlineNonLimitedNoBusinessScoreMedalCalculator(this.DB, this.Log);
                break;

            case MedalType.OnlineNonLimitedWithBusinessScore:
                medalCalulator = new OnlineNonLimitedWithBusinessScoreMedalCalculator(this.DB, this.Log);
                break;

            default:
                return(new MedalOutputModel {
                    MedalType = type,
                    Medal = Medal.NoClassification,
                    TurnoverType = null,
                    Error = "None of the medals match the criteria for medal calculation",
                    CustomerId = customerId
                });
            }             // switch

            MedalInputModel data = medalCalulator.GetInputParameters(customerId, calculationDate);

            MedalOutputModel medal = medalCalulator.CalculateMedal(data);

            SetOfferedAmount(
                medal,
                turnoverCalc.MinApprovalAmount
                );

            return(medal);
        }         // GetMedal