fix(costs): an expense made from a booking is dated on the booking day

Creating the expense from a booking opened the editor on today, and the
cost a booking import writes by itself had no date at all, so it sat under
"No date". Both now take the booking's own date, else a hotel's check-in
day, else the day the booking sits on. The server sets it for every
booking write that creates a cost, so REST, MCP, plugin RPC and the import
agree.

A start time typed on a booking with no day picked no longer borrows
today's date on desktop. Today was mostly outside the trip, the server
then moved the booking onto day 1 while the list kept today. Desktop now
does what the phone already did and keeps the time without a date.

Refs #2604
This commit is contained in:
Maurice
2026-10-12 15:04:22 +02:00
parent 33e606959c
commit 9064dbb2f0
12 changed files with 165 additions and 29 deletions
@@ -176,6 +176,18 @@ export function withStartDate(reservationTime: string, date: string | null | und
return date ? (time ? `${date}T${time}` : date) : '';
}
/**
* The date a start time typed on an undated booking falls on: the day the booking is
* being added to, else none. Never today, which is mostly not a trip day at all and
* was then moved onto the first one, so the list and the plan disagreed (#2604).
*/
export function selectedDayDate(
days: Pick<Day, 'id' | 'date'>[],
selectedDayId: number | string | null | undefined
): string {
return (selectedDayId != null && days.find((d) => d.id === selectedDayId)?.date) || '';
}
/** The start with a new time, on its own date or `fallbackDate` when it has none. */
export function withStartTime(reservationTime: string, time: string, fallbackDate: string): string {
const date = startParts(reservationTime).date || fallbackDate;