fix(pdf): order a day's bookings in the overview by the clock in 12h too

The booking list sorted on the printed time, so for a 12h reader 1:00 PM and 10:00 AM came before 9:30 AM.
This commit is contained in:
Maurice
2026-11-23 15:06:32 +01:00
parent cd32f07bf5
commit 97c0d992c8
2 changed files with 17 additions and 2 deletions
+13
View File
@@ -751,6 +751,19 @@ describe('downloadTripPDF remaining branches', () => {
expect(html).not.toContain('16:45')
})
it('FE-W5PDF-035: the overview lists a day of bookings by the clock, also in 12h', async () => {
const booking = (id: number, title: string, time: string) => ({
id, title, type: 'tour', day_id: 10, reservation_time: `2025-06-01T${time}`,
})
await downloadTripPDF(at('14:30', {
timeFormat: '12h',
reservations: [booking(701, 'Afternoon tour', '13:00'), booking(702, 'Late morning tour', '10:00'), booking(703, 'Morning tour', '09:30')],
}) as never)
const doc = new DOMParser().parseFromString(srcdoc(), 'text/html')
const titles = [...doc.querySelectorAll('.ledger .ledger-title')].map(el => el.textContent)
expect(titles).toEqual(['Morning tour', 'Late morning tour', 'Afternoon tour'])
})
it('FE-W5PDF-032: a 24h reader gets the same times without a meridiem', async () => {
await downloadTripPDF(at('14:30', { timeFormat: '24h' }) as never)
const html = srcdoc()
+4 -2
View File
@@ -369,10 +369,12 @@ export async function downloadTripPDF({ trip, days, places, assignments: allStor
.filter(r => r.type !== 'hotel' && r.day_id != null && dayNumberOf.has(r.day_id))
.map((r: PdfBooking) => {
const day = dayNumberOf.get(r.day_id ?? -1)
const time = fmtTime(splitReservationDateTime(day ? getDisplayTimeForDay(r, day.id) : null).time)
// Sorted on the stored 24h clock: the printed 12h one puts 1:00 PM before 9:30 AM.
const clock = splitReservationDateTime(day ? getDisplayTimeForDay(r, day.id) : null).time
const time = fmtTime(clock)
return {
order: orderOf(r.day_id),
minute: time,
minute: clock || '',
icon: bookingIcon(r.type, 13),
tint: hexColour(bookingTint(r.type), '#6b6b75'),
title: r.title || '',