Beispiel #1
0
        public static IEnumerable <CalendarYearReportedValue> ToCalendarYearReportedValues(IEnumerable <ProjectGrantAllocationExpenditure> projectGrantAllocationExpenditures)
        {
            var yearRange = FirmaDateUtilities.GetRangeOfYearsForReporting();

            return(yearRange.OrderBy(cy => cy).Select(cy =>
            {
                var pmavForThisCalendarYear = projectGrantAllocationExpenditures.Where(x => x.CalendarYear == cy).ToList();
                return new CalendarYearReportedValue(cy, pmavForThisCalendarYear.Any() ? (double?)pmavForThisCalendarYear.Sum(y => y.ExpenditureAmount) : null);
            }));
        }
Beispiel #2
0
        private static ViewGoogleChartViewData GetCalendarYearExpendituresFromOrganizationGrantAllocationsLineChartViewData(Organization organization)
        {
            var yearRange = FirmaDateUtilities.GetRangeOfYearsForReporting();
            var projectGrantAllocationExpenditures = organization.GrantAllocations.SelectMany(x => x.ProjectGrantAllocationExpenditures);

            var chartTitle       = $"{FieldDefinition.ReportedExpenditure.GetFieldDefinitionLabelPluralized()} By {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()}";
            var chartContainerID = chartTitle.Replace(" ", "");
            var filterValues     = organization.GrantAllocations.Select(x => x.GrantAllocationName).Distinct().ToList();
            var googleChart      = projectGrantAllocationExpenditures.ToGoogleChart(x => x.GrantAllocation.GrantAllocationName,
                                                                                    filterValues,
                                                                                    x => x.GrantAllocation.GrantAllocationName,
                                                                                    yearRange,
                                                                                    chartContainerID,
                                                                                    chartTitle,
                                                                                    GoogleChartType.AreaChart,
                                                                                    true);

            return(new ViewGoogleChartViewData(googleChart, chartTitle, 400, true));
        }
Beispiel #3
0
        private static ViewGoogleChartViewData GetCalendarYearExpendituresFromProjectGrantAllocationsLineChartViewData(Organization organization, Person currentPerson)
        {
            var yearRange = FirmaDateUtilities.GetRangeOfYearsForReporting();

            var projects = organization.GetAllActiveProjectsAndProposalsWhereOrganizationIsStewardOrPrimaryContact(currentPerson).ToList();
            var projectGrantAllocationExpenditures = projects.SelectMany(x => x.ProjectGrantAllocationExpenditures).Where(x => x.GrantAllocation.BottommostOrganization != organization);

            var chartTitle       = $"{FieldDefinition.ReportedExpenditure.GetFieldDefinitionLabelPluralized()} By {FieldDefinition.OrganizationType.GetFieldDefinitionLabel()}";
            var chartContainerID = chartTitle.Replace(" ", "");
            var filterValues     = projects.SelectMany(x => x.ProjectGrantAllocationExpenditures).Where(x => x.GrantAllocation.BottommostOrganization != organization).Select(x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName).Distinct().ToList();

            var googleChart = projectGrantAllocationExpenditures.ToGoogleChart(x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName,
                                                                               filterValues,
                                                                               x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName,
                                                                               yearRange,
                                                                               chartContainerID,
                                                                               chartTitle,
                                                                               GoogleChartType.AreaChart,
                                                                               true);

            return(new ViewGoogleChartViewData(googleChart, chartTitle, 400, true));
        }
Beispiel #4
0
        public ViewResult AccomplishmentsDashboard()
        {
            var firmaPage       = FirmaPageTypeEnum.ProjectResults.GetFirmaPage();
            var tenantAttribute = MultiTenantHelpers.GetTenantAttributeFromCache();

            List <Organization> organizations;
            // default to Funding Organizations if no relationship type is selected to report in the dashboard.
            var relationshipTypeToReportInAccomplishmentsDashboard = MultiTenantHelpers.GetOrganizationRelationshipTypeToReportInAccomplishmentsDashboard();

            if (relationshipTypeToReportInAccomplishmentsDashboard == null)
            {
                var expectedFundingOrganizations = HttpRequestStorage.DatabaseEntities.ProjectFundingSourceBudgets
                                                   .Select(x => x.FundingSource.Organization).ToList();
                var reportedFundingOrganization = HttpRequestStorage.DatabaseEntities.ProjectFundingSourceExpenditures
                                                  .Select(x => x.FundingSource.Organization).ToList();

                expectedFundingOrganizations.AddRange(reportedFundingOrganization);
                organizations = expectedFundingOrganizations.Distinct(new HavePrimaryKeyComparer <Organization>()).OrderBy(x => x.OrganizationName).ToList();
            }
            else
            {
                organizations = HttpRequestStorage.DatabaseEntities.Projects.ToList().SelectMany(x =>
                                                                                                 x.ProjectOrganizations.Where(y =>
                                                                                                                              y.OrganizationRelationshipType == relationshipTypeToReportInAccomplishmentsDashboard).Select(z => z.Organization)).ToList().Distinct(new HavePrimaryKeyComparer <Organization>()).OrderBy(x => x.OrganizationName).ToList();
            }

            var defaultEndYear   = FirmaDateUtilities.CalculateCurrentYearToUseForRequiredReporting();
            var defaultBeginYear = defaultEndYear - (defaultEndYear - MultiTenantHelpers.GetMinimumYear());
            var associatePerformanceMeasureTaxonomyLevel = MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel();
            var taxonomyTiers = associatePerformanceMeasureTaxonomyLevel.GetTaxonomyTiers(HttpRequestStorage.DatabaseEntities).OrderBy(x => x.SortOrder).ThenBy(x => x.DisplayName, StringComparer.InvariantCultureIgnoreCase).ToList();
            var viewData      = new AccomplishmentsDashboardViewData(CurrentFirmaSession, firmaPage, tenantAttribute,
                                                                     organizations, FirmaDateUtilities.GetRangeOfYearsForReporting(), defaultBeginYear,
                                                                     defaultEndYear, taxonomyTiers, associatePerformanceMeasureTaxonomyLevel);

            return(RazorView <AccomplishmentsDashboard, AccomplishmentsDashboardViewData>(viewData));
        }