Skip to content

A local-first personal finance app

Goals: Add recurring schedule support (#1193)

shall0passdf74e6ddd144
diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts
index d7bb126ebc..fef46900f7 100644
--- a/packages/loot-core/src/server/budget/goaltemplates.ts
+++ b/packages/loot-core/src/server/budget/goaltemplates.ts
@@ -533,11 +533,31 @@ async function applyCategoryTemplate(
dateCond,
monthUtils._parse(current_month),
);
+
+ let isRepeating =
+ Object(dateCond.value) === dateCond.value &&
+ 'frequency' in dateCond.value;
+
let num_months = monthUtils.differenceInCalendarMonths(
next_date_string,
current_month,
);
+ if (isRepeating) {
+ let monthlyTarget = 0;
+ let next_month = monthUtils.addMonths(current_month, num_months + 1);
+ let next_date = getNextDate(
+ dateCond,
+ monthUtils._parse(current_month),
+ );
+ while (next_date < next_month) {
+ monthlyTarget += amountCond.value;
+ next_date = monthUtils.addDays(next_date, 1);
+ next_date = getNextDate(dateCond, monthUtils._parse(next_date));
+ }
+ amountCond.value = monthlyTarget;
+ }
+
if (template.full === true) {
if (num_months === 1) {
to_budget = -getScheduledAmount(amountCond.value);
diff --git a/upcoming-release-notes/1193.md b/upcoming-release-notes/1193.md
new file mode 100644
index 0000000000..b8c9268cc5
--- /dev/null
+++ b/upcoming-release-notes/1193.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [shall0pass]
+---
+
+Goals: Schedule keyword supports daily or weekly recurring schedules