public void YearSumsCorrectly() { var org1 = TestFramework.TestOrganization.Create(); var projectGrantAllocationExpenditures = BuildExpenditures(org1, "grant allocation 1", new Dictionary <int, decimal> { { 2010, 100.0m }, { 2011, 200.0m }, { 2012, 300.0m }, { 2013, 400.0m } }); var org2 = TestFramework.TestOrganization.Create(); projectGrantAllocationExpenditures.AddAll(BuildExpenditures(org2, "grant allocation 2", new Dictionary <int, decimal> { { 2010, 100.0m }, { 2011, 200.0m }, { 2012, 300.0m }, { 2013, 400.0m } })); var beginCalendarYear = projectGrantAllocationExpenditures.Min(x => x.CalendarYear); var endCalendarYear = projectGrantAllocationExpenditures.Max(x => x.CalendarYear); var rangeOfYears = FirmaDateUtilities.GetRangeOfYears(beginCalendarYear, endCalendarYear); var fullOrganizationTypeAndYearDictionary = projectGrantAllocationExpenditures.GetFullCategoryYearDictionary(x => x.GrantAllocation.BottommostOrganization.DisplayName, new List <string> { org1.DisplayName, org2.DisplayName }, x => x.GrantAllocation.BottommostOrganization.DisplayName, rangeOfYears); Assert.That(fullOrganizationTypeAndYearDictionary.Sum(x => x.Value[2012]), Is.EqualTo(600.0m)); }
private PartialViewResult ViewEditTechnicalAssistanceRequests(Project project, EditTechnicalAssistanceRequestsViewModel viewModel) { var firmaPage = FirmaPageTypeEnum.TechnicalAssistanceInstructions.GetFirmaPage(); var technicalAssistanceTypes = TechnicalAssistanceType.All; var fiscalYearStrings = FirmaDateUtilities.GetRangeOfYears(MultiTenantHelpers.GetMinimumYear(), FirmaDateUtilities.CalculateCurrentYearToUseForUpToAllowableInputInReporting() + 2).OrderByDescending(x => x).Select(x => new CalendarYearString(x)).ToList(); var personDictionary = HttpRequestStorage.DatabaseEntities.People.Where(x => x.RoleID == Role.Admin.RoleID || x.RoleID == Role.ProjectSteward.RoleID).OrderBy(x => x.LastName).ThenBy(x => x.FirstName).ToList().Select(x => new PersonSimple(x)).ToList(); var viewData = new EditTechnicalAssistanceRequestsViewData(CurrentFirmaSession, firmaPage, project, technicalAssistanceTypes, fiscalYearStrings, personDictionary); return(RazorPartialView <EditTechnicalAssistanceRequests, EditTechnicalAssistanceRequestsViewData, EditTechnicalAssistanceRequestsViewModel>(viewData, viewModel)); }
private static List <int> GetRangeOfYears(List <ProjectFundingSourceExpenditure> projectFundingSourceExpenditures) { if (!projectFundingSourceExpenditures.Any()) { return(new List <int>()); } var beginCalendarYear = projectFundingSourceExpenditures.Min(x => x.CalendarYear); var endCalendarYear = projectFundingSourceExpenditures.Max(x => x.CalendarYear); var rangeOfYears = FirmaDateUtilities.GetRangeOfYears(beginCalendarYear, endCalendarYear); return(rangeOfYears); }
/// <summary> /// Only public for unit testing /// </summary> public static List <PerformanceMeasureActualUpdate> CreatePerformanceMeasureActualUpdateRecordsForGivenYearToCurrentYear(ProjectUpdateBatch projectUpdateBatch, List <IPerformanceMeasureValue> performanceMeasureValuesToClone, int initialYearToFill, int endYearToFill) { var exemptYears = projectUpdateBatch.Project.GetPerformanceMeasuresExemptReportingYears().Select(x => x.CalendarYear).ToList(); var yearsToFill = FirmaDateUtilities.GetRangeOfYears(initialYearToFill, endYearToFill).Where(x => !exemptYears.Contains(x)).ToList(); var performanceMeasureActualUpdates = new List <PerformanceMeasureActualUpdate>(); foreach (var year in yearsToFill) { // when pre-filling, we intentionally set the reported value to null to prompt the user to fill that in performanceMeasureActualUpdates.AddRange( performanceMeasureValuesToClone.Select(performanceMeasureValue => ClonePerformanceMeasureValue(projectUpdateBatch, performanceMeasureValue, year, null))); } return(performanceMeasureActualUpdates); }
public static GoogleChartJson ToGoogleChart(this IEnumerable <ProjectGrantAllocationExpenditure> projectGrantAllocationExpenditures, Func <ProjectGrantAllocationExpenditure, string> filterFunction, List <string> filterValues, Func <ProjectGrantAllocationExpenditure, IComparable> sortFunction, string chartContainerID, string chartTitle) { var projectGrantAllocationExpenditureList = projectGrantAllocationExpenditures.ToList(); if (!projectGrantAllocationExpenditureList.Any()) { return(null); } var beginCalendarYear = projectGrantAllocationExpenditureList.Min(x => x.CalendarYear); var endCalendarYear = projectGrantAllocationExpenditureList.Max(x => x.CalendarYear); var rangeOfYears = FirmaDateUtilities.GetRangeOfYears(beginCalendarYear, endCalendarYear); return(projectGrantAllocationExpenditureList.ToGoogleChart(filterFunction, filterValues, sortFunction, rangeOfYears, chartContainerID, chartTitle, GoogleChartType.AreaChart, true)); }
public PartialViewResult EditPerformanceMeasureActualsForProject(ProjectPrimaryKey projectPrimaryKey) { var project = projectPrimaryKey.EntityObject; var performanceMeasureActualSimples = project.PerformanceMeasureActuals.OrderBy(pam => pam.PerformanceMeasure.SortOrder).ThenBy(pam => pam.PerformanceMeasure.DisplayName).Select(x => new PerformanceMeasureActualSimple(x)).ToList(); var projectExemptReportingYears = project.GetPerformanceMeasuresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList(); var currentExemptedYears = projectExemptReportingYears.Select(x => x.CalendarYear).ToList(); var endYear = DateTime.Now.Year; var startYear = project.GetImplementationStartYear() ?? endYear; var possibleYearsToExempt = FirmaDateUtilities.GetRangeOfYears(startYear, endYear).OrderBy(x => x).ToList(); projectExemptReportingYears.AddRange( possibleYearsToExempt.Where(x => !currentExemptedYears.Contains(x)).Select((x, index) => new ProjectExemptReportingYearSimple(-(index + 1), project.ProjectID, x))); var viewModel = new EditPerformanceMeasureActualsViewModel(performanceMeasureActualSimples, project.PerformanceMeasureActualYearsExemptionExplanation, projectExemptReportingYears.OrderBy(x => x.CalendarYear).ToList()); return(ViewEditPerformanceMeasureActuals(project, viewModel)); }
public void GroupByOrgSumsCorrectly() { var projectFundingSourceExpenditures = BuildExpenditures("org 1", "funding source 1", new Dictionary <int, decimal> { { 2010, 100.0m }, { 2011, 200.0m }, { 2012, 300.0m }, { 2013, 400.0m } }); projectFundingSourceExpenditures.AddAll(BuildExpenditures("org 2", "funding source 2", new Dictionary <int, decimal> { { 2010, 100.0m }, { 2011, 200.0m }, { 2012, 300.0m }, { 2013, 400.0m } })); var beginCalendarYear = projectFundingSourceExpenditures.Min(x => x.CalendarYear); var endCalendarYear = projectFundingSourceExpenditures.Max(x => x.CalendarYear); var rangeOfYears = FirmaDateUtilities.GetRangeOfYears(beginCalendarYear, endCalendarYear); var fullOrganizationTypeAndYearDictionary = projectFundingSourceExpenditures.GetFullCategoryYearDictionary(x => x.FundingSource.Organization.GetDisplayName(), new List <string> { "org 1", "org 2" }, x => x.FundingSource.Organization.GetDisplayName(), rangeOfYears); Assert.That(fullOrganizationTypeAndYearDictionary["org 1"].Sum(x => x.Value), Is.EqualTo(1000.0m)); }
private static void AssertThatProjectHasNoSubmittedProjectUpdates(Project project, List <int> reportingYearsToExclude, string assertMessage) { var rangeOfReportingYears = FirmaDateUtilities.GetRangeOfYears(2014, FirmaDateUtilities.CalculateCurrentYearToUseForRequiredReporting()); rangeOfReportingYears.Where(x => !reportingYearsToExclude.Contains(x)).ToList().ForEach(year => Assert.That(project.IsUpdateMandatory, Is.True, assertMessage)); }