Commit 8148a47d authored by Volker Krause's avatar Volker Krause
Browse files

Handle SNCF TER booking confirmations

BUG: 439055
CCBUG: 404451
FIXED-IN: 21.08.0
parent 16ff2755
Pipeline #70700 skipped
......@@ -412,3 +412,24 @@ function parseOuigoTicket(pdf, node) {
}
return res;
}
function parseTerConfirmation(html) {
var reservations = new Array();
const refNum = html.eval('//td[@id="referenceContainer"]')[0].content;
const name = html.eval('//td[@id="nomReferenceContainer"]')[0].content;
const journeys = html.eval('//table[@id ="emailTrajet" or @id="emailTrajetRetour"]');
for (const journey of journeys) {
var res = JsonLd.newTrainReservation();
const dt = journey.eval('.//h2')[0].content.match(/ (\d.*)$/)[1];
res.reservationFor.departureDay = JsonLd.toDateTime(dt, "dd MMMM yyyy", "fr");
const ps = journey.eval('.//p');
res.reservationFor.departureStation.name = ps[0].content;
res.reservationFor.departureTime = JsonLd.toDateTime(ps[1].content.match(/ (\d.*)/)[1], "hh'h'mm", "fr");
res.reservationFor.arrivalStation.name = ps[2].content;
res.reservationFor.arrivalTime = JsonLd.toDateTime(ps[3].content.match(/ (\d.*)/)[1], "hh'h'mm", "fr");
res.reservationNumber = refNum;
res.underName.name = name;
reservations.push(res);
}
return reservations;
}
......@@ -14,19 +14,20 @@
}
],
"function": "parsePdf",
"script": "sncf.js",
"mimeType": "application/pdf"
"mimeType": "application/pdf",
"script": "sncf.js"
},
{
"filter": [
{
"match": "^i[01]CV",
"mimeType": "text/plain"
"mimeType": "text/plain",
"scope": "Current"
}
],
"function": "parseSncfBarcode",
"script": "sncf.js",
"mimeType": "text/plain"
"mimeType": "text/plain",
"script": "sncf.js"
},
{
"filter": [
......@@ -38,8 +39,8 @@
}
],
"function": "parseSncfPdfText",
"script": "sncf.js",
"mimeType": "text/plain"
"mimeType": "text/plain",
"script": "sncf.js"
},
{
"filter": [
......@@ -50,8 +51,8 @@
}
],
"function": "parseSecutixPdf",
"script": "sncf.js",
"mimeType": "application/pdf"
"mimeType": "application/pdf",
"script": "sncf.js"
},
{
"filter": [
......@@ -63,8 +64,8 @@
}
],
"function": "parseOuigoEmail",
"script": "sncf.js",
"mimeType": "text/html"
"mimeType": "text/html",
"script": "sncf.js"
},
{
"filter": [
......@@ -76,7 +77,26 @@
}
],
"function": "parseOuigoTicket",
"script": "sncf.js",
"mimeType": "application/pdf"
"mimeType": "application/pdf",
"script": "sncf.js"
},
{
"filter": [
{
"field": "From",
"match": "@ter-sncf.fr",
"mimeType": "message/rfc822",
"scope": "Ancestors"
},
{
"field": "From",
"match": "@ter.fr",
"mimeType": "message/rfc822",
"scope": "Ancestors"
}
],
"function": "parseTerConfirmation",
"mimeType": "text/html",
"script": "sncf.js"
}
]
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