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,39 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import {
|
||||
IBillPaymentEventDeletedPayload,
|
||||
IPaymentReceiveDeletedPayload,
|
||||
} from '@/interfaces';
|
||||
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class ValidateMatchingOnPaymentMadeDelete {
|
||||
@Inject()
|
||||
private validateNoMatchingLinkedService: ValidateTransactionMatched;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.billPayment.onDeleting,
|
||||
this.validateMatchingOnPaymentMadeDelete.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {IPaymentReceiveDeletedPayload}
|
||||
*/
|
||||
public async validateMatchingOnPaymentMadeDelete({
|
||||
tenantId,
|
||||
oldBillPayment,
|
||||
trx,
|
||||
}: IBillPaymentEventDeletedPayload) {
|
||||
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
||||
tenantId,
|
||||
'PaymentMade',
|
||||
oldBillPayment.id
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user