Enhance bulk booking handling and wagon capacity calculations across services

This commit is contained in:
Marshal
2026-07-09 15:30:00 +00:00
parent 3259bd7667
commit 1690f9e498
11 changed files with 278 additions and 32 deletions

View File

@@ -400,8 +400,18 @@ export class BookingPricingService {
* All three components are produced by RuleEngineService.evaluate, so submit
* simply re-runs the engine — there is no extra submit-time inflation.
*/
async computeSubmitPriorityScore(booking: Booking): Promise<number> {
async computeSubmitPriorityScore(
booking: Booking,
totalWagonsOverride?: number,
): Promise<number> {
const evalInput = await this.buildEvalInputForBooking(booking);
// BULK bookings have no container lines, so buildEvalInputForBooking yields
// totalWagons = 0 and every wagon-range priority config misses. The batch
// engine derives a bulk booking's wagon footprint from tonnage vs. live
// wagon capacity and passes it here to score the booking properly.
if (totalWagonsOverride != null && totalWagonsOverride > 0) {
evalInput.totalWagons = totalWagonsOverride;
}
const ruleResult = await this.ruleEngineService.evaluate(evalInput);
return ruleResult.priorityScore;
}