2020-03-18 21:35:43 +01:00
|
|
|
// todo: generate from https://reiseauskunft.bahn.de/addons/fachkonfig-utf8.cfg ?
|
2017-11-12 23:51:39 +01:00
|
|
|
const c = {
|
2021-03-25 12:39:00 +01:00
|
|
|
NONE: Symbol('no loyalty card'),
|
2017-11-12 23:51:39 +01:00
|
|
|
BAHNCARD: Symbol('Bahncard'),
|
|
|
|
VORTEILSCARD: Symbol('VorteilsCard'),
|
|
|
|
HALBTAXABO: Symbol('HalbtaxAbo'),
|
|
|
|
VOORDEELURENABO: Symbol('Voordeelurenabo'),
|
|
|
|
SHCARD: Symbol('SH-Card'),
|
2024-02-06 22:58:49 +01:00
|
|
|
GENERALABONNEMENT: Symbol('General-Abonnement'),
|
|
|
|
};
|
2017-11-12 23:51:39 +01:00
|
|
|
|
|
|
|
// see https://gist.github.com/juliuste/202bb04f450a79f8fa12a2ec3abcd72d
|
|
|
|
const formatLoyaltyCard = (data) => {
|
|
|
|
if (data.type === c.BAHNCARD) {
|
2024-02-06 22:58:49 +01:00
|
|
|
if (data.discount === 25) {
|
|
|
|
return data.class === 1
|
|
|
|
? 1
|
|
|
|
: 2;
|
|
|
|
}
|
|
|
|
if (data.discount === 50) {
|
|
|
|
return data.class === 1
|
|
|
|
? 3
|
|
|
|
: 4;
|
|
|
|
}
|
2017-11-12 23:51:39 +01:00
|
|
|
}
|
2024-02-06 22:58:49 +01:00
|
|
|
if (data.type === c.VORTEILSCARD) {
|
|
|
|
return 9;
|
|
|
|
}
|
|
|
|
if (data.type === c.HALBTAXABO) {
|
|
|
|
return data.railplus
|
|
|
|
? 10
|
|
|
|
: 11;
|
|
|
|
}
|
|
|
|
if (data.type === c.VOORDEELURENABO) {
|
|
|
|
return data.railplus
|
|
|
|
? 12
|
|
|
|
: 13;
|
|
|
|
}
|
|
|
|
if (data.type === c.SHCARD) {
|
|
|
|
return 14;
|
|
|
|
}
|
|
|
|
if (data.type === c.GENERALABONNEMENT) {
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
};
|
2017-11-12 23:51:39 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
c as data,
|
|
|
|
formatLoyaltyCard,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|