From d9944c43756609d170931ad4fc991b77a25069c9 Mon Sep 17 00:00:00 2001 From: shall0pass <20625555+shall0pass@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:25:44 -0500 Subject: [PATCH 1/3] check for null carryover --- .../loot-core/src/server/budget/cleanup-template.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/loot-core/src/server/budget/cleanup-template.ts b/packages/loot-core/src/server/budget/cleanup-template.ts index 48e520c0e17..726b3aa3a22 100644 --- a/packages/loot-core/src/server/budget/cleanup-template.ts +++ b/packages/loot-core/src/server/budget/cleanup-template.ts @@ -57,6 +57,18 @@ async function processCleanup(month: string): Promise { [db_month, categoryId], ); + if (carryover === null) { + await setBudget({ + category: category.id, + month, + amount: budgeted, + }); + carryover = await db.first( + `SELECT carryover FROM zero_budgets WHERE month = ? and category = ?`, + [db_month, categoryId], + ); + } + if ( balance < 0 && Math.abs(balance) <= budgetAvailable && From 743625a9a74d86a76cd3e30a5e7c2041398194e9 Mon Sep 17 00:00:00 2001 From: shall0pass <20625555+shall0pass@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:32:47 -0500 Subject: [PATCH 2/3] release note --- upcoming-release-notes/1750.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/1750.md diff --git a/upcoming-release-notes/1750.md b/upcoming-release-notes/1750.md new file mode 100644 index 00000000000..cb2f399c5e1 --- /dev/null +++ b/upcoming-release-notes/1750.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [shall0pass] +--- + +End of month cleanup - fixed condition that caused an error with null carryover value From 420548a0e4b4a3f1a5968c9ebd1e757555d7cb2e Mon Sep 17 00:00:00 2001 From: shall0pass <20625555+shall0pass@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:28:14 -0500 Subject: [PATCH 3/3] simplify logic --- .../loot-core/src/server/budget/cleanup-template.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/loot-core/src/server/budget/cleanup-template.ts b/packages/loot-core/src/server/budget/cleanup-template.ts index 726b3aa3a22..941b40da379 100644 --- a/packages/loot-core/src/server/budget/cleanup-template.ts +++ b/packages/loot-core/src/server/budget/cleanup-template.ts @@ -58,15 +58,7 @@ async function processCleanup(month: string): Promise { ); if (carryover === null) { - await setBudget({ - category: category.id, - month, - amount: budgeted, - }); - carryover = await db.first( - `SELECT carryover FROM zero_budgets WHERE month = ? and category = ?`, - [db_month, categoryId], - ); + carryover = { carryover: 0 }; } if (