Skip to content

Commit

Permalink
Fix suggested payee issues #3317 #3316 (#3318)
Browse files Browse the repository at this point in the history
  • Loading branch information
qedi-r authored Aug 30, 2024
1 parent 8e077e0 commit 7738ea0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 8 additions & 3 deletions packages/loot-core/src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,6 +28,7 @@ import {
convertFromSelect,
} from '../aql';
import {
toDateRepr,
accountModel,
categoryModel,
categoryGroupModel,
Expand Down Expand Up @@ -544,18 +546,21 @@ 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,
p.category as category, TRUE as common, NULL as transfer_acct,
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}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3318.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [qedi-r]
---

Fix display of deleted payees in suggested payee list

0 comments on commit 7738ea0

Please sign in to comment.