Skip to content

Commit

Permalink
Change lookback and look forward time range when fuzzy matching (#2300)
Browse files Browse the repository at this point in the history
Change to 7 days prior and after for imported transactions when fuzzy matching
  • Loading branch information
yoyotogblo authored Feb 3, 2024
1 parent e3a8366 commit d376221
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/loot-core/src/server/accounts/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,16 @@ export async function reconcileExternalTransactions(acctId, transactions) {

// If it didn't match, query data needed for fuzzy matching
if (!match) {
// Look 1 day ahead and 4 days back when fuzzy matching. This
// Look 7 days ahead and 7 days back when fuzzy matching. This
// needs to select all fields that need to be read from the
// 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, reconciled FROM v_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ?`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
db.toDateRepr(monthUtils.addDays(trans.date, 1)),
db.toDateRepr(monthUtils.subDays(trans.date, 7)),
db.toDateRepr(monthUtils.addDays(trans.date, 7)),
trans.amount || 0,
acctId,
],
Expand Down Expand Up @@ -631,16 +631,16 @@ export async function reconcileTransactions(acctId, transactions) {

// If it didn't match, query data needed for fuzzy matching
if (!match) {
// Look 1 day ahead and 4 days back when fuzzy matching. This
// Look 7 days ahead and 7 days back when fuzzy matching. This
// needs to select all fields that need to be read from the
// 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, reconciled FROM v_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ?`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
db.toDateRepr(monthUtils.addDays(trans.date, 1)),
db.toDateRepr(monthUtils.subDays(trans.date, 7)),
db.toDateRepr(monthUtils.addDays(trans.date, 7)),
trans.amount || 0,
acctId,
],
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2300.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [yoyotogblo]
---

Change lookback and look forward time range when fuzzy matching

0 comments on commit d376221

Please sign in to comment.