mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 07:15:45 +00:00
automate the schedule
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { Booking } from '../bookings/entities/booking.entity';
|
||||
|
||||
/**
|
||||
* Stub notifier for the batch flow — **console.log only** for now.
|
||||
* Injectable so it can later be swapped for the real NotificationsService without
|
||||
* touching the batch engine.
|
||||
*/
|
||||
@Injectable()
|
||||
export class BookingNotifierService {
|
||||
private readonly logger = new Logger('BookingNotifier');
|
||||
|
||||
private ref(b: Booking): string {
|
||||
return `${b.reference}${b.isGovernment ? ' (gov)' : ''}`;
|
||||
}
|
||||
|
||||
payNow(b: Booking, deadline: Date): void {
|
||||
this.logger.log(
|
||||
`PAY NOW — ${this.ref(b)} selected for schedule ${b.trainScheduleId}; pay before ${deadline.toISOString()} (1h).`,
|
||||
);
|
||||
}
|
||||
|
||||
secured(b: Booking, reason: 'paid' | 'gov'): void {
|
||||
this.logger.log(
|
||||
`ALLOCATED — ${this.ref(b)} secured on schedule ${b.trainScheduleId}${
|
||||
reason === 'gov' ? ' (government, unpaid)' : ''
|
||||
}.`,
|
||||
);
|
||||
}
|
||||
|
||||
expired(b: Booking): void {
|
||||
this.logger.warn(
|
||||
`EXPIRED — ${this.ref(b)} did not pay in time; can move to another schedule or cancel (no re-approval).`,
|
||||
);
|
||||
}
|
||||
|
||||
scheduleFull(b: Booking): void {
|
||||
this.logger.warn(
|
||||
`SCHEDULE FULL — ${this.ref(b)} could not be placed; change schedule, pick another day, or cancel.`,
|
||||
);
|
||||
}
|
||||
|
||||
displaced(b: Booking): void {
|
||||
this.logger.warn(
|
||||
`DISPLACED — ${this.ref(b)} bumped by a government booking; move to another schedule or cancel.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user