feat: validate the matched linked transacation on deleting.

This commit is contained in:
Ahmed Bouhuolia
2024-06-23 14:34:40 +02:00
parent ca403872b3
commit 589b29bbdd
18 changed files with 307 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
import { Inject, Service } from 'typedi';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import UnitOfWork from '@/services/UnitOfWork';
import events from '@/subscribers/events';
import { Inject, Service } from 'typedi';
import { IBankTransactionUnmatchingEventPayload } from './types';
@Service()
@@ -16,10 +16,16 @@ export class UnmatchMatchedBankTransaction {
@Inject()
private eventPublisher: EventPublisher;
/**
* Unmatch the matched the given uncategorized bank transaction.
* @param {number} tenantId
* @param {number} uncategorizedTransactionId
* @returns {Promise<void>}
*/
public unmatchMatchedTransaction(
tenantId: number,
uncategorizedTransactionId: number
) {
): Promise<void> {
const { MatchedBankTransaction } = this.tenancy.models(tenantId);
return this.uow.withTransaction(tenantId, async (trx) => {