diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index e6d900a12995f49c00c0cb2d008c161830807b40..12a78d706ec4135fbc83ddcebed05e2a1d1333da 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.md new file mode 100644 index 0000000000000000000000000000000000000000..496d975ccf1c0c24761d820d6fb3306436ab0c66 --- /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