Implement clearance-first booking flow and completion process for customs contracts

This commit is contained in:
Marshal
2026-07-10 18:56:39 +00:00
parent b50075dc83
commit 9ed473c309
18 changed files with 369 additions and 39 deletions

View File

@@ -113,6 +113,17 @@ export class BookingRequestService {
},
};
// Clearance-first flow: the request immediately initiates a BARE booking
// instance (no cargo, no date, no price) that enters per-booking phased
// customs clearance. GL no longer screens the request up front — it
// reviews the documents in the clearance queue and completes the booking
// (container numbers, VGM, shipment day) once clearance is ready. The
// instance is created first so a failure leaves no half-linked request.
const booking = await this.contractBookingService.initiateForShipmentRequest(
contract,
{ contractRouteId: dto.contractRouteId, userId },
);
const reference = await this.generateReference();
const request = await this.repo.create({
reference,
@@ -120,7 +131,8 @@ export class BookingRequestService {
requestedByUserId: userId ?? null,
contractRouteId: dto.contractRouteId ?? null,
scheduledDate: dto.scheduledDate ? new Date(dto.scheduledDate) : null,
status: 'PENDING',
status: 'ACCEPTED',
createdBookingId: booking.id,
requestedLines,
notes: dto.notes ?? null,
} as never);