Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(booking-import): give the fare keeper reduce an initial value

Maurice5a270abc0552
diff --git a/server/src/nest/booking-import/kitinerary-mapper.ts b/server/src/nest/booking-import/kitinerary-mapper.ts
index 63353c2c0..b90c9422e 100644
--- a/server/src/nest/booking-import/kitinerary-mapper.ts
+++ b/server/src/nest/booking-import/kitinerary-mapper.ts
@@ -870,7 +870,7 @@ function priceRepeatedTotalOnce(items: ParsedBookingItem[]): ParsedBookingItem[]
const repeats = new Set<ParsedBookingItem>();
for (const priced of byReference.values()) {
if (priced.length < 2 || !oneAmount(priced.map(fareOf))) continue;
- const keeper = priced.reduce((first, item) => (departureMs(item) < departureMs(first) ? item : first));
+ const keeper = priced.reduce((first, item) => (departureMs(item) < departureMs(first) ? item : first), priced[0]);
priced.filter((item) => item !== keeper).forEach((item) => repeats.add(item));
}
return repeats.size ? items.map((item) => (repeats.has(item) ? withoutPrice(item) : item)) : items;