A local-first personal finance app
Update transaction repair tool to remove erroneous transaction errors (#4464)
Julian Dominguez-Schatz1a5f83d78c13
diff --git a/packages/desktop-client/src/components/settings/RepairTransactions.tsx b/packages/desktop-client/src/components/settings/RepairTransactions.tsxindex f48353ddf9..263b3036b7 100644--- a/packages/desktop-client/src/components/settings/RepairTransactions.tsx+++ b/packages/desktop-client/src/components/settings/RepairTransactions.tsx@@ -25,6 +25,7 @@ function useRenderResults() {numDeleted,numTransfersFixed,mismatchedSplits,+ numNonParentErrorsFixed,} = results;const result: string[] = [];@@ -33,6 +34,7 @@ function useRenderResults() {numCleared === 0 &&numDeleted === 0 &&numTransfersFixed === 0 &&+ numNonParentErrorsFixed === 0 &&mismatchedSplits.length === 0) {result.push(t('No split transactions found needing repair.'));@@ -58,6 +60,13 @@ function useRenderResults() {}),);}+ if (numNonParentErrorsFixed > 0) {+ result.push(+ t('Fixed {{count}} non-split transactions with split errors.', {+ count: numNonParentErrorsFixed,+ }),+ );+ }if (numTransfersFixed > 0) {result.push(t('Fixed {{count}} transfers.', {@@ -154,6 +163,10 @@ export function RepairTransactions() {amount. If not, these will be flagged below to allow you to easilylocate and fix the amounts.</li>+ <li>+ Checks for any non-split transactions with erroneous split errors+ and removes the errors if found.+ </li><li>Check if you have any budget transfers that erroneous contain acategory, and remove the category.diff --git a/packages/loot-core/src/server/tools/app.ts b/packages/loot-core/src/server/tools/app.tsindex 60d2327730..1ca92e4f94 100644--- a/packages/loot-core/src/server/tools/app.ts+++ b/packages/loot-core/src/server/tools/app.ts@@ -92,11 +92,22 @@ app.method('tools/fix-split-transactions', async () => {await batchUpdateTransactions({ updated });});+ // 6. Remove transaction errors from non-parent transactions+ const errorRows = await db.all(`+ SELECT id FROM v_transactions_internal WHERE error IS NOT NULL AND is_parent = 0+ `);++ await runMutator(async () => {+ const updated = errorRows.map(({ id }) => ({ id, error: null }));+ await batchUpdateTransactions({ updated });+ });+return {numBlankPayees: blankPayeeRows.length,numCleared: clearedRows.length,numDeleted: deletedRows.length,numTransfersFixed: brokenTransfers.length,+ numNonParentErrorsFixed: errorRows.length,mismatchedSplits,};});diff --git a/packages/loot-core/src/server/tools/types/handlers.d.ts b/packages/loot-core/src/server/tools/types/handlers.d.tsindex ecc0529aa7..2a210ebad2 100644--- a/packages/loot-core/src/server/tools/types/handlers.d.ts+++ b/packages/loot-core/src/server/tools/types/handlers.d.ts@@ -6,6 +6,7 @@ export interface ToolsHandlers {numCleared: number;numDeleted: number;numTransfersFixed: number;+ numNonParentErrorsFixed: number;mismatchedSplits: TransactionEntity[];}>;}diff --git a/upcoming-release-notes/4464.md b/upcoming-release-notes/4464.mdnew file mode 100644index 0000000000..f512d8f249--- /dev/null+++ b/upcoming-release-notes/4464.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [jfdoming]+---++Update transaction repair tool to remove erroneous transaction errors