feat(SPG-818): fix condition transaction status change handler

pull/58/head
Firman Ramdhani 2024-08-07 18:47:08 +07:00
parent 8dd36042eb
commit b57da1d21a
1 changed files with 26 additions and 26 deletions

View File

@ -91,36 +91,36 @@ export class ChangeStatusBookingHandler
const isFromCounter = data.payment_type == TransactionPaymentType.COUNTER; const isFromCounter = data.payment_type == TransactionPaymentType.COUNTER;
const dataID = data?.id; const dataID = data?.id;
if (!isFromCounter) { // if (!isFromCounter) {
const couchData = await this.couchService.getDoc(dataID, 'booking'); const couchData = await this.couchService.getDoc(dataID, 'booking');
const booking = await this.bookingService.getOneByOptions({ const booking = await this.bookingService.getOneByOptions({
where: { where: {
id: data.id, id: data.id,
},
relations: ['items'],
});
mappingTransaction(booking);
if (!couchData) {
await this.couchService.createDoc(
{
_id: booking.id,
...booking,
}, },
relations: ['items'], 'booking',
}); );
mappingTransaction(booking); } else {
await this.couchService.updateDoc(
if (!couchData) { {
await this.couchService.createDoc( _id: booking.id,
{ ...booking,
_id: booking.id, },
...booking, 'booking',
}, );
'booking',
);
} else {
await this.couchService.updateDoc(
{
_id: booking.id,
...booking,
},
'booking',
);
}
} }
} }
// }
} }
@EventsHandler(TransactionUpdatedEvent) @EventsHandler(TransactionUpdatedEvent)