fix: increment/decrement uncategorized transactions on excluding

This commit is contained in:
Ahmed Bouhuolia
2024-07-07 23:35:26 +02:00
parent 9a5befbee7
commit b80bc95fa5
2 changed files with 17 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ export class UnexcludeBankTransaction {
public async unexcludeBankTransaction( public async unexcludeBankTransaction(
tenantId: number, tenantId: number,
uncategorizedTransactionId: number uncategorizedTransactionId: number
) { ): Promise<void> {
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId); const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
const oldUncategorizedTransaction = const oldUncategorizedTransaction =
@@ -40,10 +40,13 @@ export class UnexcludeBankTransaction {
validateTransactionNotCategorized(oldUncategorizedTransaction); validateTransactionNotCategorized(oldUncategorizedTransaction);
return this.uow.withTransaction(tenantId, async (trx) => { return this.uow.withTransaction(tenantId, async (trx) => {
await this.eventPublisher.emitAsync(events.bankTransactions.onExcluding, { await this.eventPublisher.emitAsync(
events.bankTransactions.onUnexcluding,
{
tenantId, tenantId,
uncategorizedTransactionId, uncategorizedTransactionId,
} as IBankTransactionExcludingEventPayload); } as IBankTransactionExcludingEventPayload
);
await UncategorizedCashflowTransaction.query(trx) await UncategorizedCashflowTransaction.query(trx)
.findById(uncategorizedTransactionId) .findById(uncategorizedTransactionId)
@@ -51,10 +54,13 @@ export class UnexcludeBankTransaction {
excludedAt: null, excludedAt: null,
}); });
await this.eventPublisher.emitAsync(events.bankTransactions.onExcluded, { await this.eventPublisher.emitAsync(
events.bankTransactions.onUnexcluded,
{
tenantId, tenantId,
uncategorizedTransactionId, uncategorizedTransactionId,
} as IBankTransactionExcludedEventPayload); } as IBankTransactionExcludedEventPayload
);
}); });
} }
} }

View File

@@ -644,7 +644,7 @@ export default {
onExcluding: 'onBankTransactionExclude', onExcluding: 'onBankTransactionExclude',
onExcluded: 'onBankTransactionExcluded', onExcluded: 'onBankTransactionExcluded',
onUnexcluding: 'onBankTransactionExcluding', onUnexcluding: 'onBankTransactionUnexcluding',
onUnexcluded: 'onBankTransactionExcluded', onUnexcluded: 'onBankTransactionUnexcluded',
}, },
}; };