diff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png index abce1a3ed3..adb77193e7 100644 Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png index a245ec22b4..b9a7b17203 100644 Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png index 7638d9fcbd..9309286711 100644 Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png index 1ba169dabf..8184a47309 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-1-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-2-chromium-linux.png index c4e90697df..48429fc10b 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-2-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-3-chromium-linux.png index 84d01ae57f..4fd3a09aa7 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-3-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-and-cash-flow-reports-3-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-1-chromium-linux.png index 3573fd030c..06ab20fda4 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-1-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-2-chromium-linux.png index ea7791ed19..e4cbe213b9 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-2-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-3-chromium-linux.png index 6d75ef6e4b..5e253808c2 100644 Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-3-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-loads-net-worth-graph-and-checks-visuals-3-chromium-linux.png differ diff --git a/packages/desktop-client/src/components/reports/spreadsheets/net-worth-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/net-worth-spreadsheet.ts index fd5aceab38..e66bd0622f 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/net-worth-spreadsheet.ts +++ b/packages/desktop-client/src/components/reports/spreadsheets/net-worth-spreadsheet.ts @@ -40,8 +40,42 @@ export function createSpreadsheet( }); const conditionsOpKey = conditionsOp === 'or' ? '$or' : '$and'; - // Convert dates to ensure we have the full range. Then clamp end date to avoid future projections - const startDate = monthUtils.firstDayOfMonth(start); + // Go back exactly one interval before the selected range start + // to get the correct starting balance for the first period + const rangeStart = d.parseISO(monthUtils.firstDayOfMonth(start)); + let startDate: string; + if (interval === 'Daily') { + startDate = monthUtils.dayFromDate(d.subDays(rangeStart, 1)); + } else if (interval === 'Weekly') { + startDate = monthUtils.weekFromDate( + d.subDays(rangeStart, 1), + firstDayOfWeekIdx, + ); + } else { + // Monthly or yearly + startDate = monthUtils.firstDayOfMonth(monthUtils.prevMonth(start)); + } + + // If the earliest transaction is on or after the first day of the start + // month, the prior period lookback would be empty (all zeros). Skip it to + // avoid rendering an empty data point. + const earliestTransaction = await send('get-earliest-transaction'); + if ( + earliestTransaction && + earliestTransaction.date >= monthUtils.firstDayOfMonth(start) + ) { + if (interval === 'Daily') { + startDate = earliestTransaction.date; + } else if (interval === 'Weekly') { + startDate = monthUtils.weekFromDate( + earliestTransaction.date, + firstDayOfWeekIdx, + ); + } else { + // Monthly or Yearly + startDate = monthUtils.firstDayOfMonth(start); + } + } // Start with the provided end-of-month date, then adjust for current context let endDate = monthUtils.lastDayOfMonth(end); @@ -193,6 +227,7 @@ function recalculate( ); let hasNegative = false; + let startNetWorth = 0; let endNetWorth = 0; let lowestNetWorth: number | null = null; let highestNetWorth: number | null = null; @@ -242,6 +277,9 @@ function recalculate( const change = last ? total - last.y : total - priorPeriodNetWorth; + if (arr.length === 0) { + startNetWorth = total; + } endNetWorth = total; // Use standardized format from ReportOptions @@ -293,7 +331,7 @@ function recalculate( end: endDate, }, netWorth: endNetWorth, - totalChange: endNetWorth - priorPeriodNetWorth, + totalChange: endNetWorth - startNetWorth, lowestNetWorth, highestNetWorth, accounts: data diff --git a/upcoming-release-notes/7296.md b/upcoming-release-notes/7296.md new file mode 100644 index 0000000000..1b98d066f7 --- /dev/null +++ b/upcoming-release-notes/7296.md @@ -0,0 +1,6 @@ +--- +category: Bugfixes +authors: [emiltb] +--- + +Fix Net Worth graph showing a time-interval less than specified