This commit is contained in:
Marshal
2026-07-07 12:28:47 +00:00
parent 1c18fdbd52
commit f300600bfa
63 changed files with 2587 additions and 428 deletions

View File

@@ -202,15 +202,22 @@ export class GlOperationsService {
.findOne({ where: { id: booking.trainScheduleId } });
}
// Per-booking journey first: a booking rides only its own leg, so ITS
// loaded/arrived timestamps gate clearance — a Dire→Djibouti booking that
// unloaded at its own destination clears while the train keeps rolling,
// and a booking still on board does NOT clear just because the train
// arrived. The schedule actuals remain only as fallback for legacy
// in-flight bookings that predate per-booking load/unload (no loadedAt).
const departedAt = booking.loadedAt ?? schedule?.actualDepartureAt ?? null;
const arrivedAt =
booking.arrivedAt ??
(booking.loadedAt ? null : (schedule?.actualArrivalAt ?? null));
return {
scheduleId: schedule?.id ?? null,
wagonAllocated,
departedAt: schedule?.actualDepartureAt
? new Date(schedule.actualDepartureAt).toISOString()
: null,
arrivedAt: schedule?.actualArrivalAt
? new Date(schedule.actualArrivalAt).toISOString()
: null,
departedAt: departedAt ? new Date(departedAt).toISOString() : null,
arrivedAt: arrivedAt ? new Date(arrivedAt).toISOString() : null,
};
}
@@ -278,7 +285,7 @@ export class GlOperationsService {
/**
* GL Djibouti uploads T1 transport documents (multi-file) once the gate pass
* is secured on the train schedule (which itself follows wagon allocation).
* Replaces the previous batch; locked once the train departs or T1 is closed.
* Replaces the previous batch; locked only once GL Ethiopia closes the T1.
*/
async uploadT1Documents(
bookingId: string,
@@ -304,11 +311,8 @@ export class GlOperationsService {
if (state.closed) {
throw new BadRequestException('T1 has been closed by GL Ethiopia — documents are final.');
}
if (state.trainDepartedAt) {
throw new BadRequestException(
'The train has departed — T1 transport documents can no longer be changed.',
);
}
// Departure no longer locks T1 docs — GL DJ may replace them any time until
// GL Ethiopia closes/accepts the T1.
await persistT1TransportUploads(this.filesService, bookingId, files);
return { uploaded: files.length };

View File

@@ -276,6 +276,7 @@ export const PHASED_CUSTOMS_BOOKING_QUEUE_STATUSES = [
'OPERATION_CHANGES_REQUESTED',
'ROAD_DISPATCH_PENDING',
'IN_TRANSIT',
'ARRIVED',
'PAID',
'COMPLETED',
'CONTRACT_ACTIVE',