add goverment booking

This commit is contained in:
Marshal
2026-07-31 00:41:51 +00:00
parent 34e4a7d13f
commit 65f18b4796
35 changed files with 913 additions and 88 deletions

View File

@@ -139,6 +139,17 @@ export class SchedulingRescheduleService {
actorUserId?: string,
) {
const plan = await this.previewReschedule(scheduleId, dto);
// Gov bookings may never be pushed off a train. Checked here (not only in
// unassignBooking) because the displacement loop below swallows unassign
// errors and force-detaches the booking anyway.
const govDisplaced = plan.displaced.filter((b) => b.isGovernment);
if (govDisplaced.length) {
throw new BadRequestException(
`Government bookings cannot be removed from a train: ${govDisplaced
.map((b) => b.reference)
.join(', ')}`,
);
}
const expectedDisplaced = new Set(plan.displaced.map((b) => b.id));
const providedDisplaced = new Set(dto.displacedBookingIds);
if (