From 49c45461378e3dc21bf1a5e5b9b29fc7a164b2ff Mon Sep 17 00:00:00 2001 From: youngcw Date: Wed, 20 Sep 2023 20:31:20 -0700 Subject: [PATCH 1/4] speed up and a bug fix --- packages/loot-core/src/server/budget/goaltemplates.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index bd526ca42f7..408a98b7991 100644 --- a/packages/loot-core/src/server/budget/goaltemplates.ts +++ b/packages/loot-core/src/server/budget/goaltemplates.ts @@ -61,7 +61,6 @@ async function setGoalBudget({ month, templateBudget }) { } async function processTemplate(month, force, category_templates) { - let templateBudget = []; let num_applied = 0; let errors = []; let lowestPriority = 0; @@ -106,7 +105,7 @@ async function processTemplate(month, force, category_templates) { await setGoalBudget({ month, templateBudget: setToZero.filter( - f => f.isTemplate === true && f.isIncome === 0, + f => f.isTemplate === true, ), }); @@ -136,6 +135,7 @@ async function processTemplate(month, force, category_templates) { ? await getSheetValue(sheetName, `total-saved`) : await getSheetValue(sheetName, `to-budget`); for (let priority = 0; priority <= lowestPriority; priority++) { + let templateBudget = []; // setup scaling for remainder let remainder_scale = 1; if (priority === lowestPriority) { @@ -231,6 +231,11 @@ async function processTemplate(month, force, category_templates) { } } await setGoalBudget({ month, templateBudget }); + // higher priority levels wont budget anything + // if there is nothing remaining anyway + if (available_remaining<=0){ + break; + } } if (!force) { From 02a0eb77ad65af4f91e0cbed5d0f6615d0caf36d Mon Sep 17 00:00:00 2001 From: youngcw Date: Wed, 20 Sep 2023 20:39:28 -0700 Subject: [PATCH 2/4] cleanup --- packages/loot-core/src/server/budget/goaltemplates.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index 408a98b7991..3b3f45e7d42 100644 --- a/packages/loot-core/src/server/budget/goaltemplates.ts +++ b/packages/loot-core/src/server/budget/goaltemplates.ts @@ -231,11 +231,6 @@ async function processTemplate(month, force, category_templates) { } } await setGoalBudget({ month, templateBudget }); - // higher priority levels wont budget anything - // if there is nothing remaining anyway - if (available_remaining<=0){ - break; - } } if (!force) { From c0cb2d14eff4a18bb9e814220bbd84edbcfbec3a Mon Sep 17 00:00:00 2001 From: youngcw Date: Wed, 20 Sep 2023 20:41:22 -0700 Subject: [PATCH 3/4] note --- upcoming-release-notes/1718.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/1718.md diff --git a/upcoming-release-notes/1718.md b/upcoming-release-notes/1718.md new file mode 100644 index 00000000000..a52c2a2e37b --- /dev/null +++ b/upcoming-release-notes/1718.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [youngcw] +--- + +Goals: fix bug in report budget templates, and add a speedup From 949c1822bb9d7e7fdbfaeef88bd9272c1c30ee23 Mon Sep 17 00:00:00 2001 From: youngcw Date: Wed, 20 Sep 2023 20:44:34 -0700 Subject: [PATCH 4/4] lint --- packages/loot-core/src/server/budget/goaltemplates.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/loot-core/src/server/budget/goaltemplates.ts b/packages/loot-core/src/server/budget/goaltemplates.ts index 3b3f45e7d42..9d27ac33960 100644 --- a/packages/loot-core/src/server/budget/goaltemplates.ts +++ b/packages/loot-core/src/server/budget/goaltemplates.ts @@ -104,9 +104,7 @@ async function processTemplate(month, force, category_templates) { } await setGoalBudget({ month, - templateBudget: setToZero.filter( - f => f.isTemplate === true, - ), + templateBudget: setToZero.filter(f => f.isTemplate === true), }); // find all remainder templates, place them after all other templates