A local-first personal finance app
:bug: (import) fix reconciled transactions getting overriden on import (#2140)
Matiss Janis Aboltinsd2b86d100c12
diff --git a/packages/loot-core/src/server/accounts/sync.ts b/packages/loot-core/src/server/accounts/sync.tsindex fe8c077055..862648e4d9 100644--- a/packages/loot-core/src/server/accounts/sync.ts+++ b/packages/loot-core/src/server/accounts/sync.ts@@ -436,7 +436,7 @@ export async function reconcileGoCardlessTransactions(acctId, transactions) {// matched transaction. See the final pass below for the needed// fields.fuzzyDataset = await db.all(- `SELECT id, is_parent, date, imported_id, payee, category, notes FROM v_transactions+ `SELECT id, is_parent, date, imported_id, payee, category, notes, reconciled FROM v_transactionsWHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,[db.toDateRepr(monthUtils.subDays(trans.date, 4)),@@ -494,6 +494,11 @@ export async function reconcileGoCardlessTransactions(acctId, transactions) {// Finally, generate & commit the changesfor (const { trans, subtransactions, match } of transactionsStep3) {if (match) {+ // Skip updating already reconciled (locked) transactions+ if (match.reconciled) {+ continue;+ }+// TODO: change the above sql query to use aqlconst existing = {...match,@@ -594,7 +599,7 @@ export async function reconcileTransactions(acctId, transactions) {// matched transaction. See the final pass below for the needed// fields.fuzzyDataset = await db.all(- `SELECT id, is_parent, date, imported_id, payee, category, notes FROM v_transactions+ `SELECT id, is_parent, date, imported_id, payee, category, notes, reconciled FROM v_transactionsWHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,[db.toDateRepr(monthUtils.subDays(trans.date, 4)),@@ -652,6 +657,11 @@ export async function reconcileTransactions(acctId, transactions) {// Finally, generate & commit the changesfor (const { trans, subtransactions, match } of transactionsStep3) {if (match) {+ // Skip updating already reconciled (locked) transactions+ if (match.reconciled) {+ continue;+ }+// TODO: change the above sql query to use aqlconst existing = {...match,diff --git a/upcoming-release-notes/2140.md b/upcoming-release-notes/2140.mdnew file mode 100644index 0000000000..91b0355db3--- /dev/null+++ b/upcoming-release-notes/2140.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [MatissJanis]+---++Fix imported transactions overriding reconciled (locked) transaction data