mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-02 12:43:43 +00:00
Implement consolidated booking handling and UI updates for shared wagons
This commit is contained in:
@@ -269,5 +269,56 @@ describe('BookingBatchService — PAID reconcile', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('reserves both partners of a consolidated pair together on one train', async () => {
|
||||
// Two 20ft bookings, 1 container each — a shared wagon. Both in the pool.
|
||||
const consol = (id: string, partnerId: string, priority: number): Booking =>
|
||||
({
|
||||
id,
|
||||
reference: id,
|
||||
isGovernment: false,
|
||||
priorityScore: priority,
|
||||
status: 'FULLY_EXECUTED',
|
||||
wagonsRequired: 1,
|
||||
cargoTotalWeightVgm: 10,
|
||||
freightType: 'CONTAINER',
|
||||
consolidationPartnerId: partnerId,
|
||||
bookingContainers: [{ quantity: 1 }],
|
||||
}) as unknown as Booking;
|
||||
|
||||
bookingsRepository.findBatchPoolByRouteDay.mockResolvedValue([
|
||||
consol('a', 'b', 30),
|
||||
consol('b', 'a', 20),
|
||||
]);
|
||||
|
||||
await service.fillRouteDay(originYardId, destinationYardId, day);
|
||||
|
||||
// Both reserved on the same (first) train; neither reported unplaced.
|
||||
const reservedIds = notifier.payNow.mock.calls.map((c) => (c[0] as Booking).id);
|
||||
expect(reservedIds.sort()).toEqual(['a', 'b']);
|
||||
expect(notifier.unplaced).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('skips a consolidated booking whose partner is not in the pool (both-or-neither)', async () => {
|
||||
const lonely = {
|
||||
id: 'a',
|
||||
reference: 'a',
|
||||
isGovernment: false,
|
||||
priorityScore: 30,
|
||||
status: 'FULLY_EXECUTED',
|
||||
wagonsRequired: 1,
|
||||
cargoTotalWeightVgm: 10,
|
||||
freightType: 'CONTAINER',
|
||||
consolidationPartnerId: 'missing-partner',
|
||||
bookingContainers: [{ quantity: 1 }],
|
||||
} as unknown as Booking;
|
||||
|
||||
bookingsRepository.findBatchPoolByRouteDay.mockResolvedValue([lonely]);
|
||||
|
||||
await service.fillRouteDay(originYardId, destinationYardId, day);
|
||||
|
||||
// Never reserved — waits for its partner in a later cycle.
|
||||
expect(notifier.payNow).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user