mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 12:28:21 +00:00
Truck assiggnment and per truc
This commit is contained in:
@@ -45,6 +45,16 @@ describe('assertTruckLoad', () => {
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it('allows two containers only when both are explicitly 20ft', () => {
|
||||
expect(() =>
|
||||
assertTruckLoad({
|
||||
containers: ['ABCD1234567', 'ABCD7654321'],
|
||||
bookingContainers: booking,
|
||||
sizes: ['20ft', '45ft'],
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it('rejects more than two containers', () => {
|
||||
expect(() =>
|
||||
assertTruckLoad({
|
||||
|
||||
@@ -54,10 +54,11 @@ export function assertTruckLoad({
|
||||
}
|
||||
}
|
||||
|
||||
// A 40ft fills the bed, so it travels alone.
|
||||
if (containers.length > 1 && sizes.some((size) => size.includes('40'))) {
|
||||
// A truck may pair containers only when BOTH are explicitly 20ft. A 40ft
|
||||
// (and any legacy/unknown larger size) fills the bed and travels alone.
|
||||
if (containers.length > 1 && sizes.some((size) => !size.includes('20'))) {
|
||||
throw new BadRequestException(
|
||||
'A 40ft container fills the truck — assign only 1 container to this truck',
|
||||
'Truck capacity is either 1 x 40ft container or up to 2 x 20ft containers',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user