-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
File: Air.js
checkTickets() inside cancelBooking() can be improved by
const checkTickets = (tickets = []) => {
const promiseChain = [];
for (let ticketData of tickets) {
// Check for VOID or REFUND
const allTicketsVoidOrRefund = ticketData.tickets.every(
ticket => ticket.coupons.every(
coupon => coupon.status === 'V' || coupon.status === 'R'
)
);
if (allTicketsVoidOrRefund) {
continue;
}
if (cancelTickets !== true) {
throw new AirRuntimeError.PNRHasOpenTickets({ tickets });
}
// Check for not OPEN/VOID segments
const hasNotOpenSegment = ticketData.tickets.some(
ticket => ticket.coupons.some(
coupon => 'OV'.indexOf(coupon.status) === -1
)
);
if (hasNotOpenSegment) {
throw new AirRuntimeError.UnableToCancelTicketStatusNotOpen();
}
for (let ticket of ticketData.tickets) {
if (ticket.coupons[0].status !== 'V') {
promiseChain.push(service.cancelTicket({ pnr, ticketNumber: ticket.ticketNumber }));
}
}
}
return Promise.all(promiseChain);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels