Skip to content

[AI] Fix budget templates with a priority not allocating funds in tracking budgets - #8549

Merged
youngcw merged 5 commits into
masterfrom
fix-tracking-budget-template-priority
Jul 23, 2026
Merged

youngcw merged 5 commits into
masterfrom
fix-tracking-budget-template-priority

Conversation

@youngcw

@youngcw youngcw commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Description

Fix issue where the template code would see a 0 available funds value, thus making templates with priorities not budget anything.

Claude wrote the test

Related issue(s)

Fixes #8422

Testing

  • Open up a tracking budget
  • Turn on goal templates and then add some templates with prioritites
  • Budget some funds to an income category
  • Apply templates (this should apply, edge wont apply anything)

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I have read every line of this diff and can explain what each change does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 39 13.19 MB → 13.19 MB (-2.25 kB) -0.02%
loot-core 1 4.62 MB → 4.62 MB (+29 B) +0.00%
api 2 3.84 MB → 3.84 MB (+29 B) +0.00%
cli 1 8.02 MB 0%
crdt 1 11.16 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
39 13.19 MB → 13.19 MB (-2.25 kB) -0.02%
Changeset
File Δ Size
src/components/transactions/TransactionList.tsx 📉 -25 B (-0.19%) 12.96 kB → 12.93 kB
src/components/transactions/TransactionsTable.tsx 📉 -1.13 kB (-1.28%) 88.2 kB → 87.07 kB
src/components/accounts/Account.tsx 📉 -554 B (-1.35%) 40.13 kB → 39.59 kB
src/components/accounts/Header.tsx 📉 -575 B (-1.97%) 28.45 kB → 27.89 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller

Asset File Size % Changed
static/js/Value.js 2 MB → 2 MB (-1.15 kB) -0.06%
static/js/wide.js 270.84 kB → 269.73 kB (-1.1 kB) -0.41%

Unchanged

Asset File Size % Changed
static/js/index.js 1.55 MB 0%
static/js/AppliedFilters.js 35.51 kB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 762.13 kB 0%
static/js/ManageRules.js 68.85 kB 0%
static/js/PayeeRuleCountLabel.js 9.41 kB 0%
static/js/ReportRouter.js 1.2 MB 0%
static/js/ScheduleEditForm.js 140.4 kB 0%
static/js/SchedulesTable.js 170.95 kB 0%
static/js/TransactionEdit.js 107.62 kB 0%
static/js/TransactionList.js 79.07 kB 0%
static/js/bootstrapHyperFormula.js 302 B 0%
static/js/ca.js 171.84 kB 0%
static/js/chart-theme.js 670.14 kB 0%
static/js/client.js 452.05 kB 0%
static/js/da.js 95.93 kB 0%
static/js/de.js 179.3 kB 0%
static/js/en-GB.js 11.1 kB 0%
static/js/en.js 208.88 kB 0%
static/js/es.js 165.25 kB 0%
static/js/fr.js 166.78 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 152.74 kB 0%
static/js/narrow.js 330.95 kB 0%
static/js/nb-NO.js 136.65 kB 0%
static/js/nl.js 144.95 kB 0%
static/js/pl.js 137.12 kB 0%
static/js/pt-BR.js 179.81 kB 0%
static/js/ru.js 142.5 kB 0%
static/js/th.js 165.62 kB 0%
static/js/theme.js 31.1 kB 0%
static/js/uk.js 200.9 kB 0%
static/js/useDateFormat.js 2.91 MB 0%
static/js/useFormatList.js 9.31 kB 0%
static/js/useTransactionBatchActions.js 9.77 kB 0%
static/js/workbox-window.prod.es5.js 7.21 kB 0%
static/js/zh-Hans.js 107.6 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.62 MB → 4.62 MB (+29 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/budget/goal-template.ts 📈 +29 B (+0.39%) 7.19 kB → 7.22 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
kcab.worker.DyG6YkPb.js 0 B → 4.62 MB (+4.62 MB) -

Removed

Asset File Size % Changed
kcab.worker.CLKxGEvc.js 4.62 MB → 0 B (-4.62 MB) -100%

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged
No assets were unchanged


api

Total

Files count Total bundle size % Changed
2 3.84 MB → 3.84 MB (+29 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/budget/goal-template.ts 📈 +29 B (+0.40%) 7.02 kB → 7.04 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
index.js 3.84 MB → 3.84 MB (+29 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
models.js 0 B 0%

cli

Total

Files count Total bundle size % Changed
1 8.02 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 8.02 MB 0%

crdt

Total

Files count Total bundle size % Changed
1 11.16 kB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
index.js 11.16 kB 0%

…cking budgets

Tracking budgets never define a `to-budget` sheet cell (only envelope budgets
do), so the priority-tier engine always saw $0 available and clamped every
priority>0 template to 0. Seed the pool from `total-saved` instead when in
tracking mode, since it's the structural analog (budgeted income minus
budgeted expenses) and preserves genuine priority-tier competition rather
than disabling the clamp outright.

Fixes #8422
@actual-github-bot actual-github-bot Bot changed the title [AI] Fix budget templates with a priority not allocating funds in tracking budgets [WIP] [AI] Fix budget templates with a priority not allocating funds in tracking budgets Jul 22, 2026
@netlify

netlify Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 7bb37c5
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6a62750016d3830008f64a93
😎 Deploy Preview https://deploy-preview-8549.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@youngcw youngcw changed the title [WIP] [AI] Fix budget templates with a priority not allocating funds in tracking budgets [AI] Fix budget templates with a priority not allocating funds in tracking budgets Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Tracking budget template priority

Layer / File(s) Summary
Tracking funding source
packages/loot-core/src/server/budget/goal-template.ts
computeTemplates uses total-saved for tracking budgets and to-budget otherwise.
Priority allocation regression coverage
packages/loot-core/src/server/budget/goal-template.test.ts, upcoming-release-notes/fix-tracking-budget-template-priority.md
Tests cover funding from total-saved and proportional clamping across priorities; a bugfix release note describes the tracking-budget allocation issue.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: matissjanis, matt-fidd

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main fix for priority templates in tracking budgets.
Description check ✅ Passed The description matches the change and explains the tracking-budget priority allocation bug.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-tracking-budget-template-priority

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/loot-core/src/server/budget/goal-template.test.ts (1)

488-528: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use descriptive category fixture names.

Rename cat1/cat2 and cats/c to domain names such as groceriesCategory, rentCategory, and categories to keep the multi-category allocation scenario readable. As per coding guidelines, use descriptive variable names with auxiliary verbs where applicable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/loot-core/src/server/budget/goal-template.test.ts` around lines 488
- 528, Rename the category fixtures and related parameters in
setupAqlMultiCategory to descriptive domain names: use groceriesCategory and
rentCategory instead of cat1 and cat2, categories instead of cats, and a
descriptive name such as category instead of c in callbacks. Update all
references consistently without changing the test behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/loot-core/src/server/budget/goal-template.test.ts`:
- Around line 488-528: Rename the category fixtures and related parameters in
setupAqlMultiCategory to descriptive domain names: use groceriesCategory and
rentCategory instead of cat1 and cat2, categories instead of cats, and a
descriptive name such as category instead of c in callbacks. Update all
references consistently without changing the test behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ae68da0-04eb-453f-bd2a-35a3d88e5d04

📥 Commits

Reviewing files that changed from the base of the PR and between 71d802e and 5855ec4.

📒 Files selected for processing (3)
  • packages/loot-core/src/server/budget/goal-template.test.ts
  • packages/loot-core/src/server/budget/goal-template.ts
  • upcoming-release-notes/fix-tracking-budget-template-priority.md

@matt-fidd matt-fidd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch that hid for a while

@youngcw
youngcw added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 23, 2026
@youngcw
youngcw added this pull request to the merge queue Jul 23, 2026
Merged via the queue into master with commit 6019bf5 Jul 23, 2026
42 checks passed
@youngcw
youngcw deleted the fix-tracking-budget-template-priority branch July 23, 2026 20:22
RafaelEspino pushed a commit to RafaelEspino/actual that referenced this pull request Oct 28, 2026
…cking budgets (actualbudget#8549)

* [AI] Fix budget templates with a priority not allocating funds in tracking budgets

Tracking budgets never define a `to-budget` sheet cell (only envelope budgets
do), so the priority-tier engine always saw $0 available and clamped every
priority>0 template to 0. Seed the pool from `total-saved` instead when in
tracking mode, since it's the structural analog (budgeted income minus
budgeted expenses) and preserves genuine priority-tier competition rather
than disabling the clamp outright.

Fixes actualbudget#8422

* Trigger Build

* Trigger Build

* Trigger Build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Budget templates in tracking budget fail when priority > 0, but work consistently with priority 0

2 participants