Skip to content

Commit

Permalink
🐛 (import) fix reconciled transactions getting overriden on import (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Jan 1, 2024
1 parent d899640 commit d2b86d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/loot-core/src/server/accounts/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
Expand Down Expand Up @@ -494,6 +494,11 @@ export async function reconcileGoCardlessTransactions(acctId, transactions) {
// Finally, generate & commit the changes
for (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 aql
const existing = {
...match,
Expand Down Expand Up @@ -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_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
Expand Down Expand Up @@ -652,6 +657,11 @@ export async function reconcileTransactions(acctId, transactions) {
// Finally, generate & commit the changes
for (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 aql
const existing = {
...match,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2140.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix imported transactions overriding reconciled (locked) transaction data

0 comments on commit d2b86d1

Please sign in to comment.