[PR #3754] [MERGED] ♻️ make templates classy and replace 🍝 code #5039

Closed
opened 2026-02-28 21:05:01 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/3754
Author: @youngcw
Created: 10/30/2024
Status: Merged
Merged: 11/4/2024
Merged by: @youngcw

Base: masterHead: youngcw/classy-templates


📝 Commits (10+)

  • f0d10db by check
  • 5ee7257 minor changes and TS class migration
  • b8d19f2 good starting point
  • 5a28390 very basic testing
  • 9b1aef1 Merge branch 'youngcw/classy-templates' of github.com:actualbudget/actual into youngcw/classy-templates
  • 8c57d53 fix
  • 1821c13 basic overwrite of simple templates working
  • 32d471c mostly working. By and schedule don't work
  • 7bb4dfa Merge branch 'youngcw/classy-templates' of github.com:actualbudget/actual into youngcw/classy-templates
  • 9553e7b some cleanup, better async

📊 Changes

22 files changed (+745 additions, -1834 deletions)

View changed files

packages/loot-core/src/server/budget/categoryTemplate.ts (+540 -0)
📝 packages/loot-core/src/server/budget/goal-template.pegjs (+21 -16)
packages/loot-core/src/server/budget/goals/goalsAverage.test.ts (+0 -89)
packages/loot-core/src/server/budget/goals/goalsAverage.ts (+0 -30)
packages/loot-core/src/server/budget/goals/goalsBy.test.ts (+0 -134)
packages/loot-core/src/server/budget/goals/goalsBy.ts (+0 -49)
packages/loot-core/src/server/budget/goals/goalsCopy.ts (+0 -38)
packages/loot-core/src/server/budget/goals/goalsPercentage.test.ts (+0 -180)
packages/loot-core/src/server/budget/goals/goalsPercentage.ts (+0 -56)
packages/loot-core/src/server/budget/goals/goalsRemainder.test.ts (+0 -79)
packages/loot-core/src/server/budget/goals/goalsRemainder.ts (+0 -47)
packages/loot-core/src/server/budget/goals/goalsSimple.test.ts (+0 -147)
packages/loot-core/src/server/budget/goals/goalsSimple.ts (+0 -33)
packages/loot-core/src/server/budget/goals/goalsSpend.test.ts (+0 -105)
packages/loot-core/src/server/budget/goals/goalsSpend.ts (+0 -53)
packages/loot-core/src/server/budget/goals/goalsWeek.test.ts (+0 -124)
packages/loot-core/src/server/budget/goals/goalsWeek.ts (+0 -37)
📝 packages/loot-core/src/server/budget/goalsSchedule.test.ts (+7 -7)
📝 packages/loot-core/src/server/budget/goalsSchedule.ts (+8 -7)
📝 packages/loot-core/src/server/budget/goaltemplates.ts (+156 -602)

...and 2 more files

📄 Description

An attempt to rewrite the goal template processing to not be so messy. Im moving a lot of the functions into a class that will be used for each category and that way all the calculations can stay local and have minimal variables passed around. There will still be level above this so that things that require some checks of the full budget can still be done ex. balances at priority levels, remainder amounts, recapturing funds from limits, etc

This also should hopefully make #1686 easier. While also making future hooks into goals be easier to do. For example showing changes before applying, calculating full amounts for planning, etc.

This changes the following:

  • Adds frequency modifiers to limits. See #3714 for details. Resolves #3711
  • Changes limits to only run once per category, not per priority level
  • adjusts the percent of available funds template. Resolves #2437
  • hopefully fixes #2741 by only writing once and not every priority level
  • fixes #2405 by always trimming the schedule names
  • I made the validations more strict and will throw more errors

Future:
Add tests to all the template processing. I need to remove the existing ones for now to get CI/CD happy and the old tests wont work anymore with the new structure.

The schedule template is a beast. I just used the existing function in its own file since it is so involved. Maybe that could be reviewed at some point to see if we can simplify that. If sub categories ever get added limiting some templates to one per category/sub-category would be good.

Finish the runAll method for use with running a single category, all priorities all at once. Could maybe be used for applying a single category, or for future hooks like gathering full budget amounts for planning.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/3754 **Author:** [@youngcw](https://github.com/youngcw) **Created:** 10/30/2024 **Status:** ✅ Merged **Merged:** 11/4/2024 **Merged by:** [@youngcw](https://github.com/youngcw) **Base:** `master` ← **Head:** `youngcw/classy-templates` --- ### 📝 Commits (10+) - [`f0d10db`](https://github.com/actualbudget/actual/commit/f0d10db0602a3c3d5d6dd4be3977780e646ee547) by check - [`5ee7257`](https://github.com/actualbudget/actual/commit/5ee72573fa93682554f778e335ec593f3b784e1f) minor changes and TS class migration - [`b8d19f2`](https://github.com/actualbudget/actual/commit/b8d19f2c87fb1bd8254242b55d986726b340c813) good starting point - [`5a28390`](https://github.com/actualbudget/actual/commit/5a28390cb8e9230ef098793c261527fa83b5fa16) very basic testing - [`9b1aef1`](https://github.com/actualbudget/actual/commit/9b1aef15e3ebf25fe2612f86db50b93f36adb7e3) Merge branch 'youngcw/classy-templates' of github.com:actualbudget/actual into youngcw/classy-templates - [`8c57d53`](https://github.com/actualbudget/actual/commit/8c57d530ed29a21587ffa90b0147310cd889b4ef) fix - [`1821c13`](https://github.com/actualbudget/actual/commit/1821c13d14b0ec8b22108627b6989a8be834d867) basic overwrite of simple templates working - [`32d471c`](https://github.com/actualbudget/actual/commit/32d471c6d489862f7026a2f09a4ce7f5f1f94ba7) mostly working. By and schedule don't work - [`7bb4dfa`](https://github.com/actualbudget/actual/commit/7bb4dfafc1f508e779087e00b3399859d57fa3d3) Merge branch 'youngcw/classy-templates' of github.com:actualbudget/actual into youngcw/classy-templates - [`9553e7b`](https://github.com/actualbudget/actual/commit/9553e7b6a4d983962d7b1719a0f6cca60c3e69a2) some cleanup, better async ### 📊 Changes **22 files changed** (+745 additions, -1834 deletions) <details> <summary>View changed files</summary> ➕ `packages/loot-core/src/server/budget/categoryTemplate.ts` (+540 -0) 📝 `packages/loot-core/src/server/budget/goal-template.pegjs` (+21 -16) ➖ `packages/loot-core/src/server/budget/goals/goalsAverage.test.ts` (+0 -89) ➖ `packages/loot-core/src/server/budget/goals/goalsAverage.ts` (+0 -30) ➖ `packages/loot-core/src/server/budget/goals/goalsBy.test.ts` (+0 -134) ➖ `packages/loot-core/src/server/budget/goals/goalsBy.ts` (+0 -49) ➖ `packages/loot-core/src/server/budget/goals/goalsCopy.ts` (+0 -38) ➖ `packages/loot-core/src/server/budget/goals/goalsPercentage.test.ts` (+0 -180) ➖ `packages/loot-core/src/server/budget/goals/goalsPercentage.ts` (+0 -56) ➖ `packages/loot-core/src/server/budget/goals/goalsRemainder.test.ts` (+0 -79) ➖ `packages/loot-core/src/server/budget/goals/goalsRemainder.ts` (+0 -47) ➖ `packages/loot-core/src/server/budget/goals/goalsSimple.test.ts` (+0 -147) ➖ `packages/loot-core/src/server/budget/goals/goalsSimple.ts` (+0 -33) ➖ `packages/loot-core/src/server/budget/goals/goalsSpend.test.ts` (+0 -105) ➖ `packages/loot-core/src/server/budget/goals/goalsSpend.ts` (+0 -53) ➖ `packages/loot-core/src/server/budget/goals/goalsWeek.test.ts` (+0 -124) ➖ `packages/loot-core/src/server/budget/goals/goalsWeek.ts` (+0 -37) 📝 `packages/loot-core/src/server/budget/goalsSchedule.test.ts` (+7 -7) 📝 `packages/loot-core/src/server/budget/goalsSchedule.ts` (+8 -7) 📝 `packages/loot-core/src/server/budget/goaltemplates.ts` (+156 -602) _...and 2 more files_ </details> ### 📄 Description An attempt to rewrite the goal template processing to not be so messy. Im moving a lot of the functions into a class that will be used for each category and that way all the calculations can stay local and have minimal variables passed around. There will still be level above this so that things that require some checks of the full budget can still be done ex. balances at priority levels, remainder amounts, recapturing funds from limits, etc This also should hopefully make #1686 easier. While also making future hooks into goals be easier to do. For example showing changes before applying, calculating full amounts for planning, etc. This changes the following: * Adds frequency modifiers to limits. See #3714 for details. Resolves #3711 * Changes limits to only run once per category, not per priority level * adjusts the percent of available funds template. Resolves #2437 * hopefully fixes #2741 by only writing once and not every priority level * fixes #2405 by always trimming the schedule names * I made the validations more strict and will throw more errors Future: Add tests to all the template processing. I need to remove the existing ones for now to get CI/CD happy and the old tests wont work anymore with the new structure. The schedule template is a beast. I just used the existing function in its own file since it is so involved. Maybe that could be reviewed at some point to see if we can simplify that. If sub categories ever get added limiting some templates to one per category/sub-category would be good. Finish the runAll method for use with running a single category, all priorities all at once. Could maybe be used for applying a single category, or for future hooks like gathering full budget amounts for planning. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-02-28 21:05:01 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#5039