From fe033d68cf2026db7875e431fc0f3745a3842e67 Mon Sep 17 00:00:00 2001
From: shall0pass <20625555+shall0pass@users.noreply.github.com>
Date: Thu, 3 Aug 2023 10:13:14 -0500
Subject: [PATCH] Goals:  Allow up to to consider spent values (#1448)

Resolves https://github.com/actualbudget/actual/issues/1443
---
 packages/loot-core/src/server/budget/goaltemplates.ts | 4 ++--
 upcoming-release-notes/1448.md                        | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 upcoming-release-notes/1448.md

diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts
index 6ed7cd47c..06a5ef21d 100644
--- a/packages/loot-core/src/server/budget/goaltemplates.ts
+++ b/packages/loot-core/src/server/budget/goaltemplates.ts
@@ -714,8 +714,8 @@ async function applyCategoryTemplate(
   if (limit != null) {
     if (hold && balance > limit) {
       to_budget = 0;
-    } else if (to_budget + last_month_balance > limit) {
-      to_budget = limit - last_month_balance;
+    } else if (to_budget + balance > limit) {
+      to_budget = limit - balance;
     }
   }
   if (
diff --git a/upcoming-release-notes/1448.md b/upcoming-release-notes/1448.md
new file mode 100644
index 000000000..c3b522953
--- /dev/null
+++ b/upcoming-release-notes/1448.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [shall0pass]
+---
+
+Goals: Fix 'up to' calculation to include current month spending
\ No newline at end of file
-- 
GitLab