[Bug] [Budget templates]: "up to" template not handling category negative Spent #538

Closed
opened 2026-02-28 19:08:08 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @dugite-code on GitHub (Aug 2, 2023).

Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

  • Have a category with a Spent of -383.44 and a balance -44.80 with over 1300 to budget
  • Set the category budget template as #template 300 up to 350

Expected result: to have 300 applied to category budget
Actual result: 11.36 applied to category budget

It looks like the spent amount is taken as a positive and the balance subtracted to determine the amount to budget:

350 - ( 383.44 + -44.8 ) = 11.36

image


Additional details

  • I have 40 categories. All have templates, other negative balances cause issues.
  • I updated to the edge tag and still encountered this issue.
  • I do not use priorities in any of the budget goal templates.

What error did you receive?

No response

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Firefox

Operating System

Linux

Originally created by @dugite-code on GitHub (Aug 2, 2023). ### Verified issue does not already exist? - [X] I have searched and found no existing issue ### What happened? - Have a category with a Spent of `-383.44` and a balance `-44.80` with over `1300` to budget - Set the category budget template as `#template 300 up to 350` Expected result: to have `300` applied to category budget Actual result: `11.36` applied to category budget It looks like the spent amount is taken as a positive and the balance subtracted to determine the amount to budget: ``` 350 - ( 383.44 + -44.8 ) = 11.36 ``` ![image](https://github.com/actualbudget/actual/assets/12742064/f5817506-7aa9-4fe9-a31b-767068a9faf0) --- Additional details - I have 40 categories. All have templates, other negative balances cause issues. - I updated to the edge tag and still encountered this issue. - I do not use priorities in any of the budget goal templates. ### What error did you receive? _No response_ ### Where are you hosting Actual? Docker ### What browsers are you seeing the problem on? Firefox ### Operating System Linux
GiteaMirror added the bug label 2026-02-28 19:08:08 -06:00
Author
Owner

@shall0pass commented on GitHub (Aug 2, 2023):

I'm unable to reproduce this issue. I created a fresh budget to test, added one account, added one payment transaction to the food category in the amount of 315, place a -40 in the budgeted field, and applied #template 300 up to 350. The result was 300 budgeted with a balance of -15. (-315+300).

Did I miss something?

@shall0pass commented on GitHub (Aug 2, 2023): I'm unable to reproduce this issue. I created a fresh budget to test, added one account, added one payment transaction to the food category in the amount of 315, place a -40 in the budgeted field, and applied #template 300 up to 350. The result was 300 budgeted with a balance of -15. (-315+300). Did I miss something?
Author
Owner

@kyrias commented on GitHub (Aug 2, 2023):

  • Create fresh budget.
  • Create Test account with starting balance of 1300.
  • Create a transaction for -383.44 in the Food category.
  • In the previous month set the Food category budgeted amount to 338.64.
  • Set Food category template to #template 300 up to 350.
  • Apply budget template in current month.

Result: Food category has budgeted 11.36, spent -383.44, and balance -33.44.

@kyrias commented on GitHub (Aug 2, 2023): - Create fresh budget. - Create Test account with starting balance of 1300. - Create a transaction for -383.44 in the Food category. - In the previous month set the Food category budgeted amount to 338.64. - Set Food category template to `#template 300 up to 350`. - Apply budget template in current month. Result: Food category has budgeted 11.36, spent -383.44, and balance -33.44.
Author
Owner

@Kidglove57 commented on GitHub (Aug 2, 2023):

I can also reproduce this. I tried using the “overwrite” feature but it made no difference

@Kidglove57 commented on GitHub (Aug 2, 2023): I can also reproduce this. I tried using the “overwrite” feature but it made no difference
Author
Owner

@shall0pass commented on GitHub (Aug 2, 2023):

Ah ok. What's happening is that the template doesn't take into consideration any current month spending. If you didn't have the spent value, your category balance for the month would be 350 and you would have hit the limit for the category. Lines 717 and 718 of the goal templates file are where the calculation is being modified from 300 to 11 to max the category at 350 if someone wants to take a look.

Fix: line 717
else if(to_budget +balance >limit) {
to_budget = limit - balance;
}

I'm traveling today so I can't push this until tonight, maybe tomorrow. If someone else wants to check this and push 🎉

@shall0pass commented on GitHub (Aug 2, 2023): Ah ok. What's happening is that the template doesn't take into consideration any current month spending. If you didn't have the spent value, your category balance for the month would be 350 and you would have hit the limit for the category. Lines 717 and 718 of the goal templates file are where the calculation is being modified from 300 to 11 to max the category at 350 if someone wants to take a look. Fix: line 717 else if(to_budget +balance >limit) { to_budget = limit - balance; } I'm traveling today so I can't push this until tonight, maybe tomorrow. If someone else wants to check this and push 🎉
Author
Owner

@youngcw commented on GitHub (Aug 2, 2023):

This seems to be acting as expected. Select few templates consider the spent value in their calculations. Any overspending should be taken care by clicking the the negative balance and then "cover overspending" to pull in funds from a different category. Other options to clean up the overspending are to get rid of the limit, increase the limit, or use the end of month cleanup.

@youngcw commented on GitHub (Aug 2, 2023): This seems to be acting as expected. Select few templates consider the spent value in their calculations. Any overspending should be taken care by clicking the the negative balance and then "cover overspending" to pull in funds from a different category. Other options to clean up the overspending are to get rid of the limit, increase the limit, or use the end of month cleanup.
Author
Owner

@shall0pass commented on GitHub (Aug 2, 2023):

Here is the definition of this template from the documentation.

<html>
#template $50 up to $300 Budget $50 each month up to a maximum of $300 Funding rainy day categories, such as replacement shoes and bicycle repairs
</html>

The way I read this, is that it will budget 50 into the category until the category has a maximum amount of 300. Reading it that way, I agree with @youngcw that it is behaving as described. The difference in this bug report is that spending has already occurred when the template was run.

If we change your example slightly, and remove the spending. The template still would have budgeted 11.36 because your category would have been capped at 350 which was specified.

If you have read the description differently, I'm interested in hearing how you think it reads. Maybe we can make it more clear. I think you would be more satisfied with just #template 300 for this application, since you always want to budget 300 into the category. This will not place an upper limit on how much to save.

@shall0pass commented on GitHub (Aug 2, 2023): Here is the definition of this template from the documentation. <html> <body> <!--StartFragment--> #template $50 up to $300 | Budget $50 each month up to a maximum of $300 | Funding rainy day categories, such as replacement shoes and bicycle repairs -- | -- | -- <!--EndFragment--> </body> </html> The way I read this, is that it will budget 50 into the category until the category has a maximum amount of 300. Reading it that way, I agree with @youngcw that it is behaving as described. The difference in this bug report is that spending has already occurred when the template was run. If we change your example slightly, and remove the spending. The template still would have budgeted 11.36 because your category would have been capped at 350 which was specified. If you have read the description differently, I'm interested in hearing how you think it reads. Maybe we can make it more clear. I think you would be more satisfied with just `#template 300` for this application, since you always want to budget 300 into the category. This will not place an upper limit on how much to save.
Author
Owner

@dugite-code commented on GitHub (Aug 2, 2023):

Right I see where it's going wrong here. But is it really expected? From my read it's up to 350 from when the template is applied and I would expect it would take spending into account. If you have spent the funds you no longer have up to 350 so it should be fine adding the entire 300 as the cap no longer applies, It's certainly not what I expect would happen.

I don't want to use the #template 300 because this category can vary quite a bit but when I do my budget I still want a maximum of 350 in that category. I always have some spending because I get payed in the middle of the month so I do my budget in the middle of the month.

@dugite-code commented on GitHub (Aug 2, 2023): Right I see where it's going wrong here. But is it really expected? From my read it's up to 350 from when the template is applied and I would expect it would take spending into account. If you have spent the funds you no longer have up to 350 so it should be fine adding the entire 300 as the cap no longer applies, It's certainly not what I expect would happen. I don't want to use the `#template 300` because this category can vary quite a bit but when I do my budget I still want a maximum of 350 in that category. I always have some spending because I get payed in the middle of the month so I do my budget in the middle of the month.
Author
Owner

@shall0pass commented on GitHub (Aug 2, 2023):

Please try the PR https://github.com/actualbudget/actual/pull/1448 to see if this would resolve your issue. @youngcw , I'd really appreciate a review from you as well when you have time :)

@shall0pass commented on GitHub (Aug 2, 2023): Please try the PR https://github.com/actualbudget/actual/pull/1448 to see if this would resolve your issue. @youngcw , I'd really appreciate a review from you as well when you have time :)
Author
Owner

@dugite-code commented on GitHub (Aug 3, 2023):

@shall0pass Yes, just tested on netlify and that resolves my issue.

@dugite-code commented on GitHub (Aug 3, 2023): @shall0pass Yes, just tested on netlify and that resolves my issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#538