[PR #3221] [MERGED] Refactor template logic: Part 1 - Extract and refactor the note handling logic #46563

Closed
opened 2026-04-26 08:36:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/3221
Author: @ACWalker
Created: 8/8/2024
Status: Merged
Merged: 8/13/2024
Merged by: @youngcw

Base: masterHead: refactor_goal_types


📝 Commits (3)

  • b097909 Extract out note template logic from goaltemplates.ts, refactor and add unit tests
  • b492f92 Merge branch 'master' into refactor_goal_types
  • c11b288 Merge branch 'master' into refactor_goal_types

📊 Changes

7 files changed (+496 additions, -115 deletions)

View changed files

📝 packages/loot-core/src/server/budget/goaltemplates.ts (+6 -115)
packages/loot-core/src/server/budget/statements.ts (+47 -0)
packages/loot-core/src/server/budget/template-notes.test.ts (+229 -0)
packages/loot-core/src/server/budget/template-notes.ts (+117 -0)
packages/loot-core/src/server/budget/types/templates.d.ts (+82 -0)
packages/loot-core/src/server/db/types.d.ts (+9 -0)
upcoming-release-notes/3221.md (+6 -0)

📄 Description

This PR is the first in a series aimed at refactoring the goal template logic. As raised in issue #1686, while the logic in goaltemplates.ts works nicely, it has become quite unwieldy, making it difficult to test and add new features to templates. The objective of this refactoring is to improve the maintainability and testability of this functionality, to hopefully accommodate future functionality. I will try these PRs as small as possible so they can be reviewed easier.

In this PR:

  • Extract out the note handling logic from the goaltemplates.ts into it's own template-notes.ts file.
  • Introduce typing where possible, and try and make the code more readable where possible (subjective so please let me know if it's not better!)
  • Add tests for the note handling logic in the template-notes.test.ts file.
  • Extract the related SQL into a statements.ts file, so these can easily be mocked in tests and be easily be reused going forward.

🔄 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/3221 **Author:** [@ACWalker](https://github.com/ACWalker) **Created:** 8/8/2024 **Status:** ✅ Merged **Merged:** 8/13/2024 **Merged by:** [@youngcw](https://github.com/youngcw) **Base:** `master` ← **Head:** `refactor_goal_types` --- ### 📝 Commits (3) - [`b097909`](https://github.com/actualbudget/actual/commit/b0979093fd95636761923ef72f79769f7fff842f) Extract out note template logic from goaltemplates.ts, refactor and add unit tests - [`b492f92`](https://github.com/actualbudget/actual/commit/b492f92181bc3ab9ec0f476ab6930b2e5f14845b) Merge branch 'master' into refactor_goal_types - [`c11b288`](https://github.com/actualbudget/actual/commit/c11b288b7305a2ce86d6cb48919790975bab2449) Merge branch 'master' into refactor_goal_types ### 📊 Changes **7 files changed** (+496 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/budget/goaltemplates.ts` (+6 -115) ➕ `packages/loot-core/src/server/budget/statements.ts` (+47 -0) ➕ `packages/loot-core/src/server/budget/template-notes.test.ts` (+229 -0) ➕ `packages/loot-core/src/server/budget/template-notes.ts` (+117 -0) ➕ `packages/loot-core/src/server/budget/types/templates.d.ts` (+82 -0) ➕ `packages/loot-core/src/server/db/types.d.ts` (+9 -0) ➕ `upcoming-release-notes/3221.md` (+6 -0) </details> ### 📄 Description This PR is the first in a series aimed at refactoring the goal template logic. As raised in issue #1686, while the logic in `goaltemplates.ts` works nicely, it has become quite unwieldy, making it difficult to test and add new features to templates. The objective of this refactoring is to improve the maintainability and testability of this functionality, to hopefully accommodate future functionality. I will try these PRs as small as possible so they can be reviewed easier. In this PR: - Extract out the note handling logic from the `goaltemplates.ts` into it's own `template-notes.ts` file. - Introduce typing where possible, and try and make the code more readable where possible (subjective so please let me know if it's not better!) - Add tests for the note handling logic in the `template-notes.test.ts` file. - Extract the related SQL into a `statements.ts` file, so these can easily be mocked in tests and be easily be reused going forward. --- <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-04-26 08:36:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#46563