Skip to content

Commit

Permalink
fix: change payee rule not working #3702 (#3704)
Browse files Browse the repository at this point in the history
* fix: change payee rule not working #3702

* chore: release note
  • Loading branch information
UnderKoen authored Oct 23, 2024
1 parent 5cf170a commit 5405473
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/loot-core/src/server/accounts/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ export class Action {
} else {
object[this.field] = this.value;
}

if (this.field === 'payee_name') {
object['payee'] = 'new';
}
break;
case 'set-split-amount':
switch (this.options.method) {
Expand Down
18 changes: 10 additions & 8 deletions packages/loot-core/src/server/accounts/transaction-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,17 @@ export async function finalizeTransactionForRules(
trans: TransactionEntity | TransactionForRules,
): Promise<TransactionEntity> {
if ('payee_name' in trans) {
if (trans.payee_name) {
let payeeId = (await getPayeeByName(trans.payee_name))?.id;
payeeId ??= await insertPayee({
name: trans.payee_name,
});
if (trans.payee === 'new') {
if (trans.payee_name) {
let payeeId = (await getPayeeByName(trans.payee_name))?.id;
payeeId ??= await insertPayee({
name: trans.payee_name,
});

trans.payee = payeeId;
} else {
trans.payee = null;
trans.payee = payeeId;
} else {
trans.payee = null;
}
}

delete trans.payee_name;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3704.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [UnderKoen]
---

Fix not being able to change Payee by rules

0 comments on commit 5405473

Please sign in to comment.