From e0fb345a48f7054343f299dec257adcc0ffabecc Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Fri, 16 Jan 2026 18:49:27 +0200 Subject: [PATCH] fix: improve banking transaction exclude/unexclude logic --- .../commands/UnexcludeBankTransaction.service.ts | 12 +++++++----- .../DecrementUncategorizedTransactionOnExclude.ts | 4 ++-- packages/webapp/src/hooks/query/bank-rules.ts | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts index 86e5f4525..3a3ec6d75 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts @@ -4,8 +4,8 @@ import { validateTransactionShouldBeExcluded, } from './utils'; import { - IBankTransactionExcludedEventPayload, - IBankTransactionExcludingEventPayload, + IBankTransactionUnexcludedEventPayload, + IBankTransactionUnexcludingEventPayload, } from '../types/BankTransactionsExclude.types'; import { EventEmitter2 } from '@nestjs/event-emitter'; import { Inject, Injectable } from '@nestjs/common'; @@ -24,7 +24,7 @@ export class UnexcludeBankTransactionService { private readonly uncategorizedBankTransactionModel: TenantModelProxy< typeof UncategorizedBankTransaction >, - ) {} + ) { } /** * Marks the given bank transaction as excluded. @@ -50,7 +50,8 @@ export class UnexcludeBankTransactionService { return this.uow.withTransaction(async (trx: Knex.Transaction) => { await this.eventEmitter.emitAsync(events.bankTransactions.onUnexcluding, { uncategorizedTransactionId, - } as IBankTransactionExcludingEventPayload); + trx, + } as IBankTransactionUnexcludingEventPayload); await this.uncategorizedBankTransactionModel() .query(trx) @@ -61,7 +62,8 @@ export class UnexcludeBankTransactionService { await this.eventEmitter.emitAsync(events.bankTransactions.onUnexcluded, { uncategorizedTransactionId, - } as IBankTransactionExcludedEventPayload); + trx, + } as IBankTransactionUnexcludedEventPayload); }); } } diff --git a/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts b/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts index ce56b324f..fc97d259a 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts @@ -19,7 +19,7 @@ export class DecrementUncategorizedTransactionOnExclude { private readonly uncategorizedBankTransaction: TenantModelProxy< typeof UncategorizedBankTransaction >, - ) {} + ) { } /** * Validates the cashflow transaction whether matched with bank transaction on deleting. @@ -50,7 +50,7 @@ export class DecrementUncategorizedTransactionOnExclude { trx, }: IBankTransactionUnexcludedEventPayload) { const transaction = await this.uncategorizedBankTransaction() - .query() + .query(trx) .findById(uncategorizedTransactionId); // await this.account() diff --git a/packages/webapp/src/hooks/query/bank-rules.ts b/packages/webapp/src/hooks/query/bank-rules.ts index 04c0a451d..65caefb74 100644 --- a/packages/webapp/src/hooks/query/bank-rules.ts +++ b/packages/webapp/src/hooks/query/bank-rules.ts @@ -424,7 +424,7 @@ export function useUnexcludeUncategorizedTransactions( UnexcludeBankTransactionsValue >( (value: { ids: Array }) => - apiRequest.delete(`/banking/exclude/bulk`, { ids: value.ids }), + apiRequest.delete(`/banking/exclude/bulk`, { data: { ids: value.ids } }), { onSuccess: (res, id) => { onValidateExcludeUncategorizedTransaction(queryClient);