Skip to content

A local-first personal finance app

Fix schedule upcoming length years off-by-1 calculation (#6437)

Ani07-05329d884b9b11
diff --git a/packages/loot-core/src/shared/schedules.test.ts b/packages/loot-core/src/shared/schedules.test.ts
index ac4743a899..afae41d1bf 100644
--- a/packages/loot-core/src/shared/schedules.test.ts
+++ b/packages/loot-core/src/shared/schedules.test.ts
@@ -434,6 +434,9 @@ describe('schedules', () => {
['5-week', 35, '2017-01-01'],
['3-month', 91, '2017-01-01'],
['4-year', 1462, '2017-01-01'],
+ ['1-year', 366, '2017-06-15'], // Test year from mid-year (Jun 1, 2017 to Jun 1, 2018 + 1)
+ ['1-year', 367, '2019-06-15'], // Test year from mid-year with leap year 2020
+ ['2-year', 731, '2017-06-15'], // Test 2 years from mid-year (Jun 1, 2017 to Jun 1, 2019 + 1)
])(
'value of %s on returns %i days on %s',
(value: string, expected: number, date: string) => {
diff --git a/packages/loot-core/src/shared/schedules.ts b/packages/loot-core/src/shared/schedules.ts
index dc9ffcba62..69c81a2151 100644
--- a/packages/loot-core/src/shared/schedules.ts
+++ b/packages/loot-core/src/shared/schedules.ts
@@ -446,7 +446,7 @@ export function getUpcomingDays(
const future = monthUtils.addMonths(today, value);
return monthUtils.differenceInCalendarDays(future, month) + 1;
case 'year':
- const futureYear = monthUtils.addYears(today, value);
+ const futureYear = monthUtils.addMonths(today, value * 12);
return monthUtils.differenceInCalendarDays(futureYear, month) + 1;
default:
return 7;
diff --git a/upcoming-release-notes/6437.md b/upcoming-release-notes/6437.md
new file mode 100644
index 0000000000..ae751d502c
--- /dev/null
+++ b/upcoming-release-notes/6437.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: []
+---
+
+Fix schedule upcoming length years off-by-1 calculation