Skip to content

A local-first personal finance app

[Enhancement] Goal Target with cleanup template (#2282)

shall0pass5d4fcfde00ec
diff --git a/packages/loot-core/src/server/budget/cleanup-template.ts b/packages/loot-core/src/server/budget/cleanup-template.ts
index 43ab6ee2e2..889a155122 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<Notification> {
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 0000000000..e7283528a1
--- /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