A local-first personal finance app
[Goals]: fix repeating spend templates (#4066)
youngcw7060e4b657dd
diff --git a/packages/loot-core/src/server/budget/categoryTemplate.ts b/packages/loot-core/src/server/budget/categoryTemplate.tsindex 0f1e378733..3106bf1e34 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<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;diff --git a/upcoming-release-notes/4066.md b/upcoming-release-notes/4066.mdnew file mode 100644index 0000000000..15e703d8c8--- /dev/null+++ b/upcoming-release-notes/4066.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [youngcw]+---++Fix spend template not repeating