mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: validate the matched linked transacation on deleting.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { IManualJournalDeletingPayload } from '@/interfaces';
|
||||
import events from '@/subscribers/events';
|
||||
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
|
||||
|
||||
@Service()
|
||||
export class ValidateMatchingOnManualJournalDelete {
|
||||
@Inject()
|
||||
private validateNoMatchingLinkedService: ValidateTransactionMatched;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.manualJournals.onDeleting,
|
||||
this.validateMatchingOnManualJournalDelete.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {IManualJournalDeletingPayload}
|
||||
*/
|
||||
public async validateMatchingOnManualJournalDelete({
|
||||
tenantId,
|
||||
oldManualJournal,
|
||||
trx,
|
||||
}: IManualJournalDeletingPayload) {
|
||||
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
||||
tenantId,
|
||||
'ManualJournal',
|
||||
oldManualJournal.id
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user