Commit a092e5fc authored by Volker Krause's avatar Volker Krause
Browse files

Correctly distinguish between SNCF and Ouigo PNRs

In a mixed ticket, you can have two different PNRs, picking the wrong one
will later break merging with the Ouigo ticket.

Also, extract the passenger name while we are at it.

CCBUG: 404451
parent 6cc72c60
...@@ -125,10 +125,12 @@ function parseOuigoConfirmation(html) ...@@ -125,10 +125,12 @@ function parseOuigoConfirmation(html)
{ {
var reservations = new Array(); var reservations = new Array();
var pnr = html.eval("//*[@class=\"pnr-ref\"]/*[@class=\"pnr-info\"]"); var pnr = html.eval('//*[@class="pnr-ref"]/*[@class="pnr-info"]');
var pnrOuigo = html.eval('//*[@class="pnr-info-digital pnr-info-digital-ouigo"]');
var passengerName = html.eval('//*[@class="passenger"]/*[@class="name"]');
var productDts = html.eval("//*[@class=\"product-travel-date\"]"); var productDts = html.eval('//*[@class="product-travel-date"]');
var productDetails = html.eval("//table[@class=\"product-details\"]"); var productDetails = html.eval('//table[@class="product-details"]');
for (productDetailIdx in productDetails) { for (productDetailIdx in productDetails) {
// date is in the table before us // date is in the table before us
var dt = productDts[productDetailIdx].content.replace(/\S+ (.*)/, "$1"); var dt = productDts[productDetailIdx].content.replace(/\S+ (.*)/, "$1");
...@@ -139,10 +141,6 @@ function parseOuigoConfirmation(html) ...@@ -139,10 +141,6 @@ function parseOuigoConfirmation(html)
var cls = segmentDetail.attribute("class"); var cls = segmentDetail.attribute("class");
if (cls.includes("segment-departure")) { if (cls.includes("segment-departure")) {
res = JsonLd.newTrainReservation(); res = JsonLd.newTrainReservation();
if (pnr.length > 0) {
res.reservationNumber = pnr[0].content;
}
res.reservationFor.departureTime = JsonLd.toDateTime(dt + segmentDetail.content, "d MMMMhh'h'mm", "fr"); res.reservationFor.departureTime = JsonLd.toDateTime(dt + segmentDetail.content, "d MMMMhh'h'mm", "fr");
segmentDetail = segmentDetail.nextSibling; segmentDetail = segmentDetail.nextSibling;
res.reservationFor.departureStation.name = segmentDetail.content; res.reservationFor.departureStation.name = segmentDetail.content;
...@@ -151,6 +149,16 @@ function parseOuigoConfirmation(html) ...@@ -151,6 +149,16 @@ function parseOuigoConfirmation(html)
res.reservationFor.arrivalTime = JsonLd.toDateTime(dt + segmentDetail.content, "d MMMMhh'h'mm", "fr"); res.reservationFor.arrivalTime = JsonLd.toDateTime(dt + segmentDetail.content, "d MMMMhh'h'mm", "fr");
segmentDetail = segmentDetail.nextSibling; segmentDetail = segmentDetail.nextSibling;
res.reservationFor.arrivalStation.name = segmentDetail.content; res.reservationFor.arrivalStation.name = segmentDetail.content;
if (res.reservationFor.trainName == "OUIGO" && pnrOuigo.length) {
res.reservationNumber = pnrOuigo[0].content;
} else if (pnr.length) {
res.reservationNumber = pnr[0].content;
}
if (passengerName.length) {
res.underName.name = passengerName[0].content;
}
// HACK drop invalid elements so the structured fallback kicks in correctly // HACK drop invalid elements so the structured fallback kicks in correctly
// this should be done automatically in the engine // this should be done automatically in the engine
if (res.reservationFor.departureTime > 0) if (res.reservationFor.departureTime > 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment