diff --git a/CHANGELOG.md b/CHANGELOG.md index e523bca..b6b59dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Dynamic Report: fields can now be used in multiple zones simultaneously (rows + filters, columns + filters) - Dynamic Report: right-click on a filter value to exclude it (shown with strikethrough in red) +- "This year" period option in reports and dashboard (Jan 1 to today) ## [0.3.9] diff --git a/src/components/dashboard/PeriodSelector.tsx b/src/components/dashboard/PeriodSelector.tsx index 5828f7d..329af2d 100644 --- a/src/components/dashboard/PeriodSelector.tsx +++ b/src/components/dashboard/PeriodSelector.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import { Calendar } from "lucide-react"; import type { DashboardPeriod } from "../../shared/types"; -const PERIODS: DashboardPeriod[] = ["month", "3months", "6months", "12months", "all"]; +const PERIODS: DashboardPeriod[] = ["month", "3months", "6months", "year", "12months", "all"]; interface PeriodSelectorProps { value: DashboardPeriod; diff --git a/src/hooks/useDashboard.ts b/src/hooks/useDashboard.ts index a2eaec6..3fac45f 100644 --- a/src/hooks/useDashboard.ts +++ b/src/hooks/useDashboard.ts @@ -102,6 +102,9 @@ function computeDateRange( case "6months": from = new Date(year, month - 5, 1); break; + case "year": + from = new Date(year, 0, 1); + break; case "12months": from = new Date(year, month - 11, 1); break; diff --git a/src/hooks/useReports.ts b/src/hooks/useReports.ts index e8404e4..250a50c 100644 --- a/src/hooks/useReports.ts +++ b/src/hooks/useReports.ts @@ -124,6 +124,9 @@ function computeDateRange( case "6months": from = new Date(year, month - 5, 1); break; + case "year": + from = new Date(year, 0, 1); + break; case "12months": from = new Date(year, month - 11, 1); break; diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx index 408dc87..f8d32f4 100644 --- a/src/pages/DashboardPage.tsx +++ b/src/pages/DashboardPage.tsx @@ -30,6 +30,7 @@ function computeDateRange( case "month": from = new Date(year, month, 1); break; case "3months": from = new Date(year, month - 2, 1); break; case "6months": from = new Date(year, month - 5, 1); break; + case "year": from = new Date(year, 0, 1); break; case "12months": from = new Date(year, month - 11, 1); break; default: from = new Date(year, month, 1); break; } diff --git a/src/pages/ReportsPage.tsx b/src/pages/ReportsPage.tsx index 90d25c6..f185871 100644 --- a/src/pages/ReportsPage.tsx +++ b/src/pages/ReportsPage.tsx @@ -33,6 +33,7 @@ function computeDateRange( case "month": from = new Date(year, month, 1); break; case "3months": from = new Date(year, month - 2, 1); break; case "6months": from = new Date(year, month - 5, 1); break; + case "year": from = new Date(year, 0, 1); break; case "12months": from = new Date(year, month - 11, 1); break; default: from = new Date(year, month, 1); break; } diff --git a/src/shared/types/index.ts b/src/shared/types/index.ts index a952871..c585d22 100644 --- a/src/shared/types/index.ts +++ b/src/shared/types/index.ts @@ -247,7 +247,7 @@ export interface ImportReport { // --- Dashboard Types --- -export type DashboardPeriod = "month" | "3months" | "6months" | "12months" | "all" | "custom"; +export type DashboardPeriod = "month" | "3months" | "6months" | "year" | "12months" | "all" | "custom"; export interface DashboardSummary { totalCount: number;