A local-first personal finance app
feat: fix categories being set on offbudget transactions (#3705)
Koen van Staverena91a8859ab65
diff --git a/packages/loot-core/src/server/accounts/transactions.ts b/packages/loot-core/src/server/accounts/transactions.tsindex a056daac11..c91d0d95f0 100644--- a/packages/loot-core/src/server/accounts/transactions.ts+++ b/packages/loot-core/src/server/accounts/transactions.ts@@ -77,7 +77,13 @@ export async function batchUpdateTransactions({await batchMessages(async () => {if (added) {addedIds = await Promise.all(- added.map(async t => db.insertTransaction(t)),+ added.map(async t => {+ const account = accounts.find(acct => acct.id === t.account);+ if (account.offbudget === 1) {+ t.category = null;+ }+ return db.insertTransaction(t);+ }),);}diff --git a/packages/loot-core/src/server/accounts/transfer.ts b/packages/loot-core/src/server/accounts/transfer.tsindex 04545bf785..f9c8104837 100644--- a/packages/loot-core/src/server/accounts/transfer.ts+++ b/packages/loot-core/src/server/accounts/transfer.ts@@ -26,11 +26,16 @@ async function clearCategory(transaction, transferAcct) {[transferAcct],);- // We should clear the category to make sure it's not being- // accounted for in the budget, unless it should be in the case of- // transferring from an on-budget to off-budget account+ // If the transfer is between two on-budget or two off-budget accounts,+ // we should clear the category, because the category is not relevantif (fromOffBudget === toOffBudget) {await db.updateTransaction({ id: transaction.id, category: null });+ if (transaction.transfer_id) {+ await db.updateTransaction({+ id: transaction.transfer_id,+ category: null,+ });+ }return true;}return false;diff --git a/upcoming-release-notes/3705.md b/upcoming-release-notes/3705.mdnew file mode 100644index 0000000000..d959e9cd07--- /dev/null+++ b/upcoming-release-notes/3705.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [UnderKoen]+---++Fix category being set on off-budget accounts