Skip to content

A local-first personal finance app

Fix detection of crossover point for low expense months (#6371)

Jonathon Jongsma9c9a98844f6b
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Line-Graph-and-checks-the-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Line-Graph-and-checks-the-visuals-1-chromium-linux.png
index bcfe8f26fd..2adfda1334 100644
Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Line-Graph-and-checks-the-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Line-Graph-and-checks-the-visuals-1-chromium-linux.png differ
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/crossover-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/crossover-spreadsheet.ts
index b722ee0cc1..e385a803d8 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/crossover-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/crossover-spreadsheet.ts
@@ -249,11 +249,10 @@ function recalculate(
lastBalance = balance;
lastExpense = spend;
- if (crossoverIndex == null && Math.round(monthlyIncome) >= spend) {
- crossoverIndex = idx;
- } else if (crossoverIndex != null && Math.round(monthlyIncome) < spend) {
- crossoverIndex = null;
- }
+ // Note: We don't check for crossover in historical data to avoid triggering
+ // a crossover detection when expenses drop below the investment income for
+ // a short time. Crossover is determined based on projected expenses, not
+ // actual historical expenses.
});
// If estimatedReturn provided, project future months until investment income exceeds expenses
@@ -295,7 +294,7 @@ function recalculate(
}
}
- if (months.length > 0 && crossoverIndex == null) {
+ if (months.length > 0) {
// If no explicit return provided, use the calculated default
if (monthlyReturn == null) {
// not quite right. Need a better approximation
diff --git a/upcoming-release-notes/6371.md b/upcoming-release-notes/6371.md
new file mode 100644
index 0000000000..cb5ade7c34
--- /dev/null
+++ b/upcoming-release-notes/6371.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [jonner]
+---
+
+Fix incorrect detection of crossover point for low expense months