🐛 (import) fix reconciled transactions getting overriden on import (#2140)

This commit is contained in:
Matiss Janis Aboltins
2024-01-01 12:44:57 +00:00
committed by GitHub
parent d8996405c4
commit d2b86d100c
2 changed files with 18 additions and 2 deletions

View File

@@ -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)),
@@ -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,
@@ -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)),
@@ -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,

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---
Fix imported transactions overriding reconciled (locked) transaction data