fix(mcp): update bookings through updateWithCost like REST and the plugin RPC

update_reservation and update_transport accept a type but still called the
bare ReservationsService.update. Only updateWithCost re-files a linked expense
that still carries the category derived from the old type, so changing a
booking from flight to train over MCP left its expense filed under flights
while the same change over REST or RPC moved it. Both tools now call
updateWithCost without a price entry, and send the cost events and the
accommodation change after the commit, as REST does.
This commit is contained in:
Maurice
2026-10-08 15:56:18 +02:00
parent 36a0d1eaba
commit b84867b4c2
3 changed files with 63 additions and 4 deletions
@@ -447,11 +447,15 @@ export class ReservationsMcp {
if (assignment_id != null && !(await this.assignments.getAssignmentForTrip(assignment_id, tripId)))
return errorResult('assignment_id does not belong to this trip.');
const { reservation } = await this.reservations.update(reservationId, tripId, {
// The booking and the linked expenses a type change re-files are one write,
// the same service path REST and the plugin RPC take.
const { reservation, accommodationChanged, costEvents } = await this.reservations.updateWithCost(String(reservationId), String(tripId), {
title, type, reservation_time, reservation_end_time, url, location, confirmation_number, notes, status,
place_id: place_id !== undefined ? place_id ?? undefined : undefined,
assignment_id: assignment_id !== undefined ? assignment_id ?? undefined : undefined,
}, existing);
}, existing, undefined);
if (accommodationChanged) this.guards.safeBroadcast(tripId, 'accommodation:updated', {});
for (const { event, payload } of costEvents) this.guards.safeBroadcast(tripId, event, payload);
this.guards.safeBroadcast(tripId, 'reservation:updated', { reservation });
return ok({ reservation });
}
@@ -860,7 +864,8 @@ export class ReservationsMcp {
if (applied.endpointsChanged) resolvedEndpoints = applied.endpoints;
}
const { reservation } = await this.reservations.update(reservationId, tripId, {
// One write with the linked expenses a type change re-files, as on update_reservation.
const { reservation, accommodationChanged, costEvents } = await this.reservations.updateWithCost(String(reservationId), String(tripId), {
title,
type,
reservation_time: departureTime,
@@ -874,7 +879,9 @@ export class ReservationsMcp {
metadata: nextMetadata,
endpoints: resolvedEndpoints,
needs_review,
}, existing);
}, existing, undefined);
if (accommodationChanged) this.guards.safeBroadcast(tripId, 'accommodation:updated', {});
for (const { event, payload } of costEvents) this.guards.safeBroadcast(tripId, event, payload);
this.guards.safeBroadcast(tripId, 'reservation:updated', { reservation });
return ok({ reservation });
}