import { BookingApprovalStep } from './entities/booking-approval-step.entity'; import { Booking } from './entities/booking.entity'; export interface BookingNextStep { action: string; description: string; requiredRole?: string; } export function computeNextStep( booking: Pick, nextPendingStep?: Pick | null, ): BookingNextStep | null { const { status } = booking; switch (status) { case 'SUBMITTED': return { action: 'ACCEPT_INTAKE', description: 'Line Staff must accept the submission to begin approval', }; case 'PENDING_APPROVAL': case 'APPROVED_PENDING_SIGNATURE': if (nextPendingStep) { return { action: 'APPROVE_STEP', requiredRole: nextPendingStep.requiredRole, description: `${nextPendingStep.requiredRole} must approve step ${nextPendingStep.stepOrder}`, }; } return { action: 'APPROVE_STEP', description: 'Complete the pending approval step in sequence', }; case 'APPROVED': return { action: 'CUSTOMER_SIGN', description: 'Contract generated; customer must sign', }; case 'CONTRACT_READY': return { action: 'CUSTOMER_SIGN', description: 'Customer must sign the contract', }; case 'SIGNED_CUSTOMER': return { action: 'STAFF_SIGN', description: 'Internal staff must counter-sign the contract', }; case 'FULLY_EXECUTED': return { action: 'AWAIT_PAYMENT', description: 'Awaiting customer payment', }; case 'PAID': return { action: 'START_TRANSIT', description: 'Mark shipment as in transit', }; case 'IN_TRANSIT': return { action: 'COMPLETE', description: 'Mark shipment complete', }; default: return null; } }