Skip to content
Snippets Groups Projects
Unverified Commit 7738ea0c authored by Ryan Bianchi's avatar Ryan Bianchi Committed by GitHub
Browse files

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

parent 8e077e02
No related branches found
No related tags found
No related merge requests found
......@@ -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}
......
......@@ -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}
......
---
category: Bugfix
authors: [qedi-r]
---
Fix display of deleted payees in suggested payee list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment