From 738a8cda7c19576613b50ce29a4126fd6963f52c Mon Sep 17 00:00:00 2001 From: tabedzki <35670232+tabedzki@users.noreply.github.com> Date: Fri, 6 Feb 2026 10:58:31 -0500 Subject: [PATCH] Fix date range calculation in BudgetAnalysisCard (#6875) * fix: corrected date range calculation in BudgetAnalysisCard using calculateTimeRange * add release note * fix: ensure correct date formatting in BudgetAnalysisCard for start and end dates * fix: rename release note file --- .../reports/reports/BudgetAnalysisCard.tsx | 15 ++++++--------- upcoming-release-notes/6875.md | 6 ++++++ 2 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 upcoming-release-notes/6875.md diff --git a/packages/desktop-client/src/components/reports/reports/BudgetAnalysisCard.tsx b/packages/desktop-client/src/components/reports/reports/BudgetAnalysisCard.tsx index 791521ba62..2fbfafbaf6 100644 --- a/packages/desktop-client/src/components/reports/reports/BudgetAnalysisCard.tsx +++ b/packages/desktop-client/src/components/reports/reports/BudgetAnalysisCard.tsx @@ -16,6 +16,7 @@ import { BudgetAnalysisGraph } from '@desktop-client/components/reports/graphs/B import { LoadingIndicator } from '@desktop-client/components/reports/LoadingIndicator'; import { ReportCard } from '@desktop-client/components/reports/ReportCard'; import { ReportCardName } from '@desktop-client/components/reports/ReportCardName'; +import { calculateTimeRange } from '@desktop-client/components/reports/reportRanges'; import { createBudgetAnalysisSpreadsheet } from '@desktop-client/components/reports/spreadsheets/budget-analysis-spreadsheet'; import { useReport } from '@desktop-client/components/reports/useReport'; import { useWidgetCopyMenu } from '@desktop-client/components/reports/useWidgetCopyMenu'; @@ -53,15 +54,11 @@ export function BudgetAnalysisCard({ mode: 'sliding-window' as const, }; - // Calculate date range - let startDate = timeFrame.start + '-01'; - let endDate = monthUtils.getMonthEnd(timeFrame.end + '-01'); - - if (timeFrame.mode === 'sliding-window') { - const currentMonth = monthUtils.currentMonth(); - startDate = monthUtils.subMonths(currentMonth, 5) + '-01'; - endDate = monthUtils.getMonthEnd(currentMonth + '-01'); - } + const [startMonth, endMonth] = calculateTimeRange(timeFrame); + const startDate = monthUtils.monthFromDate(startMonth) + '-01'; + const endDate = monthUtils.getMonthEnd( + monthUtils.monthFromDate(endMonth) + '-01', + ); const getGraphData = useMemo(() => { return createBudgetAnalysisSpreadsheet({ diff --git a/upcoming-release-notes/6875.md b/upcoming-release-notes/6875.md new file mode 100644 index 0000000000..ba255b98d0 --- /dev/null +++ b/upcoming-release-notes/6875.md @@ -0,0 +1,6 @@ +--- +category: Bugfixes +authors: [tabedzki] +--- + +Budget Analysis Fix: correct date range calculation for card view