Skip to content

Commit

Permalink
[Goals]: fix repeating spend templates (#4066)
Browse files Browse the repository at this point in the history
* fix repeating spend templates

* work with all repeat types

* note
  • Loading branch information
youngcw authored Jan 1, 2025
1 parent da613ab commit 7060e4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/loot-core/src/server/budget/categoryTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,24 @@ export class CategoryTemplate {
}

private async runSpend(template): Promise<number> {
const fromMonth = `${template.from}`;
const toMonth = `${template.month}`;
let fromMonth = `${template.from}`;
let toMonth = `${template.month}`;
let alreadyBudgeted = this.fromLastMonth;
let firstMonth = true;

//update months if needed
const repeat = template.annual
? (template.repeat || 1) * 12
: template.repeat;
let m = monthUtils.differenceInCalendarMonths(toMonth, this.month);
if (repeat && m < 0) {
while (m < 0) {
toMonth = monthUtils.addMonths(toMonth, repeat);
fromMonth = monthUtils.addMonths(fromMonth, repeat);
m = monthUtils.differenceInCalendarMonths(toMonth, this.month);
}
}

for (
let m = fromMonth;
monthUtils.differenceInCalendarMonths(this.month, m) > 0;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4066.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [youngcw]
---

Fix spend template not repeating

0 comments on commit 7060e4b

Please sign in to comment.