From 5d4fcfde00ecdefce1158df5d3716d6b6cbeb51d Mon Sep 17 00:00:00 2001 From: shall0pass <20625555+shall0pass@users.noreply.github.com> Date: Wed, 31 Jan 2024 13:42:05 -0600 Subject: [PATCH] [Enhancement] Goal Target with cleanup template (#2282) * update goal target after montly cleanup * release note --- .../loot-core/src/server/budget/cleanup-template.ts | 11 ++++++++++- upcoming-release-notes/2282.md | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/2282.md diff --git a/packages/loot-core/src/server/budget/cleanup-template.ts b/packages/loot-core/src/server/budget/cleanup-template.ts index 43ab6ee2e2c..889a155122c 100644 --- a/packages/loot-core/src/server/budget/cleanup-template.ts +++ b/packages/loot-core/src/server/budget/cleanup-template.ts @@ -3,7 +3,7 @@ import { Notification } from '../../client/state-types/notifications'; import * as monthUtils from '../../shared/months'; import * as db from '../db'; -import { setBudget, getSheetValue } from './actions'; +import { setBudget, getSheetValue, setGoal } from './actions'; import { parse } from './cleanup-template.pegjs'; export function cleanupTemplate({ month }: { month: string }) { @@ -35,11 +35,20 @@ async function processCleanup(month: string): Promise { sheetName, `budget-${category.id}`, ); + const spent = await getSheetValue( + sheetName, + `sum-amount-${category.id}`, + ); await setBudget({ category: category.id, month, amount: budgeted - balance, }); + await setGoal({ + category: category.id, + month, + goal: -spent, + }); num_sources += 1; } if (template.filter(t => t.type === 'sink').length > 0) { diff --git a/upcoming-release-notes/2282.md b/upcoming-release-notes/2282.md new file mode 100644 index 00000000000..e7283528a11 --- /dev/null +++ b/upcoming-release-notes/2282.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [shall0pass] +--- + +Cleanup utility: Update goal target after end of month cleanup tool is activated for 'source' categories