Highlights: default reference month to previous + YTD current year, user-changeable (#106) #111

Merged
maximus merged 1 commit from issue-106-highlights-default-ref-month into main 2026-04-19 12:34:37 +00:00
Owner

Summary

  • /reports/highlights now defaults the monthly tiles (current-month balance + top movers vs. previous month) to the previous calendar month instead of the current one — matching Cartes and Compare.
  • The YTD tile stays pinned to Jan 1st of the current civil year, independent of the reference month choice.
  • New CompareReferenceMonthPicker on the page lets the user pivot both the monthly balance tile and the top-movers comparison to any past month. Selection persists in the URL via ?refY=YYYY&refM=MM (bookmarkable, distinct from ?from/?to which govern YTD in other reports).
  • The hub highlights panel on /reports inherits the same default via useHighlights.
  • Shared helper defaultReferencePeriod(today) extracted to src/utils/referencePeriod.ts and adopted by useCartes and useCompare.

Signature changes

  • getHighlights(referenceYear, referenceMonth, ytdYear, windowDays?, topMoversLimit?, topTransactionsLimit?, today?) — replaces the previous (windowDays, referenceDate, ...) shape. today is injected for deterministic unit tests.
  • useHighlights() now returns { year, month, ytdYear, setReferencePeriod, ... } in addition to the previous data/isLoading/error/windowDays/setWindowDays.

Test plan

  • npm test -- --run — 14 suites, 121 tests pass (including the 6 updated getHighlights tests + 6 new resolveHighlightsReference tests + 3 new defaultReferencePeriod tests)
  • npm run build — tsc + vite build clean
  • cargo check passes
  • Manual: open /reports/highlights in April — monthly tile + top-movers should show March data by default; YTD should sum Jan 1 → today
  • Manual: change picker to, e.g., November 2025 — URL should update to ?refY=2025&refM=11, monthly tile shows Nov 2025 balance, YTD tile does NOT change
  • Manual: copy URL with ?refY/?refM, open in a new tab — same reference month preselected

🤖 Generated with Claude Code

## Summary - `/reports/highlights` now defaults the monthly tiles (current-month balance + top movers vs. previous month) to the **previous calendar month** instead of the current one — matching Cartes and Compare. - The YTD tile stays pinned to Jan 1st of the current civil year, independent of the reference month choice. - New `CompareReferenceMonthPicker` on the page lets the user pivot both the monthly balance tile and the top-movers comparison to any past month. Selection persists in the URL via `?refY=YYYY&refM=MM` (bookmarkable, distinct from `?from`/`?to` which govern YTD in other reports). - The hub highlights panel on `/reports` inherits the same default via `useHighlights`. - Shared helper `defaultReferencePeriod(today)` extracted to `src/utils/referencePeriod.ts` and adopted by `useCartes` and `useCompare`. ## Signature changes - `getHighlights(referenceYear, referenceMonth, ytdYear, windowDays?, topMoversLimit?, topTransactionsLimit?, today?)` — replaces the previous `(windowDays, referenceDate, ...)` shape. `today` is injected for deterministic unit tests. - `useHighlights()` now returns `{ year, month, ytdYear, setReferencePeriod, ... }` in addition to the previous `data/isLoading/error/windowDays/setWindowDays`. ## Test plan - [x] `npm test -- --run` — 14 suites, 121 tests pass (including the 6 updated `getHighlights` tests + 6 new `resolveHighlightsReference` tests + 3 new `defaultReferencePeriod` tests) - [x] `npm run build` — tsc + vite build clean - [x] `cargo check` passes - [ ] Manual: open `/reports/highlights` in April — monthly tile + top-movers should show March data by default; YTD should sum Jan 1 → today - [ ] Manual: change picker to, e.g., November 2025 — URL should update to `?refY=2025&refM=11`, monthly tile shows Nov 2025 balance, YTD tile does NOT change - [ ] Manual: copy URL with `?refY`/`?refM`, open in a new tab — same reference month preselected 🤖 Generated with [Claude Code](https://claude.com/claude-code)
maximus added the
status:ready
status:review
labels 2026-04-19 12:28:54 +00:00
maximus added 1 commit 2026-04-19 12:28:55 +00:00
feat(reports/highlights): default reference month to previous month + YTD current year, user-changeable (#106)
All checks were successful
PR Check / rust (push) Successful in 21m14s
PR Check / frontend (push) Successful in 2m16s
PR Check / rust (pull_request) Successful in 21m31s
PR Check / frontend (pull_request) Successful in 2m14s
8b90cb6489
- Extract shared defaultReferencePeriod helper (src/utils/referencePeriod.ts)
- useHighlights now reads ?refY=YYYY&refM=MM, defaults to previous month
- getHighlights signature: (referenceYear, referenceMonth, ytdYear, windowDays, ...)
- YTD tile pinned to Jan 1 of current civil year, independent of reference month
- CompareReferenceMonthPicker surfaced on /reports/highlights
- Hub highlights panel inherits the same default via useHighlights
- useCartes and useCompare now delegate their default-period helpers to the shared util
Author
Owner

Revue — APPROVE

Verdict

Implementation propre et bien testée. Les défauts demandés sont respectés et l'URL reste bookmarkable.

Points validés

  • defaultReferencePeriod extrait dans src/utils/referencePeriod.ts avec test dédié. Réutilisé par useCartes et useCompare (alias local conservé). Bonne dé-duplication.
  • URL params ?refY=YYYY&refM=MM — distincts de from/to, donc pas de conflit avec les autres rapports. Fallback clean vers defaultReferencePeriod() si absents ou malformés.
  • YTD anchored on current civil year (new Date().getFullYear()), indépendant de la référence choisie par l'utilisateur. Correspond à ce que demande l'issue.
  • Recent-transactions window continue de se fermer sur today (pas sur la fin du mois de référence) — comportement conservé, mentionné dans les notes.
  • Injection today dans getHighlights pour des tests déterministes. Bonne pratique.
  • CompareReferenceMonthPicker branché à côté du PeriodSelector dans ReportsHighlightsPage.
  • HubHighlightsPanel : useHighlights remplit automatiquement avec le bon défaut → le hub preview matche la page détail sans code supplémentaire.
  • Helper monthEnd mort supprimé (nettoyage).
  • Tests : 14 nouveaux tests sur useHighlights, referencePeriod, mise à jour complète de reportService.test.ts.

Vérifications locales

  • npm test -- --run : 121/121 verts (10 nouveaux tests)
  • npm run build : (5.28s)

Label hygiene

L'issue #106 portait à la fois status:ready et status:review après l'update de l'Agent — j'ai retiré le status:ready résiduel. Pattern à surveiller pour les prochains sprints.

Rien ne bloque le merge. Dernière PR du milestone spec-refonte-rapports 🎉

## Revue — APPROVE ✅ ### Verdict Implementation propre et bien testée. Les défauts demandés sont respectés et l'URL reste bookmarkable. ### Points validés - **`defaultReferencePeriod`** extrait dans `src/utils/referencePeriod.ts` avec test dédié. Réutilisé par `useCartes` et `useCompare` (alias local conservé). Bonne dé-duplication. - **URL params `?refY=YYYY&refM=MM`** — distincts de `from`/`to`, donc pas de conflit avec les autres rapports. Fallback clean vers `defaultReferencePeriod()` si absents ou malformés. - **YTD anchored on current civil year** (`new Date().getFullYear()`), indépendant de la référence choisie par l'utilisateur. Correspond à ce que demande l'issue. - **Recent-transactions window** continue de se fermer sur `today` (pas sur la fin du mois de référence) — comportement conservé, mentionné dans les notes. - **Injection `today`** dans `getHighlights` pour des tests déterministes. Bonne pratique. - **`CompareReferenceMonthPicker`** branché à côté du `PeriodSelector` dans `ReportsHighlightsPage`. - **`HubHighlightsPanel`** : `useHighlights` remplit automatiquement avec le bon défaut → le hub preview matche la page détail sans code supplémentaire. - Helper `monthEnd` mort supprimé (nettoyage). - **Tests** : 14 nouveaux tests sur `useHighlights`, `referencePeriod`, mise à jour complète de `reportService.test.ts`. ### Vérifications locales - `npm test -- --run` : **121/121** verts (10 nouveaux tests) - `npm run build` : ✅ (5.28s) ### Label hygiene L'issue #106 portait à la fois `status:ready` et `status:review` après l'update de l'Agent — j'ai retiré le `status:ready` résiduel. Pattern à surveiller pour les prochains sprints. Rien ne bloque le merge. Dernière PR du milestone `spec-refonte-rapports` 🎉
maximus merged commit da6041dc45 into main 2026-04-19 12:34:37 +00:00
maximus deleted branch issue-106-highlights-default-ref-month 2026-04-19 12:34:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: maximus/Simpl-Resultat#111
No description provided.