## Summary
Step 4 of the analytics plan, items 2, 4 and 5: **income, net and assets views** on the Analyse page (replacing the old Vermögen chart page) and a **narrow-screen layout** pass.
### Views
A switch at the top selects **Ausgaben | Einnahmen | Netto | Vermögen**, stored in the URL as `view=`. Switching starts the drill-down from the top, because the subclasses differ per view.
- **Einnahmen:** works like Ausgaben. Bookings *from* an income account count positive, bookings *to* one (corrections) negative.
- **Netto:** income minus expenses. Income subclasses are positive and expense subclasses negative.
- The bar chart stacks income up and expenses down, with a black line for the net result per period; the tooltip total is left out there.
- Categories are ordered by size, so the big expense groups aren't folded into "Andere".
- The fourth tile shows the **savings rate** (net / income).
- No treemap, since areas can't show negative amounts.
- **Vermögen:** month-end balances of the asset accounts (class 1) in CHF. It is a stock, not a flow:
- A month, quarter or year shows the balance at its end, and the total is the balance at the end of the range.
- Tiles show that balance, the change since the start of the range (with the opening balance), and the comparison with the same month a year earlier.
- The year table shows year-end balances; the drill-down ends at the account.
- The year comparison shows month-end balances, without the cumulative switch.
- Foreign-currency balances are computed like the balance sheet (`ViewService`): kept in the account currency and converted with `IFxConverter`, which is asked once per currency.
- **Colours follow the view:** more expenses are red; more income, surplus or assets green. The CSS classes are now `worse` / `better` instead of `up` / `down`.
### Code
- `ExpenseAnalysis` → **`AccountingAnalysis`** with `AnalyticsView` (Expenses, Income, Net, Assets), and `GetExpenseAnalysisAsync` → `GetAnalysisAsync`. The running year's last month now comes from all bookings, not just expenses.
- `AnalyticsResult.Opening` gives the balance at the start of the range for Vermögen.
- `charts.js`: the stacked bar chart takes an optional `totalLine`.
### Removed
- The **Vermögen** chart page (`/Assets`) and its menu entry. Plotly is now only used by the booking-text charts on the Transactions page.
### Narrow screens
At 400 px the page was wider than the screen.
- **App-wide:** the side menu took half the screen. It now starts collapsed to icons below 700 px (`wwwroot/js/viewport.js`); the ☰ toggle still opens it. The header dropdowns are narrower, and the app name hides below 520 px.
- **Analyse page:** button groups wrap, the tiles sit two per row, and in the year table the name column is narrower and pinned while the years scroll, with the full name as a tooltip.
## Test plan
- [x] `dotnet build`: no warnings
- [x] `dotnet test`: 88/88 pass, including 7 new `AccountingAnalysisTestShould` tests (income signs, net ordering, month-end balances with opening, balance at period end, FX conversion asked once, comparison at the same month, assets drill-down ends at the account)
- [x] Against a copy of the real data, all matching the app's own reports:
- Einnahmen 2026 = 109'865.13 ("Total Einkünfte" in the profit-and-loss report)
- Netto 2026 = 32'859.06 (= 109'865.13 − 77'006.07)
- Vermögen end of Oct 2026 = 263'994.98 ("Total Aktiven" in the Bilanz)
- [x] Headless Chrome at 400, 820 and 1500 px: no horizontal overflow; menu collapsed at 400 px and expanded at 820 / 1500 px; pinned table column scrolls correctly; all charts render without console errors
## Note on the data (not a code issue)
The Vermögen view shows each year as its books say. In the real data, some closing balances don't match the next year's opening balances. These are probably bookings added to a year after the next one was opened:
- End of 2024 → 2025: Bargeld CHF (+40.75)
- End of 2025 → 2026: Bargeld CHF (+98.50), TKB Privatkonto (+200.00), account 1042 (2'030.40 at the end of 2025, missing in 2026), Durchlaufskonto (−7.29)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: #6
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
4 lines
143 B
JavaScript
4 lines
143 B
JavaScript
// Viewport helpers for Blazor components that need the window size on first render.
|
|
export function width() {
|
|
return window.innerWidth;
|
|
}
|