Skip to content

A local-first personal finance app

Run rules on transactions created by a transfer. (#5279)

Rapha149bd9f0aec89b4
diff --git a/packages/loot-core/src/server/transactions/transfer.ts b/packages/loot-core/src/server/transactions/transfer.ts
index 0158a73bc7..954bfdad87 100644
--- a/packages/loot-core/src/server/transactions/transfer.ts
+++ b/packages/loot-core/src/server/transactions/transfer.ts
@@ -1,6 +1,8 @@
// @ts-strict-ignore
import * as db from '../db';
+import { runRules } from './transaction-rules';
+
async function getPayee(acct) {
return db.first<db.DbPayee>('SELECT * FROM payees WHERE transfer_acct = ?', [
acct,
@@ -56,7 +58,7 @@ export async function addTransfer(transaction, transferredAccount) {
[transaction.account],
);
- const id = await db.insertTransaction({
+ const transferTransaction = {
account: transferredAccount,
amount: -transaction.amount,
payee: fromPayee,
@@ -65,6 +67,12 @@ export async function addTransfer(transaction, transferredAccount) {
notes: transaction.notes || null,
schedule: transaction.schedule,
cleared: false,
+ };
+ const { notes, cleared } = await runRules(transferTransaction);
+ const id = await db.insertTransaction({
+ ...transferTransaction,
+ notes,
+ cleared,
});
await db.updateTransaction({ id: transaction.id, transfer_id: id });
diff --git a/upcoming-release-notes/5279.md b/upcoming-release-notes/5279.md
new file mode 100644
index 0000000000..e75e22a96f
--- /dev/null
+++ b/upcoming-release-notes/5279.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [Rapha149]
+---
+
+Run rules on transactions created by a transfer (only applying to the fields notes and cleared).