private Worksheet RenderFundLine(Worksheet worksheet, FundLine fundLine, string contractAllocationNumber) { var row = NextRow(worksheet); RenderFundingSummaryReportRow(worksheet, row, fundLine, contractAllocationNumber); ApplyFutureMonthStyleToRow(worksheet, row, fundLine.CurrentPeriod); return(worksheet); }
public void SumPeriods() { var fundLine = new FundLine( 5, "FundLine", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); fundLine.Period1To8.Should().Be(36); fundLine.Period9To12.Should().Be(42); fundLine.YearToDate.Should().Be(15); fundLine.Total.Should().Be(78); }
public static ICollection <Period> GetPeriodsForFundLine(IEnumerable <PeriodisedData> periodisedData, FundLine fundLine) { if (fundLine.AcademicYear.HasValue) { return(periodisedData.SelectMany(fpd => fpd.Periods.Where(w => w.CollectionYear == fundLine.AcademicYear)).ToList()); } else { return(periodisedData.SelectMany(fpd => fpd.Periods).ToList()); } }
private static void SaveJsonFromSpreadSheet(string filename, List <SSFundingStream> spreadSheetData) { var summarisationTypes = new List <SummarisationTypeModel> { new SummarisationTypeModel { FundingStreams = new List <FundingStream>(), SummarisationType = $"{MainYear}FM35" }, new SummarisationTypeModel { FundingStreams = new List <FundingStream>(), SummarisationType = $"{MainYear}EAS" }, new SummarisationTypeModel { FundingStreams = new List <FundingStream>(), SummarisationType = $"{MainYear}FM25" }, new SummarisationTypeModel { FundingStreams = new List <FundingStream>(), SummarisationType = $"{MainYear}ALB" }, new SummarisationTypeModel { FundingStreams = new List <FundingStream>(), SummarisationType = $"{MainYear}TBL" }, }; foreach (var ssFundingStream in spreadSheetData) { foreach (var fundingStreamDeliverableLineCode in ssFundingStream.DeliverableLineCodes) { var summType = GetSummarisationTypeForDLC(summarisationTypes, fundingStreamDeliverableLineCode); var fundingStream = new FundingStream { PeriodCode = ssFundingStream.PeriodCode, DeliverableLineCode = fundingStreamDeliverableLineCode.LineCode, FundModel = summType.SummarisationType.Replace(MainYear, ""), FundLines = new List <FundLine>() }; summType.FundingStreams.Add(fundingStream); foreach (var ssFundLine in fundingStreamDeliverableLineCode.FundLines) { var fundLine = new FundLine { Fundline = ssFundLine.Line, LineType = ssFundLine.LineType, UseAttributes = ssFundLine.ValueCalculation.Contains("AttributeName"), Attributes = GetAttributesFromValueCalculation(ssFundLine.ValueCalculation) }; fundingStream.FundLines.Add(fundLine); } } } //Generate Unit Test Theories //foreach (var summarisationType in summarisationTypes) //{ // foreach (var fundingStream in summarisationType.FundingStreams) // { // foreach (var fundLine in fundingStream.FundLines) // { // Console.WriteLine($"[InlineData(\"{summarisationType.SummarisationType}\", \"{fundingStream.PeriodCode}\", {fundingStream.DeliverableLineCode}, \"{fundLine.Fundline}\", \"{fundLine.LineType}\")]"); // } // } //} var jsonString = JsonSerializer.Serialize(summarisationTypes, new JsonSerializerOptions { WriteIndented = true, IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }); File.WriteAllText(filename, jsonString); }
public ICollection <Period> GetPeriodsForFundLine(IEnumerable <PeriodisedData> periodisedData, FundLine fundLine) { if (fundLine.UseAttributes) { periodisedData = periodisedData.Where(pd => fundLine.Attributes.Contains(pd.AttributeName)); } return(periodisedData.SelectMany(fpd => fpd.Periods).ToList()); }