Files
edr-platform/apps/edr-freight-api/src/migrations/1827000000000-CreateBookingRequests.ts
Marshal 0f7cac2b68 add booking request functionality for GENERAL customs contracts
- Create migration for booking_requests table with necessary fields and indexes.
- Implement BookingRequestRepository for database operations related to booking requests.
- Develop BookingRequestService to handle business logic for submitting, accepting, rejecting, and canceling booking requests.
- Create DTOs for creating booking requests and reviewing them.
- Define BookingRequest entity to map to the booking_requests table.
- Add UI components for managing shipment requests, including detail and list pages.
- Implement OperationDatePicker component for selecting available shipment days.
2026-06-29 09:30:44 +00:00

76 lines
3.1 KiB
TypeScript

import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
/**
* Customer shipment requests for GENERAL customs (Path B) contracts. The customer
* submits date + quantities; Global Logistics reviews, then creates the booking
* on their behalf and per-booking clearance begins. Additive — no change to
* existing tables; ONE_TIME contracts are unaffected.
*/
export class CreateBookingRequests1827000000000 implements MigrationInterface {
name = 'CreateBookingRequests1827000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
schema: 'freight',
name: 'booking_requests',
columns: [
{ name: 'id', type: 'uuid', isPrimary: true, generationStrategy: 'uuid', default: 'gen_random_uuid()' },
{ name: 'reference', type: 'varchar', length: '40', default: "''" },
{ name: 'contract_id', type: 'uuid' },
{ name: 'requested_by_user_id', type: 'uuid', isNullable: true },
{ name: 'contract_route_id', type: 'uuid', isNullable: true },
{ name: 'scheduled_date', type: 'timestamptz', isNullable: true },
{ name: 'status', type: 'varchar', length: '16', default: "'PENDING'" },
{ name: 'requested_lines', type: 'jsonb', default: "'{}'::jsonb" },
{ name: 'notes', type: 'text', isNullable: true },
{ name: 'created_booking_id', type: 'uuid', isNullable: true },
{ name: 'reviewed_by_staff_id', type: 'uuid', isNullable: true },
{ name: 'reviewed_at', type: 'timestamptz', isNullable: true },
{ name: 'review_note', type: 'text', isNullable: true },
{ name: 'created_at', type: 'timestamptz', default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', default: 'now()' },
{ name: 'deleted_at', type: 'timestamptz', isNullable: true },
],
foreignKeys: [
{
columnNames: ['contract_id'],
referencedSchema: 'freight',
referencedTableName: 'contracts',
referencedColumnNames: ['id'],
onDelete: 'CASCADE',
},
{
columnNames: ['created_booking_id'],
referencedSchema: 'freight',
referencedTableName: 'bookings',
referencedColumnNames: ['id'],
onDelete: 'SET NULL',
},
],
}),
true,
);
await queryRunner.createIndex(
'freight.booking_requests',
new TableIndex({ name: 'idx_booking_requests_contract', columnNames: ['contract_id'] }),
);
await queryRunner.createIndex(
'freight.booking_requests',
new TableIndex({ name: 'idx_booking_requests_status', columnNames: ['status'] }),
);
await queryRunner.createIndex(
'freight.booking_requests',
new TableIndex({
name: 'idx_booking_requests_contract_status',
columnNames: ['contract_id', 'status'],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('freight.booking_requests', true);
}
}