Skip to content

A local-first personal finance app

:bug: [Goals]: Fix inconsistent schedule amounts (#4265)

youngcw64df0e107c75
diff --git a/packages/loot-core/src/server/budget/categoryTemplate.ts b/packages/loot-core/src/server/budget/categoryTemplate.ts
index edde050a03..37dcbbecb6 100644
--- a/packages/loot-core/src/server/budget/categoryTemplate.ts
+++ b/packages/loot-core/src/server/budget/categoryTemplate.ts
@@ -126,10 +126,7 @@ export class CategoryTemplate {
break;
}
case 'schedule': {
- const budgeted = await getSheetValue(
- monthUtils.sheetForMonth(this.month),
- `leftover-${this.category.id}`,
- );
+ const budgeted = this.fromLastMonth + toBudget;
const ret = await goalsSchedule(
scheduleFlag,
t,
diff --git a/packages/loot-core/src/server/budget/template-notes.test.ts b/packages/loot-core/src/server/budget/template-notes.test.ts
index 1d036c9273..f2e36c7281 100644
--- a/packages/loot-core/src/server/budget/template-notes.test.ts
+++ b/packages/loot-core/src/server/budget/template-notes.test.ts
@@ -224,7 +224,7 @@ describe('checkTemplates', () => {
expected: {
sticky: true,
message: 'There were errors interpreting some templates:',
- pre: 'cat1: Schedule “Non-existent Schedule” does not exist',
+ pre: 'Category 1: Schedule “Non-existent Schedule” does not exist',
},
},
];
diff --git a/packages/loot-core/src/server/budget/template-notes.ts b/packages/loot-core/src/server/budget/template-notes.ts
index a619a90a15..7761b4f443 100644
--- a/packages/loot-core/src/server/budget/template-notes.ts
+++ b/packages/loot-core/src/server/budget/template-notes.ts
@@ -40,7 +40,7 @@ export async function checkTemplates(): Promise<Notification> {
const scheduleNames = schedules.map(({ name }) => name);
const errors: string[] = [];
- categoryWithTemplates.forEach(({ id, name, templates }) => {
+ categoryWithTemplates.forEach(({ name, templates }) => {
templates.forEach(template => {
if (template.type === 'error') {
errors.push(`${name}: ${template.line}`);
@@ -48,7 +48,7 @@ export async function checkTemplates(): Promise<Notification> {
template.type === 'schedule' &&
!scheduleNames.includes(template.name)
) {
- errors.push(`${id}: Schedule “${template.name}” does not exist`);
+ errors.push(`${name}: Schedule “${template.name}” does not exist`);
}
});
});
diff --git a/upcoming-release-notes/4265.md b/upcoming-release-notes/4265.md
new file mode 100644
index 0000000000..12b9f6bd50
--- /dev/null
+++ b/upcoming-release-notes/4265.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [youngcw]
+---
+
+Fix schedule templates sometimes budgeting wrong amounts