mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 03:40:56 +00:00
Add migration to repair schema drift and implement contract step banner in UI
This commit is contained in:
@@ -181,6 +181,26 @@ export function computeExportWindowTimes(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Earliest departure a train may be scheduled for — staff cannot schedule inside
|
||||
* the lead window. IMPORT/DOMESTIC lead is in whole EAT days: with lead 3 and
|
||||
* today the 11th, the 12th and 13th are blocked and the 14th is the first
|
||||
* allowed departure day (00:00 EAT). EXPORT lead is in hours: earliest departure
|
||||
* is `now + exportBookingLeadHours` (24h = 1 day). Mirrors the booking-window
|
||||
* math so a schedulable date always has a real booking window before it.
|
||||
*/
|
||||
export function earliestSchedulableDeparture(
|
||||
direction: string | null | undefined,
|
||||
cfg: { importWindowLeadDays: number; exportBookingLeadHours: number },
|
||||
now: Date,
|
||||
): Date {
|
||||
if (direction === 'EXPORT') {
|
||||
return new Date(now.getTime() + cfg.exportBookingLeadHours * 3_600_000);
|
||||
}
|
||||
const earliestDay = shiftEatDay(eatDay(now), cfg.importWindowLeadDays);
|
||||
return eatDayToUtc(earliestDay, 0);
|
||||
}
|
||||
|
||||
/** Which 3h EAT intake window a timestamp (e.g. fullyExecutedAt) belongs to. */
|
||||
export function getBatchWindowForTimestamp(date: Date): BatchWindow {
|
||||
const { year, month, day, hour } = eatParts(date);
|
||||
|
||||
Reference in New Issue
Block a user