mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 13:40:57 +00:00
21 lines
616 B
TypeScript
21 lines
616 B
TypeScript
import type { ScheduleTradeDirection } from '@edr/types';
|
|
|
|
type YardLike = { country?: string | null };
|
|
|
|
/** Derive booking/schedule trade direction from origin and destination yard countries. */
|
|
export function deriveTradeDirection(
|
|
originYard: YardLike,
|
|
destinationYard: YardLike,
|
|
): ScheduleTradeDirection {
|
|
const originCountry = originYard.country?.trim();
|
|
const destinationCountry = destinationYard.country?.trim();
|
|
|
|
if (originCountry === 'Djibouti') {
|
|
return 'IMPORT';
|
|
}
|
|
if (destinationCountry === 'Djibouti' && originCountry !== 'Djibouti') {
|
|
return 'EXPORT';
|
|
}
|
|
return 'DOMESTIC';
|
|
}
|