Default to yearly periods on Analyse, Strom and Wasser (#15)
Co-authored-by: Claudio Schaad <c.schaad@pog.ch> Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
This commit is contained in:
parent
cde16d2d0f
commit
29aa0ce736
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
|
- **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`
|
- **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
|
- **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`
|
- **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
|
### UI structure
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ using System.Linq;
|
||||||
namespace Schaad.Accounting.Models
|
namespace Schaad.Accounting.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// What the charts on the Strom and Wasser pages show: how the bills are grouped and which
|
/// What the charts on the Strom and Wasser pages show: how the bills are grouped (calendar year
|
||||||
/// years. A null <see cref="FromYear"/>/<see cref="ToYear"/> means from the first/to the last
|
/// 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.
|
/// year with a bill, so a newly added bill shows up without touching the filter.
|
||||||
/// </summary>
|
/// </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>
|
/// <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>
|
public static List<int> YearsOf<T>(IEnumerable<T> bills) where T : IPeriodBill<T>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@ public class BillChartFilterTestShould
|
||||||
BillChartFilter.YearsOf<ElectricityBill>([]).ShouldBeEmpty();
|
BillChartFilter.YearsOf<ElectricityBill>([]).ShouldBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GroupPerCalendarYearWhenNoKindIsGiven()
|
||||||
|
{
|
||||||
|
new BillChartFilter().Kind.ShouldBe(BillPeriodKind.Year);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CoverAllYearsWhenNoYearIsSelected()
|
public void CoverAllYearsWhenNoYearIsSelected()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public partial class Analytics : ComponentBase
|
||||||
{
|
{
|
||||||
(fromYear, toYear) = (toYear, fromYear);
|
(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;
|
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)
|
node = Acc is { } account ? new AnalyticsNode(account / 100, account, IsAssets ? null : Text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue