mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
- Added functionality to cancel contracts, allowing users to provide a reason for cancellation. - Updated contract statuses to include SUSPENDED and changed CLOSED to COMPLETED. - Enhanced the UI to reflect the new cancellation option and updated messaging for contract statuses. - Refactored contract booking actions to accommodate changes in booking logic for ONE_TIME and GENERAL contracts. - Removed clearance document management from the contract detail page, as it is now handled per booking. - Introduced a SQL script to reset bookings and train schedules for development purposes.
102 lines
3.5 KiB
TypeScript
102 lines
3.5 KiB
TypeScript
import {
|
|
clearanceSettingCode,
|
|
clearanceOutputSettingCode,
|
|
clearanceCodesForBooking,
|
|
INTERCITY_DOCUMENTS_SETTING_CODE,
|
|
} from './clearance.util';
|
|
import type { Booking } from './entities/booking.entity';
|
|
|
|
describe('clearance.util — clearanceSettingCode', () => {
|
|
it('resolves import container with/without customs', () => {
|
|
expect(clearanceSettingCode('IMPORT', 'CONTAINER', true)).toBe(
|
|
'clearance_import_container_with_customs',
|
|
);
|
|
// Non-customs bookings self-clear with the same document set a ONE_TIME
|
|
// self-clear contract uses.
|
|
expect(clearanceSettingCode('IMPORT', 'CONTAINER', false)).toBe(
|
|
'contract_clearance_selfclear_import_container',
|
|
);
|
|
});
|
|
|
|
it('resolves export bulk with/without customs', () => {
|
|
expect(clearanceSettingCode('EXPORT', 'BULK', true)).toBe(
|
|
'clearance_export_bulk_with_customs',
|
|
);
|
|
expect(clearanceSettingCode('EXPORT', 'BULK', false)).toBe(
|
|
'contract_clearance_selfclear_export_bulk',
|
|
);
|
|
});
|
|
|
|
it('resolves the intercity document set for DOMESTIC regardless of customs/freight', () => {
|
|
expect(clearanceSettingCode('DOMESTIC', 'CONTAINER', true)).toBe(
|
|
INTERCITY_DOCUMENTS_SETTING_CODE,
|
|
);
|
|
expect(clearanceSettingCode('DOMESTIC', 'BULK', false)).toBe(
|
|
INTERCITY_DOCUMENTS_SETTING_CODE,
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('clearance.util — clearanceCodesForBooking (intercity)', () => {
|
|
const base = {
|
|
tradeDirection: 'DOMESTIC',
|
|
freightType: 'CONTAINER',
|
|
serviceType: null,
|
|
customsClearingEnabled: false,
|
|
};
|
|
|
|
it('GENERAL drawdowns and direct bookings carry the per-booking intercity set', () => {
|
|
const general = clearanceCodesForBooking({
|
|
...base,
|
|
contractId: 'c1',
|
|
contractKind: 'GENERAL',
|
|
} as unknown as Booking);
|
|
expect(general.inputCode).toBe(INTERCITY_DOCUMENTS_SETTING_CODE);
|
|
expect(general.outputCode).toBeNull();
|
|
|
|
const direct = clearanceCodesForBooking({
|
|
...base,
|
|
contractId: null,
|
|
contractKind: null,
|
|
} as unknown as Booking);
|
|
expect(direct.inputCode).toBe(INTERCITY_DOCUMENTS_SETTING_CODE);
|
|
});
|
|
|
|
it('ONE_TIME contract shipments carry the same per-booking set', () => {
|
|
// Contracts no longer collect clearance documents — every shipment does,
|
|
// whatever kind of contract it draws on.
|
|
const drawdown = clearanceCodesForBooking({
|
|
...base,
|
|
contractId: 'c1',
|
|
contractKind: 'ONE_TIME',
|
|
} as unknown as Booking);
|
|
expect(drawdown.inputCode).toBe(INTERCITY_DOCUMENTS_SETTING_CODE);
|
|
expect(drawdown.outputCode).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('clearance.util — clearanceOutputSettingCode', () => {
|
|
it('returns a container output code only for customs container bookings', () => {
|
|
expect(clearanceOutputSettingCode('IMPORT', 'CONTAINER', true)).toBe(
|
|
'clearance_output_import_container',
|
|
);
|
|
expect(clearanceOutputSettingCode('EXPORT', 'CONTAINER', true)).toBe(
|
|
'clearance_output_export_container',
|
|
);
|
|
});
|
|
|
|
it('returns null without customs', () => {
|
|
expect(clearanceOutputSettingCode('IMPORT', 'CONTAINER', false)).toBeNull();
|
|
});
|
|
|
|
it('resolves bulk output sets (mirrors container) and returns null for domestic', () => {
|
|
expect(clearanceOutputSettingCode('IMPORT', 'BULK', true)).toBe(
|
|
'clearance_output_import_bulk',
|
|
);
|
|
expect(clearanceOutputSettingCode('EXPORT', 'BULK', true)).toBe(
|
|
'clearance_output_export_bulk',
|
|
);
|
|
expect(clearanceOutputSettingCode('DOMESTIC', 'CONTAINER', true)).toBeNull();
|
|
});
|
|
});
|