public ProjectFundingSourceExpenditureBulk(ProjectFundingSourceExpenditure projectFundingSourceExpenditure,
                                                   List <ProjectFundingSourceExpenditure> projectFundingSourceExpenditures,
                                                   IEnumerable <int> calendarYearsToPopulate)
        {
            ProjectID                = projectFundingSourceExpenditure.ProjectID;
            FundingSourceID          = projectFundingSourceExpenditure.FundingSourceID;
            IsRelevant               = true;
            CalendarYearExpenditures = new List <CalendarYearMonetaryAmount>();
            AddProjectFundingSourceExpenditures(projectFundingSourceExpenditures);
            // we need to fill in the other calendar years with blanks
            var usedCalendarYears = projectFundingSourceExpenditures.Select(x => x.CalendarYear).ToList();

            CalendarYearExpenditures.AddRange(calendarYearsToPopulate.Where(x => !usedCalendarYears.Contains(x)).ToList().Select(x => new CalendarYearMonetaryAmount(x, 0, true)));
        }
        public static string GetFundingSourceCustomAttributesValue(this ProjectFundingSourceExpenditure projectFundingSourceExpenditure, FundingSourceCustomAttributeType fundingSourceCustomAttributeType)
        {
            var fundingSourceCustomAttribute = projectFundingSourceExpenditure.FundingSource.FundingSourceCustomAttributes.SingleOrDefault(x => x.FundingSourceCustomAttributeTypeID == fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID);

            if (fundingSourceCustomAttribute != null)
            {
                if (fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataType == FundingSourceCustomAttributeDataType.DateTime)
                {
                    return(DateTime.TryParse(fundingSourceCustomAttribute.GetCustomAttributeValues().Single().AttributeValue, out var date) ? date.ToShortDateString() : null);
                }
                else
                {
                    return(string.Join(", ",
                                       fundingSourceCustomAttribute.FundingSourceCustomAttributeValues.Select(x => x.AttributeValue)));
                }
            }
            else
            {
                return("None");
            }
        }
            public static ProjectFundingSourceExpenditure Create(Project project, FundingSource fundingSource)
            {
                var projectFundingSourceExpenditure = ProjectFundingSourceExpenditure.CreateNewBlank(project, fundingSource);

                return(projectFundingSourceExpenditure);
            }
 public void AddProjectFundingSourceExpenditure(ProjectFundingSourceExpenditure projectFundingSourceExpenditure)
 {
     Check.Require(projectFundingSourceExpenditure.ProjectID == ProjectID && projectFundingSourceExpenditure.FundingSourceID == FundingSourceID,
                   "Row doesn't align with collection mismatch ProjectID and FundingSourceID");
     CalendarYearExpenditures.Add(new CalendarYearMonetaryAmount(projectFundingSourceExpenditure.CalendarYear, projectFundingSourceExpenditure.ExpenditureAmount, true));
 }