Skip to content

Commit

Permalink
[Enhancement] Goal Target with cleanup template (#2282)
Browse files Browse the repository at this point in the history
* update goal target after montly cleanup

* release note
  • Loading branch information
shall0pass authored Jan 31, 2024
1 parent 54d7e54 commit 5d4fcfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/loot-core/src/server/budget/cleanup-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2282.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [shall0pass]
---

Cleanup utility: Update goal target after end of month cleanup tool is activated for 'source' categories

0 comments on commit 5d4fcfd

Please sign in to comment.