uapi-json icon indicating copy to clipboard operation
uapi-json copied to clipboard

cancelBooking improvement suggestion

Open ukeh opened this issue 3 years ago • 2 comments

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);

}

ukeh avatar Aug 13 '22 10:08 ukeh

@dchertousov please have a look at this

ukeh avatar Aug 13 '22 10:08 ukeh

https://support.travelport.com/webhelp/Smartpoint1G1V/Content/Air/Ticketing/TicketAssistant/TicketAssistant_Void.htm

this document says that " Tickets with an OPEN or ARPT (Airport) status are eligible for voiding". "A" might be used to indicate status ARPT, so is it ok to use 'OVA'.indexOf(coupon.status) === -1 instead of 'OV'.indexOf(coupon.status) === -1?

ukeh avatar Aug 13 '22 13:08 ukeh