diff --git a/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx b/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx index dd173ba3e..565edcc79 100644 --- a/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx @@ -118,11 +118,12 @@ const computeLastMileSteps = ( Boolean(releaseRow?.releaseDate), record.status === "IN_TRANSIT" || record.status === "DELIVERED", exactKm != null, + exactKm != null, // Generate Invoice — auto-generated when distance is saved record.status === "DELIVERED", ]; // Current step = earliest incomplete one. const activeIdx = flags.findIndex((f) => !f); - const labels = ["Ready to Transit", "Assign vehicle", "Truck arrived", "Truck leave", "In transit", "Add distance", "Delivered"]; + const labels = ["Ready to Transit", "Assign vehicle", "Truck arrived", "Truck leave", "In transit", "Add distance", "Generate Invoice", "Delivered"]; const details: (string | null)[] = [ null, record.vehicle?.plateNumber ?? null, @@ -130,6 +131,7 @@ const computeLastMileSteps = ( fmtStamp(releaseRow?.releaseDate), null, exactKm != null ? `${exactKm} KM` : null, + exactKm != null ? "Invoice ready" : null, fmtStamp(releaseRow?.deliveredAt), ]; return labels.map((label, i) => ({ @@ -1004,9 +1006,9 @@ const LastMilePage = () => { const releaseRow = pickupReadyByBooking.get(row.original.bookingId) ?? pickupReadyByBooking.get(bookingRef(row.original)); // Only the current step's action is active; the rest stay disabled. - // Step order: 0 Ready·1 Assign·2 Arrived·3 Leave·4 In-transit·5 Distance·6 Delivered. + // Steps: 0 Ready·1 Assign·2 Arrived·3 Leave·4 In-transit·5 Distance·6 Invoice·7 Delivered. const activeStep = computeLastMileSteps(row.original, releaseRow).findIndex((s) => s.active); - const canAdvance = activeStep === 0 || activeStep === 4 || activeStep === 6; + const canAdvance = activeStep === 0 || activeStep === 4 || activeStep === 7; const canAssignStep = activeStep === 1; const canDistance = activeStep === 5; // Truck arrival/leaving are independent of the step sequence — each