diff --git a/packages/loot-core/src/server/budget/goal-template.pegjs b/packages/loot-core/src/server/budget/goal-template.pegjs index 2cda62bdb6a..3d78ada8fb6 100644 --- a/packages/loot-core/src/server/budget/goal-template.pegjs +++ b/packages/loot-core/src/server/budget/goal-template.pegjs @@ -35,11 +35,11 @@ repeat 'repeat interval' / 'year'i { return { annual: true }} / years: positive _ 'years'i { return { annual: true, repeat: +years }} -limit = _? upTo _ amount: amount _ 'per week starting'i _ start:date _? hold:hold? +limit = _? upTo _ amount: amount _ 'per week starting'i _ start:date _? hold:hold? { return {amount: amount, hold: hold, period: 'weekly', start: start }} / _? upTo _ amount: amount _ 'per day'i _? hold: hold? { return {amount: amount, hold: hold, period: 'daily', start:null }} - / _? upTo _ amount: amount _? hold: hold? + / _? upTo _ amount: amount _? hold: hold? { return {amount: amount, hold: hold, period: 'monthly', start:null }} percentOf = percent:percent _ of _ 'previous'i _ { return { percent: percent, prev: true}} 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 a799b939449..1d036c92736 100644 --- a/packages/loot-core/src/server/budget/template-notes.test.ts +++ b/packages/loot-core/src/server/budget/template-notes.test.ts @@ -73,6 +73,26 @@ describe('storeTemplates', () => { }, ], }, + { + description: + 'Stores template when prefix is used with valid template notes', + mockTemplateNotes: [ + { + id: 'cat1', + name: 'Category 1', + note: 'test: #template 12', + }, + ], + expectedTemplates: [ + { + type: 'simple', + monthly: 12, + limit: null, + priority: 0, + directive: 'template', + }, + ], + }, { description: 'Stores templates for categories with valid goal directive template notes', diff --git a/packages/loot-core/src/server/budget/template-notes.ts b/packages/loot-core/src/server/budget/template-notes.ts index 4141ec3dc07..a619a90a15d 100644 --- a/packages/loot-core/src/server/budget/template-notes.ts +++ b/packages/loot-core/src/server/budget/template-notes.ts @@ -79,7 +79,7 @@ async function getCategoriesWithTemplates(): Promise { const parsedTemplates: Template[] = []; note.split('\n').forEach(line => { - const trimmedLine = line.trim(); + const trimmedLine = line.substring(line.indexOf('#')).trim(); if ( !trimmedLine.startsWith(TEMPLATE_PREFIX) && diff --git a/upcoming-release-notes/4032.md b/upcoming-release-notes/4032.md new file mode 100644 index 00000000000..4c3d2e0f878 --- /dev/null +++ b/upcoming-release-notes/4032.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [UnderKoen] +--- + +Allow note prefixes in budget templates.