update booking process for customs clearance contracts, allowing customers to create bookings post-clearance finalization

This commit is contained in:
Marshal
2026-06-28 21:47:40 +00:00
parent f45d260c53
commit 506b269207
6 changed files with 43 additions and 42 deletions

View File

@@ -1,6 +1,5 @@
import {
BadRequestException,
ForbiddenException,
Injectable,
NotFoundException,
} from '@nestjs/common';
@@ -192,18 +191,15 @@ export class ContractBookingService {
*/
private async assertGate(contract: Contract, isGlActor: boolean): Promise<string> {
if (contract.customsClearingEnabled) {
// Path B — GL Ethiopia only.
if (!isGlActor) {
throw new ForbiddenException(
'Only Global Logistics Ethiopia can create bookings for customs-clearance contracts.',
);
}
// Path B — the customer creates the booking once GL has finalized the
// pre-booking clearance (GL "create booking" was removed; clearance ends
// at finalize and hands the booking back to the customer).
if (contract.clearanceStatus !== 'CLEARANCE_READY_FOR_BOOKING') {
throw new BadRequestException(
'Contract clearance is not ready for booking yet.',
);
}
return 'GL_ET';
return isGlActor ? 'GL_ET' : 'CUSTOMER';
}
// Path A — customer (or staff) once the contract is executed.