Skip to content

A local-first personal finance app

Fix suggested payee issues #3317 #3316 (#3318)

Ryan Bianchi7738ea0c0088
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
index 20ba4a1944..ab2a687bb2 100644
--- a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
@@ -1240,7 +1240,9 @@ const Transaction = memo(function Transaction({
focused={focusedField === 'payee'}
/* Filter out the account we're currently in as it is not a valid transfer */
accounts={accounts.filter(account => account.id !== accountId)}
- payees={payees.filter(payee => payee.transfer_acct !== accountId)}
+ payees={payees.filter(
+ payee => !payee.transfer_acct || payee.transfer_acct !== accountId,
+ )}
valueStyle={valueStyle}
transaction={transaction}
subtransactions={subtransactions}
diff --git a/packages/loot-core/src/server/db/index.ts b/packages/loot-core/src/server/db/index.ts
index 9a7fd514b0..04f49ee369 100644
--- a/packages/loot-core/src/server/db/index.ts
+++ b/packages/loot-core/src/server/db/index.ts
@@ -13,6 +13,7 @@ import { v4 as uuidv4 } from 'uuid';
import * as fs from '../../platform/server/fs';
import * as sqlite from '../../platform/server/sqlite';
+import * as monthUtils from '../../shared/months';
import { groupById } from '../../shared/util';
import {
CategoryEntity,
@@ -27,6 +28,7 @@ import {
convertFromSelect,
} from '../aql';
import {
+ toDateRepr,
accountModel,
categoryModel,
categoryGroupModel,
@@ -544,7 +546,9 @@ export function getPayees() {
}
export function getCommonPayees() {
- const threeMonthsAgo = '20240201';
+ const twelveWeeksAgo = toDateRepr(
+ monthUtils.subWeeks(monthUtils.currentDate(), 12),
+ );
const limit = 10;
return all(`
SELECT p.id as id, p.name as name, p.favorite as favorite,
@@ -552,10 +556,11 @@ export function getCommonPayees() {
count(*) as c,
max(t.date) as latest
FROM payees p
- LEFT JOIN v_transactions t on t.payee == p.id
+ LEFT JOIN v_transactions_internal_alive t on t.payee == p.id
WHERE LENGTH(p.name) > 0
+ AND p.tombstone = 0
+ AND t.date > ${twelveWeeksAgo}
GROUP BY p.id
- HAVING latest > ${threeMonthsAgo}
ORDER BY c DESC ,p.transfer_acct IS NULL DESC, p.name
COLLATE NOCASE
LIMIT ${limit}
diff --git a/upcoming-release-notes/3318.md b/upcoming-release-notes/3318.md
new file mode 100644
index 0000000000..7dbb8e41cb
--- /dev/null
+++ b/upcoming-release-notes/3318.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [qedi-r]
+---
+
+Fix display of deleted payees in suggested payee list