From 4ce5e2fd075434bbe8f03f6c5983896a74c4cde2 Mon Sep 17 00:00:00 2001 From: Matt Fiddaman Date: Wed, 18 Dec 2024 21:55:23 +0000 Subject: [PATCH] Prevent schedules with null amounts from crashing the app (#3958) * test * note * add comment --- packages/loot-core/src/shared/schedules.ts | 4 ++++ upcoming-release-notes/3958.md | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 upcoming-release-notes/3958.md diff --git a/packages/loot-core/src/shared/schedules.ts b/packages/loot-core/src/shared/schedules.ts index b1b0b991160..78f6b82e947 100644 --- a/packages/loot-core/src/shared/schedules.ts +++ b/packages/loot-core/src/shared/schedules.ts @@ -276,6 +276,10 @@ export function getScheduledAmount( amount: number | { num1: number; num2: number }, inverse: boolean = false, ): number { + // this check is temporary, and required at the moment as a schedule rule + // allows the amount condition to be deleted which causes a crash + if (amount == null) return 0; + if (typeof amount === 'number') { return inverse ? -amount : amount; } diff --git a/upcoming-release-notes/3958.md b/upcoming-release-notes/3958.md new file mode 100644 index 00000000000..13a7478f90b --- /dev/null +++ b/upcoming-release-notes/3958.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [matt-fidd] +--- + +Prevent schedules with null amounts from crashing the app