Enhance bulk booking handling and wagon capacity calculations across services

This commit is contained in:
Marshal
2026-07-09 15:30:00 +00:00
parent 3259bd7667
commit 1690f9e498
11 changed files with 278 additions and 32 deletions

View File

@@ -82,6 +82,29 @@ describe('wagon-plan.util', () => {
expect(plan).toHaveLength(2);
});
it('counts a bulk booking\'s wagons from the plan, not a flat 1', () => {
// 700T of sugar on 60T CW3 gondolas = 12 wagons; the stored wagonsRequired
// must carry all of them so gross weight charges 12 tares downstream.
const booking = {
id: 'bulk-700',
reference: 'bulk-700',
freightType: 'BULK',
cargoTotalWeightVgm: 700,
bookingContainers: [],
} as unknown as Booking;
const plan = buildBulkWagonPlan([booking], cw3);
expect(plan).toHaveLength(12);
expect(sumWagonsRequired(booking, plan)).toBe(12);
// Without a plan the pre-plan fallback still applies.
expect(sumWagonsRequired(booking)).toBe(1);
});
it('counts container wagons from the plan TEU packing', () => {
const booking = makeContainerBooking('c-plan', [{ quantity: 6, wagonsRequired: 3 }]);
const plan = buildContainerWagonPlan([booking], nw5);
expect(sumWagonsRequired(booking, plan)).toBe(3);
});
it('6×20ft containers = 3 wagon slots (2 per wagon)', () => {
// 20ft containers have wagonsPerUnit = 0.5, so 6 * 0.5 = 3 wagons
const booking = makeContainerBooking('b6x20', [{ quantity: 6, wagonsRequired: 3 }]);