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

[Goals] Negate schedule amount to budget if income #2125

Merged

Conversation

mk-french
Copy link
Contributor

When referencing a schedule in a goal template for an income category, the amount to budget comes in as a negative amount. This PR fixes that by correctly signing the amount to budget if the category is an income category.

Copy link

netlify bot commented Dec 27, 2023

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit de6ec26
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/658b7dee53524900083613a2
😎 Deploy Preview https://deploy-preview-2125.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 27, 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.09 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 113.08 kB 0%
static/js/reports.chunk.js 78.28 kB 0%
static/js/narrow-components.chunk.js 45.2 kB 0%
static/js/553.chunk.js 28.56 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 27, 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 (+41 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/budget/goals/goalsSchedule.ts 📈 +76 B (+1.11%) 6.68 kB → 6.75 kB
packages/loot-core/src/server/budget/goaltemplates.ts 📈 +10 B (+0.05%) 20.9 kB → 20.91 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 (+41 B) +0.00%

Smaller

No assets were smaller

Unchanged

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

@youngcw
Copy link
Member

youngcw commented Dec 27, 2023

Can you put together an example budget file that shows the bug? Ive not seen this issue and I have some income schedules that I use.

Side question. Are you setting the schedule in question to be income instead of an expense?

@mk-french
Copy link
Contributor Author

Can you put together an example budget file that shows the bug? Ive not seen this issue and I have some income schedules that I use.

Yep.

2023-12-27-My-Finances-01903ab.zip

Side question. Are you setting the schedule in question to be income instead of an expense?

If by setting you mean having a +ve amount then yes. Are you doing something different?

@youngcw
Copy link
Member

youngcw commented Dec 27, 2023

Ok, you're right this is broken. I had forgotten that I wasn't actually using a schedule in the income category on my end. I've been using it for long enough that I forgot what the template actually was.

@shall0pass does this look good to you?

@shall0pass
Copy link
Contributor

This fixes the one case you mentioned, but it appears there are issues in other categories as well.

For example:
In a spending schedule where we have an upcoming bill, a category will be filled with a positive value to budget for it. Good ✅
In an income schedule where we are expecting income, any category will be filled with a negative value. Bad 👎

So if I had '#template schedule paycheck' and expect the entire amount to go into this one category, it will budget a negative amount in both report types.

Would it make sense to use an absolute value around amounts before applying it to the budget cells so it's always positive (inflow or outflow)? I can't think of a reason why an amount you want to schedule using a template would ever return a negative budgeted number, but I may be overlooking an edge case.

@youngcw
Copy link
Member

youngcw commented Dec 27, 2023

So if I had '#template schedule paycheck' and expect the entire amount to go into this one category, it will budget a negative amount

That made sense to me, where the paycheck would be negative expense and counteract any normal expenses. That would be assuming that you want to pull that money out instead of leaving it in or have it be mostly canceling out in some way.

@shall0pass
Copy link
Contributor

So if I had '#template schedule paycheck' and expect the entire amount to go into this one category, it will budget a negative amount

That made sense to me, where the paycheck would be negative expense and counteract any normal expenses. That would be assuming that you want to pull that money out instead of leaving it in or have it be mostly canceling out in some way.

A different example. I have a monthly schedule set up to deposit $X into my HSA account. If I use that schedule in the templates as-is, it will remove $X from the HSA category instead of adding $X to the category. (I have them mentally linked since only medically qualified expenses can be used from that account). Just last month I thought I would use the schedule template for this, but now I see that it'll remove the deposit from the category rather than add it as intended. I'm going to revert the template to the previous fixed amount for now.

@mk-french
Copy link
Contributor Author

So if I had '#template schedule paycheck' and expect the entire amount to go into this one category, it will budget a negative amount

That made sense to me, where the paycheck would be negative expense and counteract any normal expenses. That would be assuming that you want to pull that money out instead of leaving it in or have it be mostly canceling out in some way.

Agreed. This behaviour also makes sense to me. If it's an expense Category then an expected/scheduled income has to be budgeted as negative, as positive values here represent an expense. Then when income transactions arrive in the account, they will balance appropriately.

A different example. I have a monthly schedule set up to deposit $X into my HSA account. If I use that schedule in the templates as-is, it will remove $X from the HSA category instead of adding $X to the category. (I have them mentally linked since only medically qualified expenses can be used from that account). Just last month I thought I would use the schedule template for this, but now I see that it'll remove the deposit from the category rather than add it as intended. I'm going to revert the template to the previous fixed amount for now.

Apologies, I don't exactly understand what the goal in terms of budgeting is here. Are you trying to track the deposits into the account, the medical expenses or the resultant of both? In my head, if it's an expense category, and it's a deposit you're scheduling, it needs to be a -ve budget for the balance to work.

Regardless, this change only affects the behaviour of Income categories, everything else is as it was.

@shall0pass
Copy link
Contributor

Perhaps it's just how I have my accounts organized. I have a Savings account, income to that account goes to an income category. I also have a spending category that has a balance that mirrors the account balance and money is budgeted that month in the exact amount of the income for the Savings account.

I'm fine with the changes you've made as-is. I definitely won't be using an income schedule in the rollover budget though, as this past month it threw my To Budget amount off considerably and the category balance and account balance were no longer the same (Account balance went up by the scheduled amount and category went down by the scheduled amount.). I understand not all templates can be used in the same way. Maybe the income template might be more appropriate. Thanks for thinking about this.

@youngcw youngcw added this to the v24.1.0 milestone Dec 31, 2023
@shall0pass shall0pass merged commit e589163 into actualbudget:master Jan 3, 2024
19 checks passed
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully and removed ✨ Merged Pull Request has been merged successfully ✅ Approved labels Jan 3, 2024
FlorianLang06 pushed a commit to FlorianLang06/actual that referenced this pull request Mar 7, 2024
* Negate schedule amount to budget if income

* Release notes

* Determine sign at initial calc

To ensure no unintended impact to remainder calcs etc.

* Lint fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants