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