mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { Inject, Service } from 'typedi';
|
|
import {
|
|
IBillPaymentEventDeletedPayload,
|
|
IPaymentReceivedDeletedPayload,
|
|
} 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.validateMatchingOnPaymentMadeDeleting.bind(this)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Validates the payment made transaction whether matched with bank transaction on deleting.
|
|
* @param {IPaymentReceivedDeletedPayload}
|
|
*/
|
|
public async validateMatchingOnPaymentMadeDeleting({
|
|
tenantId,
|
|
oldBillPayment,
|
|
trx,
|
|
}: IBillPaymentEventDeletedPayload) {
|
|
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
|
tenantId,
|
|
'PaymentMade',
|
|
oldBillPayment.id,
|
|
trx
|
|
);
|
|
}
|
|
}
|