mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat(server): change estimate and receipts status once delivering mail
This commit is contained in:
@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
|
||||
import {
|
||||
PaymentReceiveMailOpts,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
PaymentReceiveMailPresendEvent,
|
||||
SendInvoiceMailDTO,
|
||||
} from '@/interfaces';
|
||||
import Mail from '@/lib/Mail';
|
||||
@@ -13,6 +14,8 @@ import {
|
||||
import { GetPaymentReceive } from './GetPaymentReceive';
|
||||
import { ContactMailNotification } from '@/services/MailNotification/ContactMailNotification';
|
||||
import { parseAndValidateMailOptions } from '@/services/MailNotification/utils';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class SendPaymentReceiveMailNotification {
|
||||
@@ -28,6 +31,9 @@ export class SendPaymentReceiveMailNotification {
|
||||
@Inject('agenda')
|
||||
private agenda: any;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Sends the mail of the given payment receive.
|
||||
* @param {number} tenantId
|
||||
@@ -46,6 +52,13 @@ export class SendPaymentReceiveMailNotification {
|
||||
messageDTO,
|
||||
};
|
||||
await this.agenda.now('payment-receive-mail-send', payload);
|
||||
|
||||
// Triggers `onPaymentReceivePreMailSend` event.
|
||||
await this.eventPublisher.emitAsync(events.paymentReceive.onPreMailSend, {
|
||||
tenantId,
|
||||
paymentReceiveId,
|
||||
messageOptions: messageDTO,
|
||||
} as PaymentReceiveMailPresendEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user