From d3ab8f9812bf0cf2e345e7eff56412448ca4664a Mon Sep 17 00:00:00 2001 From: shall0pass <20625555+shall0pass@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:11:52 -0500 Subject: [PATCH] [Bug] Goals: Fix schedules 'in between' calculation (#1753) * fix in between calculation * release note --- packages/loot-core/src/server/budget/goaltemplates.ts | 9 +++++++-- upcoming-release-notes/1753.md | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 upcoming-release-notes/1753.md diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index c07557a05d2..c23d3f7eb11 100644 --- a/packages/loot-core/src/server/budget/goaltemplates.ts +++ b/packages/loot-core/src/server/budget/goaltemplates.ts @@ -645,7 +645,12 @@ async function applyCategoryTemplate( let conditions = rule.serialize().conditions; let { date: dateConditions, amount: amountCondition } = extractScheduleConds(conditions); - let target = -amountCondition.value; + let target = + amountCondition.op === 'isbetween' + ? -Math.round( + amountCondition.value.num1 + amountCondition.value.num2, + ) / 2 + : -amountCondition.value; let next_date_string = getNextDate( dateConditions, monthUtils._parse(current_month), @@ -682,7 +687,7 @@ async function applyCategoryTemplate( monthUtils._parse(current_month), ); while (next_date < next_month) { - monthlyTarget += amountCondition.value; + monthlyTarget += -target; next_date = monthUtils.addDays(next_date, 1); next_date = getNextDate( dateConditions, diff --git a/upcoming-release-notes/1753.md b/upcoming-release-notes/1753.md new file mode 100644 index 00000000000..0e04fb44e96 --- /dev/null +++ b/upcoming-release-notes/1753.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [shall0pass] +--- + +Goals - Fix schedules 'in between' calculation