import type { Contract } from '../entities/contract.entity'; /** Statuses that already mean "done/void" — a contract in one of these never blocks a duplicate. */ export const TERMINAL_CONTRACT_STATUSES = [ 'REJECTED', 'CANCELLED', 'CONTRACT_CLOSED', 'ARCHIVED', 'EXPIRED', ] as const; /** * True once a contract is done, either explicitly (terminal status) or by date * (past contractValidUntil). Checked by date too because the nightly expiry * cron only flips the status once a day — this keeps same-day checks correct * even a few hours before the cron runs. */ export function isEffectivelyExpired( contract: Pick, ): boolean { if ((TERMINAL_CONTRACT_STATUSES as readonly string[]).includes(contract.status)) { return true; } return Boolean(contract.contractValidUntil && contract.contractValidUntil < new Date()); }