diff --git a/packages/loot-core/src/server/budget/goals/goalsSchedule.ts b/packages/loot-core/src/server/budget/goals/goalsSchedule.ts index ef5bc7ee290..b311d5bcf9e 100644 --- a/packages/loot-core/src/server/budget/goals/goalsSchedule.ts +++ b/packages/loot-core/src/server/budget/goals/goalsSchedule.ts @@ -17,6 +17,7 @@ export async function goalsSchedule( last_month_balance, to_budget, errors, + category, ) { if (!scheduleFlag) { scheduleFlag = true; @@ -34,12 +35,15 @@ export async function goalsSchedule( const conditions = rule.serialize().conditions; const { date: dateConditions, amount: amountCondition } = extractScheduleConds(conditions); + const sign = category.is_income ? 1 : -1; const target = amountCondition.op === 'isbetween' - ? -Math.round( - amountCondition.value.num1 + amountCondition.value.num2, - ) / 2 - : -amountCondition.value; + ? (sign * + Math.round( + amountCondition.value.num1 + amountCondition.value.num2, + )) / + 2 + : sign * amountCondition.value; const next_date_string = getNextDate( dateConditions, monthUtils._parse(current_month), diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index 6c71ee2a191..256053eda4a 100644 --- a/packages/loot-core/src/server/budget/goaltemplates.ts +++ b/packages/loot-core/src/server/budget/goaltemplates.ts @@ -590,6 +590,7 @@ async function applyCategoryTemplate( last_month_balance, to_budget, errors, + category, ); to_budget = goalsReturn.to_budget; errors = goalsReturn.errors; diff --git a/upcoming-release-notes/2125.md b/upcoming-release-notes/2125.md new file mode 100644 index 00000000000..0197a4b53a3 --- /dev/null +++ b/upcoming-release-notes/2125.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [mk-french] +--- + +Goals: Negate schedule amount to budget if income