Exemple #1
0
        public void GetCompanyRating_ExtendedCompany_Returns_Rating()
        {
            // Arange
            Fixture         fixture = new Fixture();
            ExtendedCompany company = this.CreateExtendedCompany(fixture);

            int expectedSummaryRating = 9;

            // Act
            var actual = this.scoreService.GetCompanyRating(company);

            // Assert
            this.AssertBaseCompanyRaping(actual, company, expectedSummaryRating);
            AssertRatingEntity(actual.Equity, ExpectedEquityScore, ExpectedEquityDescription, "2", $"Egenkapital: {company.Equity}");
            AssertRatingEntity(actual.Result, ExpectedResultScore, ExpectedResultDescription, "1", $"Resultat: {company.ProfitLoss}");
        }
        public Rating GetCompanyRating(Company company)
        {
            ExtendedCompany extendedCompany         = company as ExtendedCompany;
            bool            isAnnualReportAvailable = company.AnnualReportAvailable;

            decimal ageScore       = this.scoringNumbersService.ScoreAge(company.DateStarted);
            decimal employeesScore = this.scoringNumbersService.ScoreEmployees(company.EmployeesNumberForDataModel);
            decimal typeScore      = this.scoringNumbersService.ScoreType(company.Type);
            decimal sitautionScore = this.scoringNumbersService.ScoreSituation(company);

            decimal equityScore = 0;

            if (isAnnualReportAvailable && extendedCompany != null)
            {
                equityScore = this.scoringNumbersService.ScoreEquity(extendedCompany.Equity);
            }

            decimal resultScore = 0;

            if (isAnnualReportAvailable && extendedCompany != null)
            {
                resultScore = this.scoringNumbersService.ScoreResult(extendedCompany.ProfitLoss);
            }

            decimal totalScore = ageScore + employeesScore + typeScore + sitautionScore + equityScore + resultScore;

            int summaryRating = CalculateSummaryRating(totalScore);

            Rating rating = new Rating()
            {
                RegistrationNumber = company.VAT,
                SummaryRating      = summaryRating,
                Age = new RatingEntity()
                {
                    Value        = ageScore,
                    Explaination = this.scoringDescriptionService.DescriptionAge(ageScore),
                    Impact       = "2",
                    DataPoint    = $"Stiftelsesdato: {company.Startdate}"
                },
                Employees = new RatingEntity()
                {
                    Value        = employeesScore,
                    Explaination = this.scoringDescriptionService.DescriptionEmployees(employeesScore),
                    Impact       = "1",
                    DataPoint    = $"Antal ansatte: {company.EmployeesDescription}"
                },
                Situation = new RatingEntity()
                {
                    Value        = sitautionScore,
                    Explaination = this.scoringDescriptionService.DescriptionSituation(sitautionScore),
                    Impact       = "3",
                    DataPoint    = $"Situation: {company.CompanySituation}"
                },
                Type = new RatingEntity()
                {
                    Value        = typeScore,
                    Explaination = this.scoringDescriptionService.DescriptionType(company.Type),
                    Impact       = "3",
                    DataPoint    = $"Virksomhedsform: {company.CompanyTypeDescription}"
                }
            };

            if (isAnnualReportAvailable && extendedCompany != null)
            {
                rating.Equity = new RatingEntity()
                {
                    Value        = equityScore,
                    Explaination = this.scoringDescriptionService.DescriptionEquity(equityScore),
                    Impact       = "2",
                    DataPoint    = $"Egenkapital: {extendedCompany.Equity}"
                };
                rating.Result = new RatingEntity()
                {
                    Value        = resultScore,
                    Explaination = this.scoringDescriptionService.DescriptionResult(resultScore),
                    Impact       = "1",
                    DataPoint    = $"Resultat: {extendedCompany.ProfitLoss}"
                };
            }

            rating.Stopped = !company.CompanyActive;

            return(rating);
        }