Files
actual/upcoming-release-notes/api-category-template.md
e67bb684e2 [AI] Add API methods to budget a category from its templates (#9260)
* [AI] Add API methods to budget a category from its templates

applyCategoryTemplate runs the same budget/apply-single-template handler as
the "Overwrite with template" item in a category's budget menu.

getCategoryTemplateAmount runs budget/dry-run-category-template, which the
budget automations editor uses for its preview. It reads the category's saved
templates rather than the ones open in the editor.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* [AI] Throw from the template dry run when the templates fail validation

dryRunCategoryTemplate ignored the errors computeTemplates collects, so a
category whose templates fail validation, for example with two #goal lines,
was previewed as 0. It now throws with those errors. The automations editor
already catches a failed dry run. getCategoryTemplateAmount rethrows the
error as an APIError.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* [AI] Return the template dry run's validation errors instead of throwing

Throwing from dryRunCategoryTemplate surfaced as an internal error in the
budget automations editor, for example when "Cover schedule" is picked
before a schedule is chosen. The dry run now returns the errors
computeTemplates collects alongside the amounts, and
getCategoryTemplateAmount throws an APIError when there are any.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* [AI] Reject category templates that fail to parse in the template API methods

A #template line that fails to parse is stored as an error template, which
the template runner skips, so applying could budget 0 and report success.
applyCategoryTemplate and getCategoryTemplateAmount now throw with the
failing lines instead. The UI's apply paths are left unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* [AI] Format the template API test

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* [AI] Read category templates for the template API without storing them

The template preview parsed the category's note by storing its templates in goal_def first, so a read wrote to the budget. It now parses the note in memory, and applying stores the templates once, inside apply-single-template.

* [AI] Type the template API test's goal_def query

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 02:02:50 +00:00

168 B

category, authors
category authors
Enhancements
nowak-mariusz

Add applyCategoryTemplate and getCategoryTemplateAmount to the API to budget a category from its templates