Skip to content

A local-first personal finance app

Goals: Up To Template calculation with negative category balance (#2535)

shall0pass1dd1c188d624
diff --git a/packages/loot-core/src/server/budget/goals/goalsSimple.ts b/packages/loot-core/src/server/budget/goals/goalsSimple.ts
index ae3befaab4..eec6e96249 100644
--- a/packages/loot-core/src/server/budget/goals/goalsSimple.ts
+++ b/packages/loot-core/src/server/budget/goals/goalsSimple.ts
@@ -8,6 +8,7 @@ export async function goalsSimple(
limit,
hold,
to_budget,
+ last_month_balance,
) {
// simple has 'monthly' and/or 'limit' params
if (template.limit != null) {
@@ -25,7 +26,7 @@ export async function goalsSimple(
const monthly = amountToInteger(template.monthly);
increment = monthly;
} else {
- increment = limit;
+ increment = limit - last_month_balance;
}
to_budget += increment;
return { to_budget, errors, limit, limitCheck, hold };
diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts
index 0d94aa7775..110a148706 100644
--- a/packages/loot-core/src/server/budget/goaltemplates.ts
+++ b/packages/loot-core/src/server/budget/goaltemplates.ts
@@ -513,6 +513,7 @@ async function applyCategoryTemplate(
limit,
hold,
to_budget,
+ last_month_balance,
);
to_budget = goalsReturn.to_budget;
errors = goalsReturn.errors;
diff --git a/upcoming-release-notes/2535.md b/upcoming-release-notes/2535.md
new file mode 100644
index 0000000000..204a85df8e
--- /dev/null
+++ b/upcoming-release-notes/2535.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [shall0pass]
+---
+
+Goal templates: Allow budgeting to a full category balance when using 'up to' and a negative category rollover balance.