Enhance wagon capacity handling and validation in booking service

- Added default capacities for container and bulk wagons.
- Updated wagonsFor method to consider weight and length for wagon calculations.
- Improved handling of overweight bookings with appropriate warnings.
- Adjusted tests to reflect changes in wagon capacity and validation logic.
This commit is contained in:
Marshal
2026-07-09 13:10:32 +00:00
parent db35b90b45
commit eb819d66a1
6 changed files with 155 additions and 26 deletions

View File

@@ -2802,10 +2802,14 @@ export class TrainSchedulingService {
`Booking ${booking.reference} is within the soft hold window (expires ${booking.holdExpiresAt?.toISOString()})`,
);
}
// Overweight is the soft threshold (maxVgmTons): the customer already
// paid the overweight surcharge at booking. The hard ceiling
// (maxCapacityTons) blocks booking creation, so anything reaching
// scheduling is shippable — warn the planner, never block allocation.
const overweightLines = (booking.bookingContainers ?? []).filter((c) => c.isOverweight);
if (overweightLines.length) {
violations.push(
`Booking ${booking.reference} has overweight container lines; use forceAssign to override`,
warnings.push(
`Booking ${booking.reference} has ${overweightLines.length} overweight container line(s); overweight surcharge applied`,
);
}
}