diff --git a/packages/loot-core/src/server/budget/categoryTemplate.ts b/packages/loot-core/src/server/budget/categoryTemplate.ts index 0f1e3787330..3106bf1e348 100644 --- a/packages/loot-core/src/server/budget/categoryTemplate.ts +++ b/packages/loot-core/src/server/budget/categoryTemplate.ts @@ -444,11 +444,24 @@ export class CategoryTemplate { } private async runSpend(template): Promise { - 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; diff --git a/upcoming-release-notes/4066.md b/upcoming-release-notes/4066.md new file mode 100644 index 00000000000..15e703d8c8e --- /dev/null +++ b/upcoming-release-notes/4066.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [youngcw] +--- + +Fix spend template not repeating