A local-first personal finance app
Goals: Improve remainder calculation when combined with other keywords (#1288)
shall0passa3e3c78c5cd4
diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.tsindex e6d900a129..12a78d706e 100644--- a/packages/loot-core/src/server/budget/goaltemplates.ts+++ b/packages/loot-core/src/server/budget/goaltemplates.ts@@ -603,9 +603,16 @@ async function applyCategoryTemplate(break;}case 'remainder': {- to_budget = Math.round(remainder_scale * template.weight);- // can over budget with the rounding, so checking that- if (to_budget > budgetAvailable) to_budget = budgetAvailable;+ if (remainder_scale >= 0) {+ to_budget +=+ remainder_scale === 0+ ? Math.round(template.weight)+ : Math.round(remainder_scale * template.weight);+ // can over budget with the rounding, so checking that+ if (to_budget >= budgetAvailable + budgeted) {+ to_budget = budgetAvailable + budgeted;+ }+ }break;}case 'error':diff --git a/upcoming-release-notes/1288.md b/upcoming-release-notes/1288.mdnew file mode 100644index 0000000000..496d975ccf--- /dev/null+++ b/upcoming-release-notes/1288.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [shall0pass]+---++Goals: Improved calculation when 'remainder' keyword is used with other keywords in the same category.\ No newline at end of file