mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +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 { IExpenseEventDeletePayload } from '@/interfaces';
|
||||
import events from '@/subscribers/events';
|
||||
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
|
||||
|
||||
@Service()
|
||||
export class ValidateMatchingOnExpenseDelete {
|
||||
@Inject()
|
||||
private validateNoMatchingLinkedService: ValidateTransactionMatched;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.expenses.onDeleting,
|
||||
this.validateMatchingOnExpenseDelete.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {IExpenseEventDeletePayload}
|
||||
*/
|
||||
public async validateMatchingOnExpenseDelete({
|
||||
tenantId,
|
||||
oldExpense,
|
||||
trx,
|
||||
}: IExpenseEventDeletePayload) {
|
||||
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
||||
tenantId,
|
||||
'Expense',
|
||||
oldExpense.id
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user