mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
fix(operations): last-mile assign until load fully trucked + 40ft cap
Assign was gated on any truck assigned, blocking multi-truck deliveries. Gate on remaining containers (or bulk tonnage) instead, show covered/total in the modal, cap a 40ft container to one truck with no size mixing (mirrors assertTruckLoad), and lock arrived/departed rows.
This commit is contained in:
@@ -67,6 +67,21 @@ export class FacilityHandlingService {
|
||||
inventoryId = inv?.id ?? null;
|
||||
}
|
||||
|
||||
// The handed-over weight: the booking's declared VGM, else what its
|
||||
// containers actually carry. A GRN without a weight is not a receipt.
|
||||
let weightTons = Number(booking.cargoTotalWeightVgm) || null;
|
||||
if (!weightTons) {
|
||||
const [sum]: Array<{ tons: string | null }> = await manager.query(
|
||||
`SELECT SUM(bcu.vgm_tons) AS tons
|
||||
FROM freight.booking_container_units bcu
|
||||
JOIN freight.booking_container bc
|
||||
ON bc.id = bcu.booking_container_id AND bc.deleted_at IS NULL
|
||||
WHERE bc.booking_id = $1 AND bcu.deleted_at IS NULL`,
|
||||
[booking.id],
|
||||
);
|
||||
weightTons = Number(sum?.tons) || null;
|
||||
}
|
||||
|
||||
const repo = manager.getRepository(FacilityHandlingEvent);
|
||||
await repo.save(
|
||||
repo.create({
|
||||
@@ -75,7 +90,7 @@ export class FacilityHandlingService {
|
||||
trainScheduleId: input.trainScheduleId ?? null,
|
||||
eventType,
|
||||
grnNumber,
|
||||
weightTons: Number(booking.cargoTotalWeightVgm) || null,
|
||||
weightTons,
|
||||
inventoryId,
|
||||
performedBy: input.performedBy ?? null,
|
||||
occurredAt,
|
||||
|
||||
Reference in New Issue
Block a user