Skip to content

Commit

Permalink
[Bug] Goals: Fix schedules 'in between' calculation (#1753)
Browse files Browse the repository at this point in the history
* fix in between calculation

* release note
  • Loading branch information
shall0pass authored Oct 6, 2023
1 parent 0ea7f18 commit d3ab8f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/loot-core/src/server/budget/goaltemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1753.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [shall0pass]
---

Goals - Fix schedules 'in between' calculation

0 comments on commit d3ab8f9

Please sign in to comment.