mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
fix issue
This commit is contained in:
@@ -13,7 +13,9 @@ import { YardCountry } from '@edr/types';
|
||||
//
|
||||
import { deriveTradeDirection } from '../../common/derive-trade-direction.util';
|
||||
import { CompaniesService } from '../companies/companies.service';
|
||||
import { CargoType } from '../rule-engine/entities/cargo-type.entity';
|
||||
import { ServiceType } from '../rule-engine/entities/service-type.entity';
|
||||
import { bulkTonsPerWagon } from '../train-scheduling/train-capacity.util';
|
||||
import { Yard } from '../rule-engine/entities/yard.entity';
|
||||
import { FilesService } from '../files/files.service';
|
||||
import { MinioService } from '../minio/minio.service';
|
||||
@@ -858,6 +860,29 @@ export class ContractsService {
|
||||
);
|
||||
}
|
||||
|
||||
// NUMBER_OF_WAGONS booking forms need the heaviest load one wagon may take
|
||||
// so they can reject a wagon count whose even share overloads a wagon —
|
||||
// the client-side twin of ContractBookingService.assertWagonShareFits.
|
||||
// The raw wagonTypes join rows are dropped: only the derived cap ships.
|
||||
for (const scope of contract.cargoScope ?? []) {
|
||||
const cargoType = scope.cargoType as
|
||||
| (CargoType & { maxTonsPerWagon?: number | null })
|
||||
| null
|
||||
| undefined;
|
||||
if (!cargoType) continue;
|
||||
const allowed = (cargoType.wagonTypes ?? []).filter(
|
||||
(wt) => Number(wt.capacityTons) > 0,
|
||||
);
|
||||
cargoType.maxTonsPerWagon = allowed.length
|
||||
? Math.max(
|
||||
...allowed.map((wt) =>
|
||||
bulkTonsPerWagon(cargoType, wt.id, Number(wt.capacityTons)),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
delete cargoType.wagonTypes;
|
||||
}
|
||||
|
||||
// Surface the staff "request changes" note so the portal can show the
|
||||
// customer what to fix. Degrade to null on lookup failure — a missing note
|
||||
// must never 500 a contract fetch.
|
||||
|
||||
Reference in New Issue
Block a user