fix(SPG-817): invoice expired not send email
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
parent
efe5661a57
commit
a61f8b853d
|
@ -10,6 +10,7 @@ import { TransactionUpdatedEvent } from 'src/modules/transaction/transaction/dom
|
|||
import { RefundChangeStatusEvent } from 'src/modules/transaction/refund/domain/entities/event/refund-change-status.event';
|
||||
import { RefundCreatedEvent } from 'src/modules/transaction/refund/domain/entities/event/refund-created.event';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
@EventsHandler(
|
||||
TransactionChangeStatusEvent,
|
||||
|
@ -38,7 +39,7 @@ export class PaymentTransactionHandler
|
|||
},
|
||||
});
|
||||
|
||||
const transaction = await this.dataService.getOneByOptions({
|
||||
let transaction = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
id: data_id,
|
||||
},
|
||||
|
@ -50,6 +51,20 @@ export class PaymentTransactionHandler
|
|||
],
|
||||
});
|
||||
|
||||
if (!transaction) {
|
||||
transaction = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
id: event.data.id,
|
||||
},
|
||||
relations: [
|
||||
'items',
|
||||
'refunds',
|
||||
'refunds.refund_items',
|
||||
'refunds.refund_items.transaction_item',
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(transaction, {
|
||||
booking_date: new Date(transaction.booking_date).toDateString(),
|
||||
booking_date_before: new Date(
|
||||
|
@ -101,6 +116,7 @@ export class PaymentTransactionHandler
|
|||
transaction['refund'] &&
|
||||
[STATUS.DRAFT].includes(transaction['refund'].status)
|
||||
) {
|
||||
Logger.verbose('Send Refund Request', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.REFUND_REQUEST,
|
||||
|
@ -130,6 +146,7 @@ export class PaymentTransactionHandler
|
|||
transaction['refund'] &&
|
||||
transaction['refund'].status == STATUS.REFUNDED
|
||||
) {
|
||||
Logger.verbose('Send Refund Confirmation', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.REFUND_CONFIRMATION,
|
||||
|
@ -159,6 +176,7 @@ export class PaymentTransactionHandler
|
|||
old_data.status != current_data.status &&
|
||||
[STATUS.ACTIVE, STATUS.SETTLED].includes(current_data.status)
|
||||
) {
|
||||
Logger.verbose('Send Payment Settled', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.PAYMENT_CONFIRMATION,
|
||||
|
@ -188,6 +206,7 @@ export class PaymentTransactionHandler
|
|||
old_data.status != current_data.status &&
|
||||
[STATUS.PENDING].includes(current_data.status)
|
||||
) {
|
||||
Logger.verbose('Send Confirmation to Pending', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.BOOKING_INVOICE,
|
||||
|
@ -210,13 +229,13 @@ export class PaymentTransactionHandler
|
|||
pdf,
|
||||
);
|
||||
}
|
||||
|
||||
// payment expired
|
||||
else if (
|
||||
!from_refund &&
|
||||
old_data.status != current_data.status &&
|
||||
[STATUS.PENDING, STATUS.EXPIRED].includes(current_data.status)
|
||||
) {
|
||||
Logger.verbose('Send Payment Expired', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.INVOICE_EXPIRED,
|
||||
|
@ -248,6 +267,7 @@ export class PaymentTransactionHandler
|
|||
current_data.status,
|
||||
)
|
||||
) {
|
||||
Logger.verbose('Send Change Booking Date', 'PaymentTransaction');
|
||||
const pdf = await GeneratePdf(
|
||||
transaction,
|
||||
InvoiceType.BOOKING_DATE_CHANGE,
|
||||
|
|
|
@ -60,7 +60,7 @@ export class MidtransCallbackHandler
|
|||
new TransactionChangeStatusEvent({
|
||||
id: data_id,
|
||||
old: old_data,
|
||||
data: data,
|
||||
data: { ...data, status: transaction.status },
|
||||
user: BLANK_USER,
|
||||
description: 'Midtrans Callback',
|
||||
module: TABLE_NAME.TRANSACTION,
|
||||
|
|
Loading…
Reference in New Issue