Skip to content

Commit

Permalink
don't set undefined price fields
Browse files Browse the repository at this point in the history
  • Loading branch information
traines-source committed Dec 17, 2024
1 parent e05b31e commit 5c5c1ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 14 additions & 7 deletions p/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,28 @@ const mutateToAddTickets = (parsed, opt, j) => {
.filter(s => s.typ == 'REISEANGEBOT' && !s.angebotsbeziehungList.flatMap(b => b.referenzen)
.find(r => r.referenzAngebotsoption == 'PFLICHT'))
.map((s) => {
return {
const p = {
name: s.name,
priceObj: {
amount: Math.round(s.preis?.betrag * 100),
currency: s.preis?.waehrung,
},
addData: s.teilpreis ? 'Teilpreis / partial fare' : undefined,
addDataTicketInfo: s.konditionsAnzeigen?.map(a => a.anzeigeUeberschrift)
.join('. '),
addDataTicketDetails: s.konditionsAnzeigen?.map(a => a.textLang)
.join(' '),
addDataTravelInfo: s.leuchtturmInfo?.text,
firstClass: s.klasse == 'KLASSE_1',
partialFare: s.teilpreis,
};
if (s.teilpreis) {
p.addData = 'Teilpreis / partial fare';
}
if (s.konditionsAnzeigen) {
p.addDataTicketInfo = s.konditionsAnzeigen?.map(a => a.anzeigeUeberschrift)
.join('. ');
p.addDataTicketDetails = s.konditionsAnzeigen?.map(a => a.textLang)
.join(' ');
}
if (s.leuchtturmInfo) {
p.addDataTravelInfo = s.leuchtturmInfo?.text;
}
return p;
});
if (opt.generateUnreliableTicketUrls) {
// TODO
Expand Down
9 changes: 0 additions & 9 deletions test/fixtures/db-refresh-journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,8 @@ const dbJourney = {
amount: 2799,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Train-specific travel. No cancellations',
addDataTicketDetails: 'You can use all trains indicated on your ticket. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket, see there. Your ticket cannot be cancelled.',
addDataTravelInfo: undefined,
firstClass: false,
partialFare: false,
},
Expand All @@ -196,7 +194,6 @@ const dbJourney = {
amount: 3599,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Train-specific travel. No cancellations. No access to the DB Lounge',
addDataTicketDetails: 'You can use all trains indicated on your ticket. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket, see there. Your ticket cannot be cancelled. Your ticket does not entitle you to use the DB Lounge.',
addDataTravelInfo: 'Travel 1st class',
Expand All @@ -209,10 +206,8 @@ const dbJourney = {
amount: 3499,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Train-specific travel. Cancellation subject to a fee before first day of validity',
addDataTicketDetails: 'You can use all trains indicated on your ticket. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket, see there. You can cancel your ticket up to and including 17.12.2024 for a fee of EUR 10,00. You will receive a voucher for the remaining amount. No cancellation thereafter.',
addDataTravelInfo: undefined,
firstClass: false,
partialFare: false,
},
Expand All @@ -222,7 +217,6 @@ const dbJourney = {
amount: 4499,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Train-specific travel. Cancellation subject to a fee before first day of validity. No access to the DB Lounge',
addDataTicketDetails: 'You can use all trains indicated on your ticket. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket, see there. You can cancel your ticket up to and including 17.12.2024 for a fee of EUR 10,00. You will receive a voucher for the remaining amount. No cancellation thereafter. Your ticket does not entitle you to use the DB Lounge.',
addDataTravelInfo: 'Travel 1st class',
Expand All @@ -235,10 +229,8 @@ const dbJourney = {
amount: 13280,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Unrestricted choice of trains. Cancellation free of charge before first day of validity. City-Ticket',
addDataTicketDetails: 'Your ICE ticket lets you take any type of train. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket; see there. You can cancel your ticket free of charge up to and including 17.12.2024. After that, cancellation is available for a fee of EUR 19,00. Your ticket includes a City-Ticket for Berlin, Tarifbereiche A und B and Köln, Stadtgebiet Köln (Tarifgebiet 2100). The City-Ticket is valid in conjunction with your long-distance ticket only when you use it for connecting services in local or regional rail passenger transport (e.g. S-Bahn, RE and RB trains) as part of the through ticket. The City-Ticket is issued together with your Super Sparpreis or Sparpreis ticket, depending on the journey you have booked.',
addDataTravelInfo: undefined,
firstClass: false,
partialFare: false,
},
Expand All @@ -248,7 +240,6 @@ const dbJourney = {
amount: 23910,
currency: 'EUR',
},
addData: undefined,
addDataTicketInfo: 'Unrestricted choice of trains. Cancellation free of charge before first day of validity. City-Ticket. Access to the DB Lounge. Seat included',
addDataTicketDetails: 'Your ICE ticket lets you take any type of train. Your ticket constitutes a continuous contract of carriage in each direction (through ticket). Should you make a passenger rights claim, the ticket will be considered in its entirety. Special rules apply to tickets including City-Ticket; see there. You can cancel your ticket free of charge up to and including 17.12.2024. After that, cancellation is available for a fee of EUR 19,00. Your ticket includes a City-Ticket for Berlin, Tarifbereiche A und B and Köln, Stadtgebiet Köln (Tarifgebiet 2100). The City-Ticket is valid in conjunction with your long-distance ticket only when you use it for connecting services in local or regional rail passenger transport (e.g. S-Bahn, RE and RB trains) as part of the through ticket. The City-Ticket is issued together with your Super Sparpreis or Sparpreis ticket, depending on the journey you have booked. Your ticket entitles you to use the DB Lounge. Your ticket includes a free seat reservation.',
addDataTravelInfo: 'Travel 1st class',
Expand Down

0 comments on commit 5c5c1ac

Please sign in to comment.