mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-06 17:05:02 +00:00
train
This commit is contained in:
@@ -2913,21 +2913,23 @@ export class BookingBatchService implements OnModuleInit {
|
||||
|
||||
/**
|
||||
* Dimensions of the wagon type THIS booking rides: bulk resolves through its
|
||||
* cargo type's wagon_type_id, container through the first container line's
|
||||
* type — the same FK resolution `resolveWagonType` applies when the paid
|
||||
* booking is allocated. Board/fill math measured on a representative wagon
|
||||
* while allocation validated the real one let a selected batch flunk the
|
||||
* post-payment gross-weight check; sharing the resolution closes that gap.
|
||||
* Falls back to the representative dims when the FK or relation is absent.
|
||||
* cargo type's allowed wagon-type list, container through the first container
|
||||
* line's — the same list resolution the scheduling planner applies when the
|
||||
* paid booking is allocated. Board/fill math measured on a representative
|
||||
* wagon while allocation validated the real one let a selected batch flunk
|
||||
* the post-payment gross-weight check; sharing the resolution closes that
|
||||
* gap. Uses the first configured type (the fill engine has no train context);
|
||||
* falls back to the representative dims when the list or relation is absent.
|
||||
*/
|
||||
private dimsFor(booking: Booking, wagonDims: WagonDims): PerWagonDims {
|
||||
const fallback =
|
||||
booking.freightType === "BULK" ? wagonDims.bulk : wagonDims.container;
|
||||
const wagonTypeId =
|
||||
booking.freightType === "BULK"
|
||||
? booking.cargoType?.wagonTypeId
|
||||
? booking.cargoType?.wagonTypes?.[0]?.id
|
||||
: (booking.bookingContainers ?? [])
|
||||
.map((line) => line.containerType?.wagonTypeId)
|
||||
.flatMap((line) => line.containerType?.wagonTypes ?? [])
|
||||
.map((wagonType) => wagonType.id)
|
||||
.find((id): id is string => Boolean(id));
|
||||
const dims = wagonTypeId ? wagonDims.byWagonTypeId.get(wagonTypeId) : undefined;
|
||||
if (!dims) return fallback;
|
||||
|
||||
Reference in New Issue
Block a user