mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
Enhance bulk booking handling and wagon capacity calculations across services
This commit is contained in:
@@ -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 }]);
|
||||
|
||||
Reference in New Issue
Block a user