fix(SPG-745) Data booking status active dan settled (tipe pembayaran selain counter) belum masuk PoS

fix/data
Aswin Ashar Abdullah 2024-08-02 17:49:11 +07:00
parent 239e2d778a
commit 8eee99fce5
1 changed files with 34 additions and 27 deletions

View File

@ -38,36 +38,43 @@ export class BookingHandler
const old_data = event.data.old; const old_data = event.data.old;
const data = event.data.data; const data = event.data.data;
if (data.payment_type != TransactionPaymentType.COUNTER) return;
const booking = await this.bookingService.getOneByOptions({
where: {
id: data.id,
},
relations: ['items'],
});
mappingTransaction(booking);
if ( if (
old_data?.status != data.status && data.payment_type == TransactionPaymentType.COUNTER ||
[STATUS.PENDING, STATUS.ACTIVE].includes(data.status) ([STATUS.ACTIVE, STATUS.SETTLED].includes(data.status) &&
data.payment_type != TransactionPaymentType.COUNTER)
) { ) {
await this.couchService.createDoc( console.log(data, 'data', old_data);
{ const booking = await this.bookingService.getOneByOptions({
_id: booking.id, where: {
...booking, id: data.id,
}, },
'booking', relations: ['items'],
); });
} else {
await this.couchService.updateDoc( mappingTransaction(booking);
{
_id: booking.id, if (
...booking, (old_data?.status != data.status ||
}, data.payment_type != TransactionPaymentType.COUNTER) &&
'booking', [STATUS.PENDING, STATUS.ACTIVE, STATUS.SETTLED].includes(data.status)
); ) {
console.log('here');
await this.couchService.createDoc(
{
_id: booking.id,
...booking,
},
'booking',
);
} else {
await this.couchService.updateDoc(
{
_id: booking.id,
...booking,
},
'booking',
);
}
} }
} }
} }