Default to yearly periods on Analyse, Strom and Wasser
- Analyse: the default period is now "Jahr" (was "Monat" for a single year, "Quartal" otherwise); a period in the URL still wins. - Strom/Wasser: BillChartFilter defaults to calendar years instead of per bill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cde16d2d0f
commit
8b1661d7b6
4 changed files with 11 additions and 5 deletions
|
|
@ -65,7 +65,7 @@ When a new year is opened, the previous year's data is copied as the starting po
|
|||
- **RawDataRepository** — plain-text load/save of the data files for the JSON editor page; validates (strict JSON, unique Ids, account references), refuses if the file changed since loading, and backs up the old version to `backup/{mandator}/{year}/json-{timestamp}/`; for `electricity.json` and `water.json` it reads/writes the mandator folder instead of the year folder
|
||||
- **Texte bereinigen** page (`TextCleanup`) — edits only the `Text` of one account's bookings in the selected year (inline, search/replace via `TextReplacement`, bulk set); saves through `RawDataRepository.SaveTransactionTextsAsync`
|
||||
- **AnalyticsService** — loads all years of the current mandator (via `MultiYearRepository`) into an `AccountingAnalysis` (expenses, income, net, assets) for the Analyse page; queries run in memory
|
||||
- **Strom** page (`Electricity`, `/electricity`, under "Charts" in the menu) — grid and dialog (FluentDataGrid/`ElectricityBillDialog`) over `IElectricityBillRepository`'s `ElectricityBill` records (one yearly NeoVac bill each: kWh/CHF for grid and PV, side costs; `TotalKwh`, `PvShare`, `TotalChf`, `ChfPerKwh` are computed); three Chart.js charts via `ChartJsChart` (stacked kWh, CHF/kWh lines, total CHF), filtered by the shared `BillChartToolbar` (`BillChartFilter`): grouped per bill (default), calendar year or half-year (`BillPeriod<T>.FromBills` over `IPeriodBill<T>`; a bill reaching over several periods is spread evenly over its months and the page shows a note) and limited to a from/to year range (periods overlapping it are kept whole)
|
||||
- **Strom** page (`Electricity`, `/electricity`, under "Charts" in the menu) — grid and dialog (FluentDataGrid/`ElectricityBillDialog`) over `IElectricityBillRepository`'s `ElectricityBill` records (one yearly NeoVac bill each: kWh/CHF for grid and PV, side costs; `TotalKwh`, `PvShare`, `TotalChf`, `ChfPerKwh` are computed); three Chart.js charts via `ChartJsChart` (stacked kWh, CHF/kWh lines, total CHF), filtered by the shared `BillChartToolbar` (`BillChartFilter`): grouped per bill, calendar year (default) or half-year (`BillPeriod<T>.FromBills` over `IPeriodBill<T>`; a bill reaching over several periods is spread evenly over its months and the page shows a note) and limited to a from/to year range (periods overlapping it are kept whole)
|
||||
- **Wasser** page (`Water`, `/water`, under "Charts" in the menu) — same layout as Strom over `IWaterBillRepository`'s `WaterBill` records (warm/cold water m³ and CHF, base costs; `TotalM3`, `WarmWaterShare`, `TotalChf` are computed); two charts (stacked m³, total CHF) with the same `BillChartToolbar`
|
||||
|
||||
### UI structure
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ using System.Linq;
|
|||
namespace Schaad.Accounting.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// What the charts on the Strom and Wasser pages show: how the bills are grouped and which
|
||||
/// years. A null <see cref="FromYear"/>/<see cref="ToYear"/> means from the first/to the last
|
||||
/// What the charts on the Strom and Wasser pages show: how the bills are grouped (calendar year
|
||||
/// by default) and which years. A null <see cref="FromYear"/>/<see cref="ToYear"/> means from the first/to the last
|
||||
/// year with a bill, so a newly added bill shows up without touching the filter.
|
||||
/// </summary>
|
||||
public record BillChartFilter(BillPeriodKind Kind = BillPeriodKind.Bill, int? FromYear = null, int? ToYear = null)
|
||||
public record BillChartFilter(BillPeriodKind Kind = BillPeriodKind.Year, int? FromYear = null, int? ToYear = null)
|
||||
{
|
||||
/// <summary>The years any bill touches, from the first to the last; empty without bills.</summary>
|
||||
public static List<int> YearsOf<T>(IEnumerable<T> bills) where T : IPeriodBill<T>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ public class BillChartFilterTestShould
|
|||
BillChartFilter.YearsOf<ElectricityBill>([]).ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GroupPerCalendarYearWhenNoKindIsGiven()
|
||||
{
|
||||
new BillChartFilter().Kind.ShouldBe(BillPeriodKind.Year);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CoverAllYearsWhenNoYearIsSelected()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public partial class Analytics : ComponentBase
|
|||
{
|
||||
(fromYear, toYear) = (toYear, fromYear);
|
||||
}
|
||||
period = ParsePeriod(Period) ?? (fromYear == toYear ? AnalyticsPeriod.Month : AnalyticsPeriod.Quarter);
|
||||
period = ParsePeriod(Period) ?? AnalyticsPeriod.Year;
|
||||
view = Enum.TryParse<AnalyticsView>(View, ignoreCase: true, out var parsedView) ? parsedView : AnalyticsView.Expenses;
|
||||
|
||||
node = Acc is { } account ? new AnalyticsNode(account / 100, account, IsAssets ? null : Text)
|
||||
|
|
|
|||
Loading…
Reference in a new issue