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

[Bug]: Template by schedule incorrectly calculating budgeting amount #3892

Open
2 tasks done
sammichaels opened this issue Nov 25, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working goal templates Related to the experimental goal templates feature

Comments

@sammichaels
Copy link

Verified issue does not already exist?

  • I have searched and found no existing issue
  • I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file)

What happened?

When using a schedule with two transactions per month and a template by schedule, the next month is incorrectly calculated.

Steps to reproduce (calculated on 11/24/24 and 11/25/24):

  1. Create schedule with transactions of $100 on the 15th and 30th of every month. Verified upcoming dates listed 11/30, 12/15, 12/30.
  2. Add a template by schedule "#template schedule X".
  3. Apply for November. Correctly added $100 to category for 11/30.
  4. Apply for December. Incorrectly added $100 to category. Expected $200 for the transactions on 12/15 and 12/30.
  5. Apply for January. Correctly added $200 to category for 1/15 and 1/30.

I've attached an example budget I created to reproduce the issue.

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Safari

Operating System

Mac OSX

@sammichaels sammichaels added the bug Something isn't working label Nov 25, 2024
@sammichaels
Copy link
Author

sammichaels commented Nov 26, 2024

The behavior appears to be in goalsSchedule.ts:

if (balance >= totalSinking + totalPayMonthOf) {
to_budget += Math.round(totalPayMonthOf + totalSinkingBaseContribution);
} else {
const totalSinkingContribution = await getSinkingContributionTotal(
t_sinking,
remainder,
last_month_balance,
);
if (t_sinking.length === 0) {
to_budget +=
Math.round(totalPayMonthOf + totalSinkingContribution) -
last_month_balance;
} else {
to_budget += Math.round(totalPayMonthOf + totalSinkingContribution);
}
}

If the balance is less than the amount needed to schedule (if statement on line 227 is evaluating to false), it is incorrectly subtracting last_month_balance from the amount in totalPayMonthOf (setting to_Budget on line 236). I think the issue is that it's not reserving the amount needed for upcoming transactions in previous months that have not yet happened.

In my example above, $100 is added in November, but that transaction has not yet occurred. When December is calculated, it's not taking into consideration the 11/30 upcoming transaction and instead subtracting that balance ($200 total needed for 12/15 and 12/30, $100 already there, so only fund $100). The expected behavior would be $200 total needed for 12/15 and 12/30, $100 already there, $100 needed in upcoming transactions from previous months on 11/30, so fund $200.

@youngcw youngcw added the goal templates Related to the experimental goal templates feature label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working goal templates Related to the experimental goal templates feature
Projects
None yet
Development

No branches or pull requests

2 participants