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

@@ -502,6 +502,31 @@ export const contractsService = {
};
},
/**
* Complete a bare initiated booking instance once its per-booking clearance
* is CLEARANCE_READY — same payload as create; the API persists cargo,
* prices, invoices, checks the booking window and moves the booking to the
* operations queue.
*/
completeBookingUnderContract: async (
id: string,
bookingId: string,
payload: Freight.CreateBookingUnderContractDto,
): Promise<{ id: string; reference: string; warnings?: string[] }> => {
const result = await postContract<{
booking?: { id: string; reference: string };
id?: string;
reference?: string;
warnings?: string[];
}>(C.BOOKINGS_COMPLETE(id, bookingId), payload);
const booking = result.booking ?? result;
return {
id: booking.id ?? "",
reference: booking.reference ?? "",
warnings: result.warnings,
};
},
/**
* Pre-create validation + authoritative price preview: the same
* BookingPricingService pass that prices the booking on create (rail +