New page /analytics shows the current mandator's expenses across all years, with drill-down all -> subclass -> account -> booking-text group, year range and month/quarter/year filters, KPI tiles, a stacked bar chart and a category list. Filters and drill-down position live in the URL. - MultiYearRepository reads any mandator/year (read-only, shared cache) - ExpenseAnalysis flattens all years and answers queries in memory: net amounts (refunds count negative), accounts keyed by number with the latest name, bookings counted in the year of their books, year-over-year comparison over the same months - Chart.js 4.5.1 vendored in wwwroot/lib/chartjs, wrapped by wwwroot/js/charts.js and StackedBarChart.razor Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1 KiB
C#
30 lines
1 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Schaad.Accounting.Datasets.Analytics;
|
|
using Schaad.Accounting.Interfaces;
|
|
|
|
namespace Schaad.Accounting.Services
|
|
{
|
|
public class AnalyticsService : IAnalyticsService
|
|
{
|
|
private readonly ISettingsService settingsService;
|
|
private readonly IMultiYearRepository multiYearRepository;
|
|
|
|
public AnalyticsService(ISettingsService settingsService, IMultiYearRepository multiYearRepository)
|
|
{
|
|
this.settingsService = settingsService;
|
|
this.multiYearRepository = multiYearRepository;
|
|
}
|
|
|
|
public async Task<ExpenseAnalysis> GetExpenseAnalysisAsync()
|
|
{
|
|
var mandator = settingsService.GetMandator();
|
|
var years = new List<YearData>();
|
|
foreach (var year in multiYearRepository.GetYears(mandator))
|
|
{
|
|
years.Add(await multiYearRepository.GetYearDataAsync(mandator, year));
|
|
}
|
|
return new ExpenseAnalysis(years);
|
|
}
|
|
}
|
|
}
|