public ProjectBudgetsAnnualByCostTypeViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, List <ProjectFundingSourceCostTypeAmount> projectFundingSourceCostTypeAmounts, List <ProjectNoFundingSourceCostTypeAmount> projectNoFundingSourceCostTypeAmounts, string expectedFundingUpdateNote) : base(currentFirmaSession) { Project = project; FieldDefinitionForProject = FieldDefinitionEnum.Project.ToType(); FieldDefinitionForFundingSource = FieldDefinitionEnum.FundingSource.ToType(); FieldDefinitionForCostType = FieldDefinitionEnum.CostType.ToType(); FieldDefinitionForEstimatedTotalCost = FieldDefinitionEnum.EstimatedTotalCost.ToType(); FieldDefinitionForEstimatedAnnualOperatingCost = FieldDefinitionEnum.EstimatedAnnualOperatingCost.ToType(); FieldDefinitionForProjectedFunding = FieldDefinitionEnum.ProjectedFunding.ToType(); FieldDefinitionForObligatedFunding = FieldDefinitionEnum.ObligatedFunding.ToType(); FieldDefinitionForExpendedFunding = FieldDefinitionEnum.ExpendedFunding.ToType(); ProjectFundingSourceCostTypeAmounts = projectFundingSourceCostTypeAmounts; var calendarYears = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears(); var usedCalendarYears = projectFundingSourceCostTypeAmounts.Where(x => x.CalendarYear.HasValue && !calendarYears.Contains(x.CalendarYear.Value)).Select(x => x.CalendarYear.Value).Distinct().ToList(); calendarYears.AddRange(usedCalendarYears); calendarYears.Sort(); CalendarYears = calendarYears; ProjectNoFundingSourceCostTypeAmounts = projectNoFundingSourceCostTypeAmounts; ExpectedFundingUpdateNote = expectedFundingUpdateNote; ObligationItemBudgetRollUps = project.GetObligationItemBudgetRollUpByYearAndCostTypeAndFundingSourceSimples(); ObligationItemInvoiceRollUps = project.GetObligationItemInvoiceRollUpByYearAndCostTypeAndFundingSourceSimples(); }
/// <summary> /// Method to check whether each section in a proposal is complete /// /// </summary> /// <param name="project"></param> /// <param name="geospatialAreaTypes">Geospatial areas are defined per tenant, this is passed to check if the tenant has any and are complete</param> public ProposalSectionsStatus(ProjectFirmaModels.Models.Project project, List <GeospatialAreaType> geospatialAreaTypes, FirmaSession currentFirmaSession) { // Basics section var basicsResults = new BasicsViewModel(project).GetValidationResults(); IsBasicsSectionComplete = !basicsResults.Any(); // Custom Attributes section var customAttributesValidationResults = project.ValidateCustomAttributes(currentFirmaSession).GetWarningMessages(); IsProjectCustomAttributesSectionComplete = !customAttributesValidationResults.Any(); // Project Location simple section var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults(); IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any(); // Project location detailed section IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete; // Geospatial Area section if (geospatialAreaTypes.Any()) { var isGeospatialAreaSectionComplete = true; foreach (var geospatialAreaType in geospatialAreaTypes) { var geospatialAreaIDs = project.ProjectGeospatialAreas.Where(x => x.GeospatialArea.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID).Select(x => x.GeospatialAreaID).ToList(); var editGeospatialAreaValidationResults = new EditProjectGeospatialAreasViewModel(geospatialAreaIDs, project.ProjectGeospatialAreaTypeNotes.SingleOrDefault(x => x.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID)?.Notes).GetValidationResults(); if (editGeospatialAreaValidationResults.Any()) { isGeospatialAreaSectionComplete = false; break; } } IsGeospatialAreaSectionComplete = isGeospatialAreaSectionComplete; } else { IsGeospatialAreaSectionComplete = true; } // Performance Measure section IsPerformanceMeasureSectionComplete = IsBasicsSectionComplete; // Project FundingSource Budget and Cost Type section var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears(); var allProjectRelevantCostTypesAsSimples = project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Budgets); var budgetValidationResults = new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange, allProjectRelevantCostTypesAsSimples).GetValidationResults(); IsExpectedFundingSectionComplete = !budgetValidationResults.Any(); // Classifications section var proposalClassificationSimples = ProjectCreateController.GetProjectClassificationSimples(project); var classificationValidationResults = new EditProposalClassificationsViewModel(proposalClassificationSimples, project).GetValidationResults(); IsClassificationsComplete = !classificationValidationResults.Any(); // Assessment section IsAssessmentComplete = ProjectCreateController.GetProjectAssessmentQuestionSimples(project).All(simple => simple.Answer.HasValue); // Notes section IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes }