fix issues

This commit is contained in:
Marshal
2026-08-28 10:34:02 +00:00
parent ba56974e32
commit 3015de7508
14 changed files with 435 additions and 49 deletions

View File

@@ -836,15 +836,15 @@ export class BookingWagonCancellationService {
)
.where('alloc.booking_id = :bookingId', { bookingId })
.getMany();
const loaded = allocations.filter(
(a) => a.status === 'LOADED' || a.status === 'DEPARTED',
);
const remaining = allocations.filter(
(a) => a.status !== 'LOADED' && a.status !== 'DEPARTED',
);
if (!loaded.length) {
// A booking whose cargo never showed up at all (0 loaded) is cancelled the
// same way — the gate that holds the train does not care whether loading
// started, only that nothing is left unresolved.
if (!allocations.length) {
throw new BadRequestException(
'Loading has not started for this booking — use the normal wagon cancellation flow.',
'This booking has no wagons on this schedule — use the normal wagon cancellation flow.',
);
}
if (!remaining.length) {