Skip to content

Commit

Permalink
Goals: fix leftover 1 cent in remainder goal (actualbudget#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngcw authored Jul 28, 2023
1 parent deedb31 commit 2f5264c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/loot-core/src/server/budget/goaltemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async function processTemplate(month, force, category_templates) {
let remainder_scale = 1;
if (priority === lowestPriority) {
let available_now = await getSheetValue(sheetName, `to-budget`);
remainder_scale = Math.round(available_now / remainder_weight_total);
remainder_scale = available_now / remainder_weight_total;
}

for (let c = 0; c < categories.length; c++) {
Expand Down Expand Up @@ -671,6 +671,9 @@ async function applyCategoryTemplate(
// can over budget with the rounding, so checking that
if (to_budget >= budgetAvailable + budgeted) {
to_budget = budgetAvailable + budgeted;
// check if there is 1 cent leftover from rounding
} else if (budgetAvailable - to_budget === 1) {
to_budget = to_budget + 1;
}
}
break;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1400.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [youngcw]
---

Goals: Fix leftover $0.01 when using remainder goal

0 comments on commit 2f5264c

Please sign in to comment.