/** * Shared helper used by reports that pivot on a reference month * (Highlights, Compare, Cartes). Returns the calendar month immediately * preceding `today` — January wraps to December of the previous year. * * Kept as a pure function so every consumer can unit-test its own wiring * with a deterministic `today` override. */ export function defaultReferencePeriod( today: Date = new Date(), ): { year: number; month: number } { const y = today.getFullYear(); const m = today.getMonth() + 1; if (m === 1) return { year: y - 1, month: 12 }; return { year: y, month: m - 1 }; }