mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-11 10:20:30 +00:00
38 lines
972 B
TypeScript
38 lines
972 B
TypeScript
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.validateMatchingOnExpenseDeleting.bind(this)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Validates the expense transaction whether matched with bank transaction on deleting.
|
|
* @param {IExpenseEventDeletePayload}
|
|
*/
|
|
public async validateMatchingOnExpenseDeleting({
|
|
tenantId,
|
|
oldExpense,
|
|
trx,
|
|
}: IExpenseEventDeletePayload) {
|
|
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
|
tenantId,
|
|
'Expense',
|
|
oldExpense.id,
|
|
trx
|
|
);
|
|
}
|
|
}
|