mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 13:38:20 +00:00
Merge pull request #1453 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
This commit is contained in:
@@ -3967,6 +3967,11 @@ export class BookingBatchService implements OnModuleInit {
|
||||
schedulingStatus: "SCHEDULED",
|
||||
scheduledAt: new Date(),
|
||||
wagonsRequired,
|
||||
// Pinned for cancellation pricing: unassign clears wagonsRequired, this
|
||||
// stays. Written once — a later re-allocation keeps the first stamp.
|
||||
...(Number(booking.cancellationWagons ?? 0) > 0
|
||||
? {}
|
||||
: { cancellationWagons: wagonsRequired }),
|
||||
paymentDeadline: null,
|
||||
selectedForBatchAt: null,
|
||||
} as never);
|
||||
|
||||
@@ -39,15 +39,30 @@ export class BookingNotifierService {
|
||||
try {
|
||||
const s = await this.trainSchedules.findByIdWithStations(scheduleId);
|
||||
if (!s) return fallback;
|
||||
const ref = s.reference ?? s.trainNumber ?? null;
|
||||
const route =
|
||||
// Customers know the train by its operating number (8001), not the
|
||||
// schedule reference — lead with it and keep S-… as the secondary id.
|
||||
const parts = [
|
||||
s.reference,
|
||||
s.originStation?.label && s.destinationStation?.label
|
||||
? ` (${s.originStation.label} → ${s.destinationStation.label})`
|
||||
: '';
|
||||
? `${s.originStation.label} → ${s.destinationStation.label}`
|
||||
: null,
|
||||
].filter(Boolean);
|
||||
const detail = parts.length ? ` (${parts.join(', ')})` : '';
|
||||
const departure = s.scheduledDepartureDate
|
||||
? `, departing ${new Date(s.scheduledDepartureDate).toLocaleDateString('en-GB', { timeZone: BATCH_TIMEZONE })}`
|
||||
? `, departing ${new Date(s.scheduledDepartureDate).toLocaleString('en-GB', {
|
||||
timeZone: BATCH_TIMEZONE,
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
})} EAT`
|
||||
: '';
|
||||
return ref ? `train ${ref}${route}${departure}` : `${fallback}${route}${departure}`;
|
||||
const number = s.trainNumber ?? s.reference ?? null;
|
||||
return number
|
||||
? `train ${number}${number === s.reference ? '' : detail}${departure}`
|
||||
: `${fallback}${detail}${departure}`;
|
||||
} catch (err) {
|
||||
this.logger.warn(
|
||||
`scheduleLabel(${scheduleId}) failed: ${(err as Error).message}`,
|
||||
|
||||
@@ -2320,12 +2320,18 @@ export class TrainSchedulingService {
|
||||
// batch fill, which unlinks it and frees its wagons on the next window cycle.
|
||||
const scheduledAt = new Date();
|
||||
for (const booking of bookings) {
|
||||
const wagonsRequired = sumWagonsRequired(booking, wagonPlan);
|
||||
await this.bookingsRepository.updateSchedulingFields(
|
||||
booking.id,
|
||||
{
|
||||
schedulingStatus: SchedulingStatus.Scheduled,
|
||||
scheduledAt,
|
||||
wagonsRequired: sumWagonsRequired(booking, wagonPlan),
|
||||
wagonsRequired,
|
||||
// Pinned for cancellation pricing: unassign clears wagonsRequired,
|
||||
// this stays. Written once — re-allocation keeps the first stamp.
|
||||
...(Number(booking.cancellationWagons ?? 0) > 0
|
||||
? {}
|
||||
: { cancellationWagons: wagonsRequired }),
|
||||
},
|
||||
manager,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user