Skip to content

Commit

Permalink
[End of Month Cleanup] Remove automatic funding of rollover categories (
Browse files Browse the repository at this point in the history
#2409)

* remove automatic funding of rollover categories

* note
  • Loading branch information
shall0pass authored Mar 4, 2024
1 parent 3b77609 commit 601c9aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
42 changes: 0 additions & 42 deletions packages/loot-core/src/server/budget/cleanup-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,48 +118,6 @@ async function processCleanup(month: string): Promise<Notification> {
}
}

//fund rollover categories after non-rollover categories
for (let c = 0; c < categories.length; c++) {
const category = categories[c];
const budgetAvailable = await getSheetValue(sheetName, `to-budget`);
const balance = await getSheetValue(sheetName, `leftover-${category.id}`);
const budgeted = await getSheetValue(sheetName, `budget-${category.id}`);
const to_budget = budgeted + Math.abs(balance);
const categoryId = category.id;
let carryover = await db.first(
`SELECT carryover FROM zero_budgets WHERE month = ? and category = ?`,
[db_month, categoryId],
);

if (carryover === null) {
carryover = { carryover: 0 };
}

if (
balance < 0 &&
Math.abs(balance) <= budgetAvailable &&
!category.is_income &&
carryover.carryover === 1
) {
await setBudget({
category: category.id,
month,
amount: to_budget,
});
} else if (
balance < 0 &&
!category.is_income &&
carryover.carryover === 1 &&
Math.abs(balance) > budgetAvailable
) {
await setBudget({
category: category.id,
month,
amount: budgeted + budgetAvailable,
});
}
}

const budgetAvailable = await getSheetValue(sheetName, `to-budget`);
if (budgetAvailable <= 0) {
warnings.push('No funds are available to reallocate.');
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2409.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [shall0pass]
---

End of month cleanup - revert logic introduced in 2295. Ignore rollover categories.

0 comments on commit 601c9aa

Please sign in to comment.