${wagonCells}
@@ -3305,14 +3346,19 @@ export class TrainSchedulingService {
})
.join('')
: '';
- const emptyWagons = wagons.filter((wagon) => (wagon.allocations ?? []).length === 0).length;
+ const emptyWagons = wagons.filter(
+ (wagon) =>
+ (wagon.allocations ?? []).length === 0 &&
+ !emptiesByWagon.get(Number(wagon.sequenceNo))?.length,
+ ).length;
const totalWeight = wagons.reduce(
(sum, wagon) =>
sum + (wagon.allocations ?? []).reduce((wagonSum, allocation) => wagonSum + Number(allocation.allocatedWeightTons || 0), 0),
0,
);
- // Container count summary (40ft, 20ft)
+ // Container count summary (40ft, 20ft) — empties returning to Djibouti are
+ // physically on the train, so they count, and are called out on their own tile.
let count40ft = 0, count20ft = 0;
wagons.forEach((wagon) => {
(wagon.allocations ?? []).forEach((allocation) => {
@@ -3323,6 +3369,11 @@ export class TrainSchedulingService {
});
});
});
+ const emptyContainers = [...emptiesByWagon.values()].flat();
+ for (const empty of emptyContainers) {
+ if (empty.containerSize?.includes('20')) count20ft++;
+ else count40ft++;
+ }
return `
@@ -3378,6 +3429,7 @@ export class TrainSchedulingService {
Containers 40ft${esc(count40ft)}
Containers 20ft${esc(count20ft)}
Total containers${esc(count40ft + count20ft)}
+ ${emptyContainers.length ? `Empty containers${esc(emptyContainers.length)}
` : ''}
Prepared person${esc(schedule.preparedByUserId)}
Check person${esc(schedule.checkedByUserId)}
Wagons${esc(wagons.length)}${emptyWagons ? ` (${emptyWagons} empty)` : ''}