mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 23:35:42 +00:00
add cron jobs and aslo
This commit is contained in:
@@ -113,6 +113,7 @@ export class TrainSchedulingService {
|
||||
originStationId: query.originStationId,
|
||||
destinationStationId: query.destinationStationId,
|
||||
schedulingStatus: query.schedulingStatus,
|
||||
trainScheduleId: query.trainScheduleId,
|
||||
});
|
||||
return { count: bookings.length, items: bookings.map((b) => this.mapEligibleBooking(b)) };
|
||||
}
|
||||
@@ -272,6 +273,20 @@ export class TrainSchedulingService {
|
||||
throw new BadRequestException('Schedule has no train set');
|
||||
}
|
||||
|
||||
// Batch parity: a schedule may only allocate bookings that targeted it. This mirrors
|
||||
// the automatic fill, which only pulls bookings whose train_schedule_id is this schedule.
|
||||
if (dto.bookingIds.length) {
|
||||
const targeted = await this.bookingsRepository.findByIdsForScheduling(dto.bookingIds);
|
||||
const stray = targeted.filter((b) => b.trainScheduleId !== scheduleId);
|
||||
if (stray.length) {
|
||||
throw new BadRequestException(
|
||||
`These bookings are not assigned to this schedule: ${stray
|
||||
.map((b) => b.reference ?? b.id)
|
||||
.join(', ')}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const previewDto = {
|
||||
bookingIds: dto.bookingIds,
|
||||
scheduleDate: schedule.scheduledDepartureDate.toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user