public decimal?CalculateWeightedTotalExpenditure()
        {
            var reportedValuesForAllSubcategories = PerformanceMeasure.GetReportedPerformanceMeasureValues(Project)
                                                    .Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear))
                                                    .Sum(x => x.ReportedValue ?? 0);

            if (Math.Abs(reportedValuesForAllSubcategories) < double.Epsilon)
            {
                return(null);
            }

            var projectGrantAllocationExpenditures = Project.ProjectGrantAllocationExpenditures.Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear)).ToList();
            var weight = TotalReportedValue / reportedValuesForAllSubcategories;

            return(projectGrantAllocationExpenditures.Sum(x => x.ExpenditureAmount) * Convert.ToDecimal(weight));
        }
示例#2
0
        public List <PerformanceMeasureSubcategoriesTotalReportedValue> SubcategoriesTotalReportedValues(Person currentPerson)
        {
            var groupByProjectAndSubcategory =
                GetReportedPerformanceMeasureValues(currentPerson)
                .Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear))
                .GroupBy(x => new { x.Project, x.PerformanceMeasureSubcategoriesAsString })
                .ToList();

            return
                (groupByProjectAndSubcategory.Select(
                     reportedValuesGroup =>
                     new PerformanceMeasureSubcategoriesTotalReportedValue(reportedValuesGroup.Key.Project,
                                                                           reportedValuesGroup.First().PerformanceMeasureSubcategoryOptions,
                                                                           this,
                                                                           reportedValuesGroup.Sum(x => x.ReportedValue))).ToList());
        }
        public static List <PerformanceMeasureSubcategoriesTotalReportedValue> SubcategoriesTotalReportedValues(FirmaSession currentFirmaSession, PerformanceMeasure performanceMeasure)
        {
            var groupByProjectAndSubcategory =
                performanceMeasure.GetReportedPerformanceMeasureValues(currentFirmaSession)
                .Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear))
                .GroupBy(x => new { x.Project, PerformanceMeasureSubcategoriesAsString = x.GetPerformanceMeasureSubcategoriesAsString() })
                .ToList();

            return
                (groupByProjectAndSubcategory.Select(
                     reportedValuesGroup =>
                     new PerformanceMeasureSubcategoriesTotalReportedValue(reportedValuesGroup.Key.Project,
                                                                           reportedValuesGroup.First().GetPerformanceMeasureSubcategoryOptions(),
                                                                           performanceMeasure,
                                                                           reportedValuesGroup.Sum(x => x.GetReportedValue()))).ToList());
        }