Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maintenence] Refactor Goals Schedule file #2102

Merged
merged 16 commits into from
Jan 7, 2024

Conversation

shall0pass
Copy link
Contributor

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

Copy link

netlify bot commented Dec 18, 2023

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 462faa7
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/659a06d566116000089ca6f6
😎 Deploy Preview https://deploy-preview-2102.demo.actualbudget.org/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Contributor

github-actions bot commented Dec 18, 2023

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
15 3.08 MB 0%

Changeset

No files were changed

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
static/js/main.js 1.43 MB 0%
static/js/665.chunk.js 824.28 kB 0%
static/media/Inter-italic.var.woff2 239.29 kB 0%
static/media/Inter-roman.var.woff2 221.86 kB 0%
static/js/231.chunk.js 117.38 kB 0%
static/js/wide-components.chunk.js 112.27 kB 0%
static/js/reports.chunk.js 77.81 kB 0%
static/js/narrow-components.chunk.js 42.42 kB 0%
static/js/553.chunk.js 13.14 kB 0%
static/js/473.chunk.js 13 kB 0%
static/js/resize-observer-polyfill.chunk.js 8.88 kB 0%
static/css/main.css 7.41 kB 0%
asset-manifest.json 1.92 kB 0%
index.html 1.66 kB 0%
static/media/browser-server.js 911 B 0%

Copy link
Contributor

github-actions bot commented Dec 18, 2023

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
2 2.23 MB → 2.23 MB (+109 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/budget/goals/goalsSchedule.ts 📈 +18 B (+0.26%) 6.75 kB → 6.77 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.24 MB → 1.24 MB (+109 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
xfo.xfo.kcab.worker.js 1014.45 kB 0%

@youngcw
Copy link
Member

youngcw commented Dec 18, 2023

I think this is overwriting previous templates budgeted value.

For example, this setup doesn't work right. This only ends up with the schedule value ($15) instead of the full 25.

#template 10
#template schedule Netflix
expect 25

@youngcw
Copy link
Member

youngcw commented Dec 18, 2023

That overwrite issue is fixed now. I still need to go through and make sure the chart and code make sense

youngcw
youngcw previously approved these changes Dec 22, 2023
@jfdoming
Copy link
Contributor

@shall0pass thanks for looking! I think I added those variables to fix a different calculation issue I found, but maybe I misunderstood how things were supposed to work. I'm on vacation right now so I don't have my computer but I'll take a look tomorrow and let you know if I noticed anything weird

@shall0pass
Copy link
Contributor Author

Remerged master and made sure #2125 was applied.

Copy link
Contributor

@jfdoming jfdoming left a comment

Choose a reason for hiding this comment

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

I wasn't able to find/reproduce the original issue I found, so feel free to merge this as is. I'll open an issue in the repo if I can reproduce it.

@Kidglove57
Copy link

Sorry I did not respond to your original review request @shall0pass. I don’t think my GitHub notifications are set right! Will look later - however I am seeing the same issues on current release as was reported in GitHub

@shall0pass
Copy link
Contributor Author

Sorry I did not respond to your original review request @shall0pass. I don’t think my GitHub notifications are set right! Will look later - however I am seeing the same issues on current release as was reported in GitHub

You're seeing the issue on 24.1.0 or you're seeing the issue in this PR? Nothing was merged for 24.1.0 around that issue, so it should still be unresolved.

@Kidglove57
Copy link

Kidglove57 commented Jan 7, 2024

Sorry I did not respond to your original review request @shall0pass. I don’t think my GitHub notifications are set right! Will look later - however I am seeing the same issues on current release as was reported in GitHub

You're seeing the issue on 24.1.0 or you're seeing the issue in this PR? Nothing was merged for 24.1.0 around that issue, so it should still be unresolved.

Understood - I have now been able to test my own file in this PR. It now fills the budget as it should for a single line annual "#template schedule x" but gives me an odd number (too low) where I have a series of annual "#template schedule ..." listed in the same category.

@shall0pass shall0pass merged commit 33e778f into actualbudget:master Jan 7, 2024
19 checks passed
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully and removed ✅ Approved labels Jan 7, 2024
@shall0pass shall0pass deleted the schedules_refactor branch January 9, 2024 18:43
FlorianLang06 pushed a commit to FlorianLang06/actual that referenced this pull request Mar 7, 2024
* refactor pass 1

* refactor pass 2

* refactor pass 3

* commented out startDate

* remove console logging

* release note

* non-repeating error

* add daily

* move else

* Fix compounding to_budget

* lint

* reapply 2125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Merged Pull Request has been merged successfully
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants