[PR #2102] [MERGED] [Maintenence] Refactor Goals Schedule file #11174

Closed
opened 2026-04-10 20:53:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/2102
Author: @shall0pass
Created: 12/18/2023
Status: Merged
Merged: 1/7/2024
Merged by: @shall0pass

Base: masterHead: schedules_refactor


📝 Commits (10+)

📊 Changes

2 files changed (+166 additions, -135 deletions)

View changed files

📝 packages/loot-core/src/server/budget/goals/goalsSchedule.ts (+160 -135)
upcoming-release-notes/2102.md (+6 -0)

📄 Description

This is an attempt to simplify the schedules file by breaking out the logic in separate functions and hopefully squashing a few bugs in the process. I think this is a little easier to follow than the currently written method of nested if-else logic and will hopefully be easier to debug in the future. The calculation method remains the same, so hopefully there are no regressions 🤞.

One possible gotcha is the way the schedule templates are now filtered. It is possible that a schedule could end up in both the sinkingFund and full template arrays. I haven't seen it happen in any of the iterations I've tried so far but I may have missed a situation.

Believed to fixed:

  1. When placing a non-repeating schedule into the future, the schedule template would not budget.
  2. Monthly recurring schedules would sometimes have non-expected values.

@jfdoming You added startDate and started variables in #1899. I removed them because it was causing issue 1 above. Is there a schedule condition I need to check that I'm overlooking? It's simply commented for now so it's easy to turn back on.

This is an attempt at a flow chart for all of the logic happening in this file. 
mermaid-1702930808136


🔄 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/2102 **Author:** [@shall0pass](https://github.com/shall0pass) **Created:** 12/18/2023 **Status:** ✅ Merged **Merged:** 1/7/2024 **Merged by:** [@shall0pass](https://github.com/shall0pass) **Base:** `master` ← **Head:** `schedules_refactor` --- ### 📝 Commits (10+) - [`14802ae`](https://github.com/actualbudget/actual/commit/14802ae84c67cbe755aeb4e04866dbab455c1650) refactor pass 1 - [`236cc44`](https://github.com/actualbudget/actual/commit/236cc44dbeb04df608ab880c9b185a41fe5686b3) refactor pass 2 - [`11e7cfc`](https://github.com/actualbudget/actual/commit/11e7cfc949a8eccc8e39a676e0ac4545940c609f) Merge branch 'actualbudget:master' into schedules_refactor - [`4f062cc`](https://github.com/actualbudget/actual/commit/4f062ccaed2f67010c45f54a3fc8af889ea00a84) refactor pass 3 - [`79701aa`](https://github.com/actualbudget/actual/commit/79701aa853a6e7713ff6ccc5399e0c0ab94f5fd6) commented out startDate - [`e763e16`](https://github.com/actualbudget/actual/commit/e763e1677d542f253698139f56be99d6fea8c9d7) remove console logging - [`9ef9509`](https://github.com/actualbudget/actual/commit/9ef9509a8c340f53d0daf6d8d6f852c99adb22ed) release note - [`accb7d3`](https://github.com/actualbudget/actual/commit/accb7d381ba66b6818bfc1f21daa6f3b4dd49b3c) non-repeating error - [`06c353e`](https://github.com/actualbudget/actual/commit/06c353e8e7c3ca4aeb3c2afd57349251a9e36460) add daily - [`2b1d2ae`](https://github.com/actualbudget/actual/commit/2b1d2aecc15ff4e69aaaf58fcbae7c98897da289) move else ### 📊 Changes **2 files changed** (+166 additions, -135 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/budget/goals/goalsSchedule.ts` (+160 -135) ➕ `upcoming-release-notes/2102.md` (+6 -0) </details> ### 📄 Description This is an attempt to simplify the schedules file by breaking out the logic in separate functions and hopefully squashing a few bugs in the process. I think this is a little easier to follow than the currently written method of nested if-else logic and will hopefully be easier to debug in the future. The calculation method remains the same, so hopefully there are no regressions 🤞. One possible gotcha is the way the schedule templates are now filtered. It is possible that a schedule could end up in both the sinkingFund and full template arrays. I haven't seen it happen in any of the iterations I've tried so far but I may have missed a situation. Believed to fixed: 1. When placing a non-repeating schedule into the future, the schedule template would not budget. 2. Monthly recurring schedules would sometimes have non-expected values. @jfdoming You added startDate and started variables in #1899. I removed them because it was causing issue 1 above. Is there a schedule condition I need to check that I'm overlooking? It's simply commented for now so it's easy to turn back on. This is an attempt at a flow chart for all of the logic happening in this file.  ![mermaid-1702930808136](https://github.com/actualbudget/actual/assets/20625555/8bc96bea-5401-4021-8acd-57f27f7e7809) --- <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-10 20:53:20 -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#11174