/// <summary> /// Analyses the specified ledger and assigns graph data /// </summary> public void Analyse([NotNull] LedgerBucket ledger, [NotNull] LedgerBook book) { if (ledger == null) { throw new ArgumentNullException(nameof(ledger)); } if (book == null) { throw new ArgumentNullException(nameof(book)); } GraphData = new GraphData { GraphName = "Bucket Balance History" }; var series = new SeriesData { Description = "The actual bank balance of the Ledger Bucket over time.", SeriesName = "Balance" }; GraphData.SeriesList.Add(series); foreach (var reconciliation in book.Reconciliations.Take(24).Reverse()) { var entry = reconciliation.Entries.FirstOrDefault(e => e.LedgerBucket == ledger); var plot = new DatedGraphPlot { Date = reconciliation.Date, Amount = entry?.Balance ?? 0 }; series.PlotsList.Add(plot); } }
/// <summary> /// Analyses the specified statement. /// </summary> /// <param name="statement">The statement.</param> /// <param name="criteria">The criteria.</param> /// <exception cref="System.ArgumentNullException"> /// </exception> public void Analyse([NotNull] StatementModel statement, [NotNull] GlobalFilterCriteria criteria) { if (statement == null) { throw new ArgumentNullException(nameof(statement)); } if (criteria == null) { throw new ArgumentNullException(nameof(criteria)); } Reset(); var minDate = CalculateStartDate(statement, criteria); var maxDate = CalculateEndDate(statement, criteria); var currentMonth = minDate; var nextMonth = currentMonth.AddMonths(1); var subTotals = new Dictionary<string, decimal>(); List<SeriesData> allSeriesData = InitialiseSeriesData(minDate, maxDate); foreach (var transaction in statement.AllTransactions) { if (transaction.Date >= nextMonth) { StoreSummarisedMonthData(subTotals, allSeriesData, currentMonth); currentMonth = nextMonth; nextMonth = nextMonth.AddMonths(1); subTotals = new Dictionary<string, decimal>(); if (currentMonth >= maxDate) { break; } } GetOrAdd(subTotals, transaction.BudgetBucket.Code, transaction.Amount); } StoreSummarisedMonthData(subTotals, allSeriesData, currentMonth); Graph = new GraphData { SeriesList = allSeriesData, GraphName = "Long term spending for Budget Buckets" }; RemoveSeriesWithNoData(); }
public void TestInitialise() { StartDate = new DateTime(2014, 08, 20); Subject = new GraphData { GraphName = "Main Graph Title" }; Series1 = new SeriesData { SeriesName = "Series 1", Description = "Series 1 Description" }; Series2 = new SeriesData { SeriesName = "Series 2", Description = "Series 2 Description" }; Series3 = new SeriesData { SeriesName = "Series 3", Description = "Series 3 Description" }; Subject.SeriesList.Add(Series1); Subject.SeriesList.Add(Series2); Subject.SeriesList.Add(Series3); var seriesNumber = 0; foreach (SeriesData series in Subject.SeriesList) { for (var index = 0; index < 31; index++) { series.PlotsList.Add(new DatedGraphPlot { Amount = seriesNumber * 100 * (index + 1), Date = StartDate.AddDays(index) }); } seriesNumber++; } }
/// <summary> /// Initializes a new instance of the <see cref="BurnDownChartAnalyserResult" /> class. /// </summary> public BurnDownChartAnalyserResult() { GraphLines = new GraphData(); }
public void Reset() { Graph = null; }